What are SAP BDC Tools

SAP BDC is the most effective method of mass data migration from legacy systems to SAP system. There are two methods of BDC tools i.e Call Transaction Method and Batch Input Session Method. In our previous SAP training tutorials we have discussed about what is SAP BDC

Here, we are going to explain BDC tools through the implementation of an program is done using the call transaction method.

To perform BDC using the Call transaction method, we need to do the following:

1. Analyze the legacy data. Closely study how the data which is to be transferred can be mapped into a recognized SAP structure. Also determine the necessary data types that need to be used as well as the data length conversions.

2. Next, create SAP data structures which are used to export the data. (Creation of internal table, BDCDATA)

3. Now, export the data in to a sequential file. Be very careful about the character format which is used.

4. You can use the standard SAP batch input program or customize and create your own program, depending on your requirements. Choose call transaction method or batch input session method according to your needs.

5. Now, execute the program, process the data, add it to the SAP System.

6.. For batch input session method, you will have to analyze the process log. But for the CALL TRANSACTION method, there is no proper log, you will have to use the messages that are collected by your program.

7. Closely study the results of the process analysis, correct and reprocess  the data entries that are displayed as errors.

 

Important points to be noted While writing the BDC program.

  1. Use the right transaction to process batch input data.
  2. The data has to be stored in the batch input structure, BDCDATA.
  3. Do you want to use call transaction method or batch input session method?.
  4. Now read the data from a sequential file.
  5. Do the data conversion as well as the error checking.
  6. Generate a batch input session if you are using batch input sessions method,or execute the program with CALL TRANSACTION USING statement, which processes the data directly, without using a session.

BDC DATA internal table has the following structure, which has to be followed throughout the BDC program

SAP BDC Tools and Write BDC program

Here, we present a simple BDC program using the Call Transaction method, which has been created using all the instructions given above. The transaction being processed here is MM01.

 

report ZMAT_UPLOAD_CT no standard page heading line-size 255.

TABLES : RLGRAP.

*DATA : IT_MESG LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

include bdcrecx1.

DATA : BEGIN OF IT_MM01 OCCURS 0,

MATNR(18),

MBRSH,

MTART(4),

KZSEL,

MAKTX(40),

MEINS(3),

END   OF IT_MM01.

 

DATA : IT_SUCCESS LIKE IT_MM01 OCCURS 0 WITH HEADER LINE,

IT_ERROR LIKE IT_MM01 OCCURS 0 WITH HEADER LINE.

 

DATA : STR_FPATH TYPE STRING.

 

*DATA : SUCC_FPATH LIKE RLGRAP-FILENAME,

*    SUCC_FPATH_STR TYPE STRING,

*    ERROR_FPATH_STR TYPE STRING.

 

PARAMETERS : P_FPATH LIKE RLGRAP-FILENAME.

 

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FPATH.

CALL FUNCTION ‘F4_FILENAME’

* EXPORTING

*   PROGRAM_NAME        = SYST-CPROG

*   DYNPRO_NUMBER       = SYST-DYNNR

*   FIELD_NAME          = ‘ ‘

IMPORTING

FILE_NAME           = P_FPATH.

 

start-of-selection.

 

IF P_FPATH IS NOT INITIAL.

 

STR_FPATH = P_FPATH.

 

ENDIF.

 

CALL FUNCTION ‘GUI_UPLOAD’

EXPORTING

filename                      = STR_FPATH

FILETYPE                      = ‘ASC’

tables

data_tab                      = IT_MM01.

 

LOOP AT IT_MM01.

 

WRITE :/10 IT_MM01.

 

ENDLOOP.

 

perform open_group.

 

LOOP AT IT_MM01.

 

perform bdc_dynpro      using ‘SAPLMGMM’ ‘0060’.

perform bdc_field       using ‘BDC_CURSOR’

‘RMMG1-MTART’.

perform bdc_field       using ‘BDC_OKCODE’

‘=AUSW’.

 

perform bdc_field       using ‘RMMG1-MATNR’
IT_MM01-MATNR.

 

perform bdc_field       using ‘RMMG1-MBRSH’

IT_MM01-MBRSH.

 

perform bdc_field       using ‘RMMG1-MTART’

IT_MM01-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)’

IT_MM01-KZSEL.

 

perform bdc_dynpro      using ‘SAPLMGMM’ ‘4004’.

perform bdc_field       using ‘BDC_OKCODE’

‘/00’.

 

perform bdc_field       using ‘MAKT-MAKTX’

IT_MM01-MAKTX.

 

perform bdc_field       using ‘BDC_CURSOR’

‘MARA-MEINS’.

 

perform bdc_field       using ‘MARA-MEINS’

IT_MM01-MEINS.

 

perform bdc_dynpro      using ‘SAPLSPO1’ ‘0300’.

perform bdc_field       using ‘BDC_OKCODE’

‘=YES’.

CALL TRANSACTION ‘MM01’ USING BDCDATA MODE ‘E’ UPDATE ‘S’ MESSAGES INTO MESSTAB.

*perform bdc_transaction using ‘MM01’.

 

READ TABLE MESSTAB INDEX 1.

 

IF MESSTAB-MSGTYP EQ ‘S’.

 

IT_SUCCESS = IT_MM01.

APPEND IT_SUCCESS.

 

ELSE.

 

*perform bdc_transaction using ‘MM01’.

 

IT_ERROR = IT_MM01.

APPEND IT_ERROR.

 

ENDIF.

 

REFRESH : BDCDATA,

MESSTAB.

CLEAR : MESSTAB.

ENDLOOP.

 

perform close_group.

**DOWNLOAD ALL succ and error recs as files on to the desktop

 

IF IT_SUCCESS[] IS NOT INITIAL.

 

CALL FUNCTION ‘GUI_DOWNLOAD’

EXPORTING

filename                        = ‘C:\Users\Reliance\Desktop\ZSUCCESS.TXT’

FILETYPE                        = ‘ASC’

WRITE_FIELD_SEPARATOR           = ‘X’

tables

data_tab                        = IT_SUCCESS.

 

ENDIF.

 

IF IT_ERROR[] IS NOT INITIAL.

 

CALL FUNCTION ‘GUI_DOWNLOAD’

EXPORTING

filename                        = ‘C:\Users\Reliance\Desktop\ZERROR.TXT’

FILETYPE                        = ‘ASC’

WRITE_FIELD_SEPARATOR           = ‘X’

tables

data_tab                        = IT_ERROR.

 

ENDIF.

Read more for SAP BDC tools and BDC programming interview questions with scenarios.