BDC with Call Transaction without Messge Handling


Business Scenario: Uploading the customer master records to SAP system by BDC call transaction methods without message handling.

Step1. GO to Tcode- SHDB to record the XD01 transaction.

 Step2. Click on New Recording button.

 Step3. Provide the Recording Name : ‘CUST_CREATE’, transaction code- XD01 and click on start recording button.

Step4. Provide the company code, sales org, distribution channel, division and the account group

and hit Enter key from keyboard.

 Step5. Maintain the Title, Country, region and Language and hit Enter Key from Keyboard.

Step6. If required maintain some value and  Hit Enter Key from Keyboard.

Step7. If required maintain some value and  Hit Enter Key from Keyboard.

Step8. If required maintain some value and  Hit Enter Key from Keyboard.

 Step9. If required maintain some value and  Hit Enter Key from Keyboard.

Step10. If required maintain some value and  Hit Enter Key from Keyboard.

Step11. If required maintain some value and  Hit Enter Key from Keyboard.

Step12. If required maintain some value and  Hit Enter Key from Keyboard.

Step13. If required maintain some value and  Hit Enter Key from Keyboard.

 Step14. If required maintain some value and  Hit Enter Key from Keyboard.

Step15. If required maintain some value and  Hit Enter Key from Keyboard.

Step16. Maintain Order probability , currency  and  Hit Enter Key from Keyboard.

Step17. Maintain Delivery priority, Shipping conditions and delivering plant  and  Hit Enter Key from Keyboard.

 Step18. If required maintain some value and  Hit Enter Key from Keyboard.

Step19. If required maintain some value and  Hit Enter Key from Keyboard.

Step20. If required maintain some value and  Hit Enter Key from Keyboard.

Step21. Save the recording.

Step22. Maintain the Excel file containing the Records of Customer details to be uploaded to SAP system .

Step23. Go to Tcode- SE38 to create a BDC report program.

Step24. Provide the program name and click on Create button to create a report program.

Step25. Provide the below code in the program.

_________________________________________________________________________________

*&———————————————————————*

*& Report  ZBDC_CALL_TRANS_CUST_MASTER

*&

*&———————————————————————*

 

REPORT  zbdc_call_trans_cust_master.

TYPES : BEGIN OF ty_cust,

             comp_code TYPE bukrs,

             sales_org TYPE vkorg,

             dist_chnl TYPE vtweg,

             divi TYPE spart,

             acc_grp TYPE ktokd,

             title TYPE  anred,

             land TYPE land1,

            region TYPE regio,

            lang TYPE spras,

            ord_prob TYPE awahr,

            curr TYPE waers,

           del_prio TYPE lprio,

          shipp_cond TYPE vsbed,

          delv_plant TYPE vwerk,

        END OF ty_cust.

DATA : lt_excel TYPE TABLE OF alsmex_tabline,

           ls_excel TYPE alsmex_tabline,

           lt_cust TYPE TABLE OF ty_cust,

           ls_cust TYPE ty_cust,

          lt_bdc TYPE TABLE OF bdcdata,

          ls_bdc TYPE bdcdata.

PARAMETERS : path TYPE rlgrap-filename OBLIGATORY DEFAULT ‘C:\Users\ratn\Desktop\bdc with call transaction\LEAGCY CUST RECORD’.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR path .

  CALL FUNCTION ‘F4_FILENAME’

    EXPORTING

      program_name  = syst-cprog

      dynpro_number = syst-dynnr

      field_name    = ‘PATH’

    IMPORTING

      file_name     = path.

START-OF-SELECTION.

  CALL FUNCTION ‘ALSM_EXCEL_TO_INTERNAL_TABLE’

    EXPORTING

      filename                = path

      i_begin_col             = 1

      i_begin_row             = 2

      i_end_col               = 50

      i_end_row               = 50

    TABLES

      intern                  = lt_excel

    EXCEPTIONS

      inconsistent_parameters = 1

      upload_ole              = 2

      OTHERS                  = 3.

  IF sy-subrc <> 0.

* Implement suitable error handling here

  ENDIF.

  LOOP AT lt_excel INTO ls_excel.

    CASE ls_excel-col.

      WHEN ‘001’.

        ls_cust-comp_code = ls_excel-value.

      WHEN ‘002’.

        ls_cust-sales_org  = ls_excel-value.

      WHEN ‘003’.

        ls_cust-dist_chnl  = ls_excel-value.

      WHEN ‘004’.

        ls_cust-divi  = ls_excel-value.

      WHEN ‘005’.

        ls_cust-acc_grp  = ls_excel-value.

      WHEN ‘006’.

        ls_cust-title  = ls_excel-value.

      WHEN ‘007’.

        ls_cust-land  = ls_excel-value.

      WHEN ‘008’.

        ls_cust-region  = ls_excel-value.

      WHEN ‘009’.

        ls_cust-lang  = ls_excel-value.

      WHEN ‘010’.

        ls_cust-ord_prob  = ls_excel-value.

      WHEN ‘011’.

        ls_cust-curr  = ls_excel-value.

      WHEN ‘012’.

        ls_cust-del_prio  = ls_excel-value.

      WHEN ‘013’.

        ls_cust-shipp_cond  = ls_excel-value.

      WHEN ‘014’.

        ls_cust-delv_plant  = ls_excel-value.

      WHEN OTHERS.

    ENDCASE.

    AT END OF row.

      APPEND ls_cust TO lt_cust.

      CLEAR : ls_cust, ls_excel.

    ENDAT.

  ENDLOOP.

  IF lt_cust IS NOT INITIAL.

    LOOP AT lt_cust INTO ls_cust.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘0100’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘RF02D-KTOKD’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘/00’.

      PERFORM : fill_screen USING ‘RF02D-BUKRS’ ls_cust-comp_code.

      PERFORM : fill_screen USING ‘RF02D-VKORG’ ls_cust-sales_org.

      PERFORM : fill_screen USING ‘RF02D-VTWEG’ ls_cust-dist_chnl.

      PERFORM : fill_screen USING ‘RF02D-SPART’ ls_cust-divi.

      PERFORM : fill_screen USING ‘RF02D-KTOKD’ ls_cust-acc_grp.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘0110’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘KNA1-SPRAS’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘/00’.

      PERFORM : fill_screen USING ‘KNA1-ANRED’ ls_cust-title.

      PERFORM : fill_screen USING ‘KNA1-LAND1’ ls_cust-land.

      PERFORM : fill_screen USING ‘KNA1-REGIO’ ls_cust-region.

      PERFORM : fill_screen USING ‘KNA1-SPRAS’ ls_cust-lang.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘0120’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘KNA1-LIFNR’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘/00’.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘0125’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘KNA1-NIELS’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘/00’.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘0130’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘KNBK-BANKS(01)’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘=ENTR’.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘0340’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘KNVA-ABLAD(01)’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘=ENTR’.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘0370’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘KNEX-LNDEX(01)’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘=ENTR’.

      PERFORM : fill_screen USING ‘KNA1-CIVVE’ ‘X’.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘0360’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘KNVK-NAMEV(01)’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘=ENTR’.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘0210’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘KNB1-AKONT’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘/00’.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘0215’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘KNB1-ZTERM’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘/00’.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘0220’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘KNB5-MAHNA’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘/00’.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘0230’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘KNB1-VRSNR’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘/00’.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘0310’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘KNVV-BZIRK’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘/00’.

      PERFORM : fill_screen USING ‘KNVV-AWAHR’ ls_cust-ord_prob.

      PERFORM : fill_screen USING ‘KNVV-WAERS’ ls_cust-curr.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘0315’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘KNVV-VWERK’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘/00’.

      PERFORM : fill_screen USING ‘KNVV-LPRIO’ ls_cust-del_prio.

      PERFORM : fill_screen USING ‘KNVV-KZAZU’ ‘X’.

      PERFORM : fill_screen USING ‘KNVV-VSBED’ ls_cust-shipp_cond.

      PERFORM : fill_screen USING ‘KNVV-VWERK’ ls_cust-delv_plant.

      PERFORM : fill_screen USING ‘KNVV-ANTLF’ ‘9’.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘0320’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘KNVV-PERFK’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘=ENTS’.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘1350’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘KNVI-TAXKD(01)’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘=ENTR’.

      PERFORM : call_screen USING ‘SAPMF02D’ ‘0324’ ‘X’.

      PERFORM : fill_screen USING ‘BDC_CURSOR’ ‘*TPART-VTEXT(01)’.

      PERFORM : fill_screen USING ‘BDC_OKCODE’ ‘=ENTR’.

******************************MODE *********************

      ” A(ALL SCREEN)

      ” E(ERROR SCREEN ONLY)

      ” N(WITHOUT SCREEN & PROCESSING TREMINATED WITH BREACKPOINT)

      ” P(WITHOUT SCREEN & PROCESSING NOT TREMINATED WITH BREACKPOINT )

******************************UPDATE *********************

      “A(ASYNCHRONOUS UPDATE)

      “S(SYNCHRONOUNE UPDATE)

      “L(LOCAL UPDATES)

************************************************************


      CALL TRANSACTION ‘XD01’ USING lt_bdc

                                                          MODE ‘A’

                                                          UPDATE ‘A’ .

      REFRESH lt_bdc.

    ENDLOOP.

  ELSE.

    MESSAGE ‘No record to Upload’ TYPE ‘I’.

  ENDIF.

*&———————————————————————*

*&      Form  CALL_SCREEN

*&———————————————————————*

 

 

FORM call_screen  USING pgm

                                       dyn

                                       dyn_bgn.

  ls_bdc-program = pgm.

  ls_bdc-dynpro = dyn.

  ls_bdc-dynbegin = dyn_bgn.

  APPEND ls_bdc TO lt_bdc.

  CLEAR ls_bdc.

ENDFORM.                    ” CALL_SCREEN

*&———————————————————————*

*&      Form  FILL_SCREEN

*&———————————————————————*

 

FORM fill_screen  USING nam

                                       val.

  ls_bdc-fnam = nam.

  ls_bdc-fval = val.

  APPEND ls_bdc TO lt_bdc.

  CLEAR ls_bdc.

ENDFORM.                    ” FILL_SCREEN


Step 26. Activate the program and run it. Select the path of the Excel file to upload and clcik on Execute buton.

Step27. Previously put a debug point and test if proper data is coming to our internal table or not.

Step28. The excel file data are properly coming to our internal table.

Step29. Click on ENTER key to continue.

Step30. Click on ENTER key to continue.

 Step31. Click on ENTER key to continue.

.

 Step32. Click on ENTER key to continue.

Step33. Click on ENTER key to continue.

Step34. Click on ENTER key to continue.

 Step35. Click on ENTER key to continue.

Step36. Click on ENTER key to continue.

 Step37. Click on ENTER key to continue.

 Step38. Click on ENTER key to continue.

 Step39. Click on ENTER key to continue.

Step40. Click on ENTER key to continue.

Step41. Click on ENTER key to continue.

 Step42. Click on ENTER key to continue.

Step43. Click on ENTER key to continue.

Step44. Click on ENTER key to continue.

Step45. Click on ENTER key to continue.

Step46. One customer is created and Click on ENTER key to continue so that another two customer are created as our excel contains 3 records.

Step47. Similarly continue with the Enter key and other two customer will be created as or excel contains 3 records.


 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s