SAP Tutorials Blog




BDC Call Transaction Method Program in SAP ABAP

BDC is Bach data communication program which is used to migrate data from legacy(Non-SAP) system to SAP ABAP System.Call Transaction Method is one of the Techniques of BDC.


In call Transaction Method ,we have to record the Transaction using SHDB Transaction code to get the screen fields and related Program that is include bdcrecx1.



Go to SHDB Transaction Code and Click on New Recording.



BDC Call Transaction Method Program in SAP ABAP

Give the Record name and Transaction code and click on Start New Recording Button.

BDC Call Transaction Method Program in SAP ABAP

Now enter the Bank country and Key

BDC Call Transaction Method Program in SAP ABAP

Now enter the Bank name ,City ,country and street. 

BDC Call Transaction Method Program in SAP ABAP

Now Save the Recording .

BDC Call Transaction Method Program in SAP ABAP

Now select the created record and click on Program.

BDC Call Transaction Method Program in SAP ABAP

Now give the program title and select radio button transfer from recording.


BDC Call Transaction Method Program in SAP ABAP

Now give the program title and click on source code button.


BDC Call Transaction Method Program in SAP ABAP

Now save it as Local object.

BDC Call Transaction Method Program in SAP ABAP

Now BDC program will be created automatically and you can find the structures and dynpro and dynfield subroutines in Include BDCRECX1 main program.Copy them and paste in your source code.

BDC Call Transaction Method Program in SAP ABAP

Now ,you can see the whole code in the below.


report ZBDC_CALLTRNS_PRO4

       no standard page heading line-size 255.


*include bdcrecx1.



types : begin of ty_bnka,

         banks type bnka-banks,

         bankl type bnka-bankl,

         banka type bnka-banka,

        stras type bnka-stras,

        ort01 type bnka-ort01,

         end of ty_bnka.


         data : it_bnka type table of ty_bnka,

                wa_bnka type ty_bnka.

         data : it_bdcdata type table of bdcdata,

                wa_bdcdata type bdcdata.


         data : bdcmsg type table of bdcmsgcoll.

         data : file type string.





         parameters : p_file type rlgrap-filename.



start-of-selection.


         if  p_file is not initial.

           file = p_file.

           ENDIF.

           CALL FUNCTION 'GUI_UPLOAD'

             EXPORTING

               FILENAME                      = file

              FILETYPE                      = 'ASC'

              HAS_FIELD_SEPARATOR           = 'X'

*              HEADER_LENGTH                 = 0

*              READ_BY_LINE                  = 'X'

*              DAT_MODE                      = ' '

*              CODEPAGE                      = ' '

*              IGNORE_CERR                   = ABAP_TRUE

*              REPLACEMENT                   = '#'

*              CHECK_BOM                     = ' '

*              VIRUS_SCAN_PROFILE            =

*              NO_AUTH_CHECK                 = ' '

*            IMPORTING

*              FILELENGTH                    =

*              HEADER                        =

             TABLES

               DATA_TAB                      = it_bnkA

*            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.

* Implement suitable error handling here

           ENDIF.


*perform open_group.

LOOP AT IT_BNKA INTO WA_BNKA.

perform bdc_dynpro      using 'SAPMF02B' '0100'.

perform bdc_field       using 'BDC_CURSOR'

                              'BNKA-BANKL'.

perform bdc_field       using 'BDC_OKCODE'

                              'ENTER'.

perform bdc_field       using 'BNKA-BANKS'

                              WA_BNKA-BANKS.

perform bdc_field       using 'BNKA-BANKL'

                              WA_BNKA-BANKL.

perform bdc_dynpro      using 'SAPMF02B' '0110'.

perform bdc_field       using 'BDC_CURSOR'

                              'BNKA-ORT01'.

perform bdc_field       using 'BDC_OKCODE'

                              'ENTER'.

perform bdc_field       using 'BNKA-BANKA'

                              WA_BNKA-BANKA.


perform bdc_field       using 'BNKA-STRAS'

                              WA_BNKA-STRAS.

perform bdc_field       using 'BNKA-ORT01'

                              WA_BNKA-ORT01.


CALL TRANSACTION 'FI01' USING IT_BDCDATA MODE 'A' UPDATE 'A' MESSAGES INTO BDCMSG.


*perform close_group.

ENDLOOP.



DATA : WA_BDCMSG LIKE LINE OF BDCMSG.

IF BDCMSG IS NOT INITIAL.

  LOOP AT BDCMSG INTO WA_BDCMSG.

    WRITE: WA_BDCMSG-TCODE,WA_BDCMSG-MSGTYP,WA_BDCMSG-MSGV1,WA_BDCMSG-FLDNAME.

    CLEAR WA_BDCMSG.


    ENDLOOP.

    ENDIF.



FORM BDC_DYNPRO USING PROGRAM DYNPRO.

  CLEAR WA_BDCDATA.

  WA_BDCDATA-PROGRAM  = PROGRAM.

  WA_BDCDATA-DYNPRO   = DYNPRO.

  WA_BDCDATA-DYNBEGIN = 'X'.

  APPEND WA_BDCDATA TO IT_BDCDATA.

ENDFORM.


*----------------------------------------------------------------------*

*        Insert field                                                  *

*----------------------------------------------------------------------*

FORM BDC_FIELD USING FNAM FVAL.

*  IF FVAL <> NODATA.

    CLEAR WA_BDCDATA.

    WA_BDCDATA-FNAM = FNAM.

    WA_BDCDATA-FVAL = FVAL.

    APPEND WA_BDCDATA TO IT_BDCDATA.

*  ENDIF.

ENDFORM.


Serkan AKKAVAK

Computer Engineer BSc

SAP Department Deputy Manager

Contact : serkurumsal@yandex.com