Beruflich Dokumente
Kultur Dokumente
Scenario: Uploading customer master records to SAP system by BDC session method.
Session Method:
Session method is always synchronous.
Message is handled automatically by the session log.
Mostly used for huge amount of data upload.
Multiple Trasactions can be processed by a single session method.
Step1. The recording of XD01 (Customer Master Creation ) from SHDB transaction is given below.
[http://3.bp.blogspot.com/-rPp67zDhQp4/UsjVyVqpMII/AAAAAAAAGmo/t_Mx73tL_mM/s1600/25.jpg]
Step2. Go to SE38 and create a report program for bdc session method.
[http://2.bp.blogspot.com/mKGi3gWWxyg/UskT1SDyFII/AAAAAAAAGqg/W_qBY5FJIUE/s1600/26.JPG]
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.
PERFORM bdc_open_group.
PERFORM bdc_create_group.
PERFORM bdc_close_group.
*&---------------------------------------------------------------------*
*&
Form BDC_OPEN_GROUP
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM bdc_open_group .
CONCATENATE sy-datum sy-uzeit INTO session_name .
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client
= sy-mandt
* DEST
= FILLER8
group
= session_name
* HOLDDATE
= FILLER8
keep
= 'x'
user
= sy-uname
* RECORD
= FILLER1
prog
= sy-cprog
* DCPFM
= '%'
* DATFM
= '%'
* IMPORTING
* QID
=
EXCEPTIONS
client_invalid
=1
destination_invalid
=2
group_invalid
=3
group_is_locked
=4
holddate_invalid
=5
internal_error
=6
queue_error
=7
running
=8
system_lock_error
=9
user_invalid
= 10
OTHERS
= 11
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
" BDC_OPEN_GROUP
*&---------------------------------------------------------------------*
*&
Form BDC_CREATE_GROUP
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM bdc_create_group .
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)'.
*
text
*----------------------------------------------------------------------*
*
-->P_0273 text
*
-->P_0274 text
*
-->P_0275 text
*----------------------------------------------------------------------*
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
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_0625 text
*
-->P_0626 text
*----------------------------------------------------------------------*
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 3.1. The excel file format should be as follows.
[http://2.bp.blogspot.com/-10KVwAyrN9M/UskUft12ZRI/AAAAAAAAGqo/PGifOs6fd_M/s1600/28.JPG]
Step4. Run the report and select the excel file and execute it.
[http://3.bp.blogspot.com/--vSNfjt19HU/UsjWZgrg6yI/AAAAAAAAGmw/Y9MJEvYZn6M/s1600/1.JPG]
[http://1.bp.blogspot.com/-cwBlEYQ2pCo/UsjWgoU1HrI/AAAAAAAAGoE/0Bl0MX8hxIg/s1600/2.JPG]
[http://2.bp.blogspot.com/-S-3YyJPZeAU/UsjWmeLJAKI/AAAAAAAAGo8/8aoqYU3zV7U/s1600/3.JPG]
[http://3.bp.blogspot.com/-rXC7tyMrPzA/UsjWm62H41I/AAAAAAAAGpI/yVnS08idDb8/s1600/4.JPG]
Step8. Select the radio button as per necessary and click on Process button.
[http://4.bp.blogspot.com/-rRR0TCMO1dA/UsjWnxPRhyI/AAAAAAAAGpU/Pg76SUQ0mYs/s1600/5.JPG]
[http://3.bp.blogspot.com/-JgngGbM-WkM/UsjWnhn-UTI/AAAAAAAAGpQ/t6d1_xAOgQ0/s1600/6.JPG]
[http://2.bp.blogspot.com/-n5P1O7BK95k/UsjWovBJAyI/AAAAAAAAGpg/C_-HeezJNPE/s1600/7.JPG]
No comments yet
Add a comment
[http://4.bp.blogspot.com/-SW0i2cZ3UM8/UsjWpf5JnKI/AAAAAAAAGpo/ateB6LT4VAk/s1600/8.JPG]
[http://4.bp.blogspot.com/-T0DNVjlQVhQ/UsjWpk66HfI/AAAAAAAAGps/pHze1DL67CE/s1600/9.JPG]
[http://3.bp.blogspot.com/-a0XoIsnJ8BE/UsjWbJELKZI/AAAAAAAAGm4/byJju1_e6OY/s1600/10.JPG]
[http://3.bp.blogspot.com/-nx0gGAG5R5c/UsjWb06S9vI/AAAAAAAAGnA/v3gy9ldoZnI/s1600/11.JPG]
[http://3.bp.blogspot.com/-Pgn9OhrsQrM/UsjWcJ2yqaI/AAAAAAAAGnM/gsfrtb8E2Kc/s1600/12.JPG]
[http://4.bp.blogspot.com/-hiTIDdceGeM/UsjWcU7s2yI/AAAAAAAAGnI/ZLCiGB5seCI/s1600/13.JPG]
[http://2.bp.blogspot.com/-VNM9QQcsBaQ/UsjWdLIC9rI/AAAAAAAAGnU/mjMeQLNY0QE/s1600/14.JPG]
[http://4.bp.blogspot.com/-sXoiWKj3qCM/UsjWdqnFtsI/AAAAAAAAGng/yU0c_fav6Wg/s1600/15.JPG]
[http://3.bp.blogspot.com/-LH4sDbqe-e4/UsjWeNtVOCI/AAAAAAAAGnk/r1WfEVkwtc8/s1600/16.JPG]
[http://4.bp.blogspot.com/-GAgxyS2nXo8/UsjWe0aPLhI/AAAAAAAAGnw/45qyQm8A_wo/s1600/17.JPG]
[http://3.bp.blogspot.com/-K39-hhRhtcY/UsjWgSKbyaI/AAAAAAAAGn4/GLO6v_pGp4E/s1600/18.JPG]
[http://1.bp.blogspot.com/-9KLqzafHyGA/UsjWgbPK64I/AAAAAAAAGn8/Cx4PqhVTCqU/s1600/19.JPG]
[http://1.bp.blogspot.com/-vkDZJIOwYsA/UsjWha624fI/AAAAAAAAGoM/wFAiVHE_aGQ/s1600/20.JPG]
[http://4.bp.blogspot.com/-RomaA0ushDw/UsjWhyvWAKI/AAAAAAAAGoU/kv0sodV__ac/s1600/21.JPG]
[http://1.bp.blogspot.com/-whXG_8zPTDQ/UsjWiRIwEUI/AAAAAAAAGog/UqEHgOQEWo4/s1600/22.JPG]
Step26.Hit Enter key from key board to continue. After processing all the reocrd the below screen will apprear. Now
to see the message log select the line and click on Analysis button.
[http://1.bp.blogspot.com/-WUekin9qJ-c/UsjWjlc9CfI/AAAAAAAAGoo/09JYNJAQWWc/s1600/23.JPG]
Step27. The The transaction XD01 is called thrice as our excel contained 3 records of customer master.
[http://3.bp.blogspot.com/-9E-TcVe0Vsc/UsjWjyHTWdI/AAAAAAAAGos/WRyUh_-CLAU/s1600/24.JPG]
Step28. Click on the third tab and it displays what are the customer numbers are created.
________________________________________________________________________________
[http://4.bp.blogspot.com/-lYml0LOUWnI/UsjWmK7UHuI/AAAAAAAAGo4/eTZQsIThmWY/s1600/25.JPG]