BDC for Material Master Update
BDC for Material Master Update
1. We need to record the session using tcode “SHDB” to get the dummy BDC structure for MM02 screen.
Step 1 - On “SHDB” code window click on New Recording button

Step 2 - After clicking on New Recording a new dialogue will appear. Fill the required buttons and click on Start Recording

BDC OKCODE — It is the final button we press or action we do after filling up the required fields.
Step 6 - After saving you will see the BDC Dummy structure.

Step 3 - After recording the session we need to write the BDC code to pass the internal table data to the internal table of BDC structure according to the recording.
Coding Screen —>
report ZMMNIU
no standard page heading line-size 255.
include bdcrecx1.
PARAMETER p_file LIKE ibipparms-path OBLIGATORY.
DATA w_file TYPE string.
TYPES: BEGIN OF ty_record,
matnr TYPE matnr,
bismt TYPE mara-bismt,
maktx TYPE makt-maktx,
END OF ty_record.
DATA: it_record TYPE STANDARD TABLE OF ty_record.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
w_file = p_file.
start-of-selection.
perform open_group.
IF w_file IS NOT INITIAL.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = w_file
filetype = 'DAT'
has_field_separator = 'X'
TABLES
data_tab = it_record
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
CLEAR: it_record.
ENDIF.
DELETE it_record WHERE matnr = space.
LOOP AT it_record INTO DATA(ls_record).
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = ls_record-matnr
IMPORTING
output = ls_record-matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
CLEAR: ls_record.
ENDIF.
MODIFY it_record FROM ls_record TRANSPORTING matnr.
CLEAR: ls_record.
ENDLOOP.
LOOP AT it_record INTO ls_record.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-MATNR'
ls_record-matnr.
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'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MAKT-MAKTX'
ls_record-maktx.
perform bdc_field using 'BDC_CURSOR'
'MARA-MSTAE'.
*perform bdc_field using 'MARA-MEINS'
* 'EA'.
*perform bdc_field using 'MARA-MATKL'
* 'Z121'.
perform bdc_field using 'MARA-BISMT'
ls_record-bismt.
perform bdc_field using 'MARA-MSTAE'
'03'.
*perform bdc_field using 'MARA-MTPOS_MARA'
* 'NORM'.
*perform bdc_field using 'MARA-GEWEI'
* 'KG'.
perform bdc_transaction using 'MM02'.
ENDLOOP.
perform close_group.
ENDIF.
no standard page heading line-size 255.
include bdcrecx1.
PARAMETER p_file LIKE ibipparms-path OBLIGATORY.
DATA w_file TYPE string.
TYPES: BEGIN OF ty_record,
matnr TYPE matnr,
bismt TYPE mara-bismt,
maktx TYPE makt-maktx,
END OF ty_record.
DATA: it_record TYPE STANDARD TABLE OF ty_record.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
w_file = p_file.
start-of-selection.
perform open_group.
IF w_file IS NOT INITIAL.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = w_file
filetype = 'DAT'
has_field_separator = 'X'
TABLES
data_tab = it_record
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
CLEAR: it_record.
ENDIF.
DELETE it_record WHERE matnr = space.
LOOP AT it_record INTO DATA(ls_record).
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = ls_record-matnr
IMPORTING
output = ls_record-matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
CLEAR: ls_record.
ENDIF.
MODIFY it_record FROM ls_record TRANSPORTING matnr.
CLEAR: ls_record.
ENDLOOP.
LOOP AT it_record INTO ls_record.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-MATNR'
ls_record-matnr.
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'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MAKT-MAKTX'
ls_record-maktx.
perform bdc_field using 'BDC_CURSOR'
'MARA-MSTAE'.
*perform bdc_field using 'MARA-MEINS'
* 'EA'.
*perform bdc_field using 'MARA-MATKL'
* 'Z121'.
perform bdc_field using 'MARA-BISMT'
ls_record-bismt.
perform bdc_field using 'MARA-MSTAE'
'03'.
*perform bdc_field using 'MARA-MTPOS_MARA'
* 'NORM'.
*perform bdc_field using 'MARA-GEWEI'
* 'KG'.
perform bdc_transaction using 'MM02'.
ENDLOOP.
perform close_group.
ENDIF.
Comments
Post a Comment