2. • BDC’s are interface are used to upload the data from legacy system
to SAP System.
• 2 Methods.
1. Call Transaction method.
2. Session method.
• Steps :
1. Get the flat file from the customer. Flat file might be excel or text
file.
2. Get a sample recording with the help of SHDB .
3. Create a program with the help of recording.
4. Create a structure according to flat file fields.
5. Upload the flat file data into internal table using GUI_UPLOAD.
6. Loop at internal table to work area to create to repeat the
operation.
4. • Click on new recording .
• Enter recoding name ex: zmaterial.
• Transaction code . Ex : MM01.
• Update mode .
• And click on start recording.
5.
6.
7. Call Transaction Method
TYPES : BEGIN OF T_MARA,
MATNR(18) TYPE C ,
MBRSH TYPE C,
MTART(4) TYPE C,
MAKTX(40) TYPE C,
MEINS(2) TYPE C,
END OF T_MARA.
DATA : IT_MARA TYPE TABLE OF T_MARA,
WA_MARA TYPE T_MARA.
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
* messages of call transaction
DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
*include bdcrecx1.
PARAMETERS : FILE(120) TYPE C.
8. • AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE.
PERFORM SEARCH_FILE.
start-of-selection.
PERFORM UPLOAD_DATA.
PERFORM BDC_DATA.
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
* IF FVAL <> NODATA.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
* ENDIF.
ENDFORM.
9. • form SEARCH_FILE .
DATA : FILE_NAME TYPE IBIPPARMS-PATH.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SY-REPID
DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
IMPORTING
FILE_NAME = FILE_NAME.
.
FILE = FILE_NAME.
endform. " SEARCH_FILE
11. • form BDC_DATA .
* perform open_group.
LOOP AT IT_MARA INTO WA_MARA.
REFRESH BDCDATA[].
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-MATNR'
WA_MARA-MATNR.
perform bdc_field using 'RMMG1-MBRSH'
WA_MARA-MBRSH.
perform bdc_field using 'RMMG1-MTART'
WA_MARA-MTART.
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'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
WA_MARA-MAKTX.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
WA_MARA-MEINS.
perform bdc_field using 'MARA-MTPOS_MARA'
'NORM'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
*perform bdc_transaction using 'MM01'.
*
*perform close_group.
12. • CALL TRANSACTION 'MM01' USING BDCDATA[] UPDATE 'S'
MODE 'A'
MESSAGES INTO MESSTAB.
PERFORM PRINT_MESSAGE.
ENDLOOP.
endform. " BDC_DATA
13. • form PRINT_MESSAGE .
DATA : MES(120) TYPE C.
LOOP AT MESSTAB.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = MESSTAB-MSGID
LANG = SY-LANGU
NO = MESSTAB-MSGNR
V1 = MESSTAB-MSGV1
V2 = MESSTAB-MSGV2
V3 = MESSTAB-MSGV3
V4 = MESSTAB-MSGV4
IMPORTING
MSG = MES
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
WRITE : / MES.
ENDLOOP.
REFRESH MESSTAB.
endform. " PRINT_MESSAGE
14. Session Method
•
TYPES : BEGIN OF T_MARA,
MATNR(18) TYPE C,
MBRSH TYPE C,
MTART(4) TYPE C,
MAKTX(40) TYPE C,
MEINS(2) TYPE C,
END OF T_MARA.
DATA : IT_MARA TYPE TABLE OF T_MARA,
WA_MARA TYPE T_MARA.
PARAMETERS: FILE(120) TYPE C.
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE.
PERFORM SEARCH_FILE
15. AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE.
PERFORM SEARCH_FILE.
form SEARCH_FILE .
DATA : FILE_NAME TYPE IBIPPARMS-PATH.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SY-REPID
DYNPRO_NUMBER = '1000'
* FIELD_NAME = ' '
IMPORTING
FILE_NAME = FILE_NAME
.
FILE = FILE_NAME.
endform. " SEARCH_FILE
18. LOOP AT IT_MARA INTO WA_MARA.
CLEAR BDCDATA[].
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-MATNR'
WA_MARA-MATNR.
perform bdc_field using 'RMMG1-MBRSH'
WA_MARA-MBRSH.
perform bdc_field using 'RMMG1-MTART'
WA_MARA-MTART.
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'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
WA_MARA-MAKTX.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
WA_MARA-MEINS.
perform bdc_field using 'MARA-MTPOS_MARA'
'NORM'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
*perform bdc_transaction using 'MM01'.
*
20. • CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
21. • FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
* IF FVAL <> NODATA.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
* ENDIF.
ENDFORM.
• ------------------------------------------------------------------------------
• Go to Transaction ‘SM35’ and click on process.
22. LSMW
• Legacy System migration workbench.
• Use to upload the data from legacy system to SAP system.
• Steps :
1. Transaction code ‘LSMW’.
2. Enter Project name , Subproject name and object name.
3. Click on create.
4. Enter the description for project , Subproject and object .
5. Click on Execute.
23.
24. • Maintain Object Attributes :
1. Get the recording .
2. Go to -> recording overview -> create.
3. Enter recording name and short description.
4. Enter the Transaction code ex : ‘XD01’.
5. Create the recording.
25.
26. • Click on default all , value entered fields in XDO1 transaction
are automatically appears.
• Save and click on back.
• Click on Batch Input Recording.
1. Check f4 help for recording. Recording name automatically
pull’s up.
• Click on back button.
• Save and click on back button.
27. Maintain source structure .
1. Create a structure according to flat file.
• Click on execute.
• Click on change and create.
• Enter structure name and short description.
• Click on Save.
Maintain Source fields .
1. To define the fields in the structure.
Click on execute.
Click on Edit and change.
Click on structure name and click table maintenance.
Enter the field name , type , length and description.
30. Maintain Structure Relation.
• Click on execute .
• Click on display change and save.
• Suppose If a project having different flat files, then structure
of different flat files we need to define here.
31. Maintain Field Mapping and conversion Rules .
1. To map the flat file fields with SAP fields.
• Click on execute.
• Click on change display.
32. • Click on SAP structure filed.
• Click on Source and map the fields SAP fields with Source
fields.
33.
34.
35. Fixed Values, Translations, User Defined Routines :
We Can define some fixed values and translation rules in this
step.
Specify Files : To mention flat file location.
36. • Enter flat file location and give name.
• Delimiter : Select as per flat file.
• And check field names at start of file.
• Save and click on back button.
Assign Files :
Execute .
Change and save.
Read Data :
Execute.
Actual data uploaded from flat file into SAP LSMW.
Display Read Data .
Display’s read data from flat file.
37. Convert Data :
1. Converts flat file data into SAP screen related data.
Execute.
Display Converted Data :
Its shows which transaction we are using .
Create Batch Input Session :
Execute.
Check Keep batch input folders?
Execute.
Run Batch Input Session.
Execute.
SM35 transaction screen will appear .
Select object name and click on process.