Step by Step tutorial on BDC Session Method Program in SAP ABAP
Step by Step tutorial on BDC Session Method Program in SAP ABAP
BDC Session Method is used to upload data from Non-SAP to SAP System. Using Session method,
we can transfer data through more than one Transaction, Unlike BDC Call Transaction Method Program.
We are Processing Batch input Session From SM35 Transaction Code.
Session method.
1) synchronous processing.
2) can transfer a large amount of data.
3) processing is slower.
4) error log is created
5) data is not updated until the session is processed.
Call transaction Method.
1) asynchronous processing
2) can transfer a small amount of data
3) processing is faster.
4) errors need to be handled explicitly
5) data is updated automatically
we can transfer data through more than one Transaction, Unlike BDC Call Transaction Method Program.
We are Processing Batch input Session From SM35 Transaction Code.
Session method.
1) synchronous processing.
2) can transfer a large amount of data.
3) processing is slower.
4) error log is created
5) data is not updated until the session is processed.
Call transaction Method.
1) asynchronous processing
2) can transfer a small amount of data
3) processing is faster.
4) errors need to be handled explicitly
5) data is updated automatically
Go to SHDB and Press Enter
Click on New Recording Button and Give the zrecord1 name and enter transaction code MM01 and click on the Start recording button.
The system goes to the Create material screen, there give the industry sector and material type and selects basic data 1.
Now it will come to the second screen where give the below details and click on save button and go back.
Now save the recording and go back.
Now, select the created record, click on the program button.
The system will ask you the program name, give it, and continue.
Now give the program title and continue.
Now double click on BDCRECX1 main program
Copy the below code.
BDC Session Method Program
report ZSESSION_PROGRAM
no standard page heading line-size 255.
TYPES : BEGIN OF ty_mat,
mbrsh TYPE mbrsh,
mtart TYPE mtart,
maktx TYPE maktx,
matkl TYPE matkl,
meins TYPE meins,
END OF ty_mat.
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA:
f_name TYPE rlgrap-filename,
it_mat TYPE STANDARD TABLE OF ty_mat,
wa_mat TYPE ty_mat.
*Input Path
PARAMETERS:
p_file TYPE rlgrap-filename. " File Path
* Data decleration
DATA:
wa_path TYPE string ,
wa_error TYPE string,
wa_cnt TYPE i,
w_mode TYPE c,
wa_cnt1(2) TYPE n.
* Opening window for path selection
at SELECTION-SCREEN on VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
IMPORTING
file_name = p_file.
TYPES:
fs_struct(4096) TYPE c OCCURS 0 .
DATA:
w_struct TYPE fs_struct.
* Uploading excel file.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
* I_LINE_HEADER =
i_tab_raw_data = w_struct
i_filename = p_file
TABLES
i_tab_converted_data = it_mat
EXCEPTIONS
conversion_failed = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
start-of-selection.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'AKS'
KEEP = 'X'
USER = SY-UNAME
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.
START-OF-SELECTION.
LOOP AT it_mat INTO wa_mat.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMMG1-MBRSH'
wa_mat-mbrsh."record-MBRSH_001.
perform bdc_field using 'RMMG1-MTART'
wa_mat-mtart."record-MTART_002.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'."record-KZSEL_01_003.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
wa_mat-maktx."record-MAKTX_004.
perform bdc_field using 'BDC_CURSOR'
'MARA-MATKL'.
perform bdc_field using 'MARA-MEINS'
wa_mat-meins."record-MEINS_005.
perform bdc_field using 'MARA-MATKL'
wa_mat-matkl."record-MATKL_006.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM01'
* POST_LOCAL = NOVBLOCAL
* PRINTING = NOPRINT
* SIMUBATCH = ' '
* CTUPARAMS = ' '
TABLES
DYNPROTAB = BDCDATA
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
.
REFRESH BDCDATA.
ENDLOOP.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA .
ENDFORM. "BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA .
ENDFORM. "BDC_FIELD
no standard page heading line-size 255.
TYPES : BEGIN OF ty_mat,
mbrsh TYPE mbrsh,
mtart TYPE mtart,
maktx TYPE maktx,
matkl TYPE matkl,
meins TYPE meins,
END OF ty_mat.
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA:
f_name TYPE rlgrap-filename,
it_mat TYPE STANDARD TABLE OF ty_mat,
wa_mat TYPE ty_mat.
*Input Path
PARAMETERS:
p_file TYPE rlgrap-filename. " File Path
* Data decleration
DATA:
wa_path TYPE string ,
wa_error TYPE string,
wa_cnt TYPE i,
w_mode TYPE c,
wa_cnt1(2) TYPE n.
* Opening window for path selection
at SELECTION-SCREEN on VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
IMPORTING
file_name = p_file.
TYPES:
fs_struct(4096) TYPE c OCCURS 0 .
DATA:
w_struct TYPE fs_struct.
* Uploading excel file.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
* I_LINE_HEADER =
i_tab_raw_data = w_struct
i_filename = p_file
TABLES
i_tab_converted_data = it_mat
EXCEPTIONS
conversion_failed = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
start-of-selection.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'AKS'
KEEP = 'X'
USER = SY-UNAME
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.
START-OF-SELECTION.
LOOP AT it_mat INTO wa_mat.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMMG1-MBRSH'
wa_mat-mbrsh."record-MBRSH_001.
perform bdc_field using 'RMMG1-MTART'
wa_mat-mtart."record-MTART_002.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'."record-KZSEL_01_003.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
wa_mat-maktx."record-MAKTX_004.
perform bdc_field using 'BDC_CURSOR'
'MARA-MATKL'.
perform bdc_field using 'MARA-MEINS'
wa_mat-meins."record-MEINS_005.
perform bdc_field using 'MARA-MATKL'
wa_mat-matkl."record-MATKL_006.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM01'
* POST_LOCAL = NOVBLOCAL
* PRINTING = NOPRINT
* SIMUBATCH = ' '
* CTUPARAMS = ' '
TABLES
DYNPROTAB = BDCDATA
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
.
REFRESH BDCDATA.
ENDLOOP.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA .
ENDFORM. "BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA .
ENDFORM. "BDC_FIELD
Now save and activate the program and execute it, then go to SM35.
and also maintain the excel sheet data like below and save it in your system.
Then give the file path through F4 HELP and click on the execute button.
Now go to the SM35 Transaction code .and click on the Process button.
Select the Process or foreground button.
Now, you can see the session log details.
Click on the analyze session button to get more details.
Finally, we successfully created the BDC Session Method Program.
Conclusion
Please comment below if you know how to create BDC Session Method Program in SAP ABAP? Or share this post to help others.
Invest in high quality paper for your eye care practice. Veatch carries top-brand Printer Recording paper and printer paper for keratometers, perimeters and ...
ReplyDeleteHow to find the Group for our client , to enter it in the BDC_OPEN_GROUP Function Module.(I.e, here in the example, its entered as AKS)
ReplyDeleteclick and get it all you want
ReplyDelete
ReplyDeletemilf
ReplyDeletebdc
ReplyDeleteSCIENCE amazing fun facts and knowledge top notch
ReplyDeletedesh premi click krege desh ke liye ncc ke liyebadiya bhai mza aa gya
Aapka BDC Full Form se related article bahut accha laga thanks
ReplyDeleteIn today's competitive job market, having specialized skills in Quality Management can be a game-changer. SAP QM is a comprehensive solution for maintaining product quality across various industries. The SAP QM Training Institute in Noida at ERP NOIDA offers expert faculty, a comprehensive curriculum, hands-on learning, flexible options, and placement assistance. Whether you're a quality professional, an ERP consultant, or a recent graduate, our institute can help you unlock your potential in Quality Management. Join us today and invest in your future.
ReplyDeleteAPTRON offers state-of-the-art facilities and a conducive learning environment to facilitate your learning journey. Whether you're a beginner or looking to advance your career, our tailored curriculum caters to all levels of proficiency. Join APTRON's ERP SAP MM Training Course in Gurgaon today and take a step closer to becoming a proficient SAP MM consultant.
ReplyDeleteNice Blog! Searching for spoken english coaching in Panchkula? We focus on enhancing communication skills, fluency, and confidence in English. These programs cater to students, professionals, and individuals seeking to improve their language abilities for academic, career, or personal growth. Expert trainers provide interactive sessions covering grammar, vocabulary, pronunciation, and conversational practice. Many institutes offer customized courses, including one-on-one coaching, group discussions, and role-playing activities, to suit diverse learning needs.
ReplyDelete