F BDC Call Transaction in SAP ABAP | CodeTheta

BDC Call Transaction in SAP ABAP

February 09, 2020

1. Go to T-Code : SHDB for recording a transaction.

2. Give Recording name - ZVP_RCD_FI01 and give Transaction Code name FI01 and click on Start recording button.

3. Give Bank Country - IN and Bank Key - 1004785 and hit enter.

4. Then enter the following -
Bank Name - ABC Bank
Region - 25
City - KOLKATA
Bank Branch - TARATALA

5. After that press save button and again click save and click back button.

6. You will see your recording name in your screen. click the recording name and click on Program.

7. Give program name ZVP_BDC_UPLOAD_FI01, click on Transfer from recording and click on continue button and click on Source and your report program will come up.

8. Create a TXT file in desktop with content below -
IN 700153 AAA 25 INDIA KOLKATA
IN 700154 BBB 25 INDIA KOLKATA
IN 700155 CCC 25 INDIA KOLKATA
IN 700156 DDD 25 INDIA KOLKATA
IN 700157 EEE  25 INDIA KOLKATA

Source Code :
REPORT ZVP_BDC_UPLOAD_FI01
       NO STANDARD PAGE HEADING LINE-SIZE 255.

*include bdcrecx1.
TYPES: BEGIN OF TY_BANK,
       BANKS TYPE BANKS,
       BANKL TYPE BANKL,
       BANKA TYPE BANKA,
       PROVZ TYPE PROVZ,
       ORT01 TYPE ORT01,
       BRNCH TYPE BRNCH,
  END OF TY_BANK.

DATA: IT_BANK TYPE TABLE OF TY_BANK,
      WA_BANK TYPE TY_BANK.

DATA: IT_BDCDATA TYPE TABLE OF BDCDATA,
      WA_BDCDATA TYPE BDCDATA.

START-OF-SELECTION.

*perform open_group.

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    FILENAME                      = 'C:\Users\soumyodeep\Desktop\BDC_UPLOAD_BNKA.TXT'
*   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_BANK
* CHANGING
*   ISSCANPERFORMED               = ' '
* 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.
MESSAGE: 'DATA UPLOADED SUCCESSFULLY' TYPE 'I'.
ENDIF.

LOOP AT IT_BANK INTO WA_BANK.

PERFORM BDC_DYNPRO      USING 'SAPMF02B' '0100'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                              'BNKA-BANKL'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                              '/00'.
PERFORM BDC_FIELD       USING 'BNKA-BANKS'
                              WA_BANK-BANKS.
PERFORM BDC_FIELD       USING 'BNKA-BANKL'
                              WA_BANK-BANKL.
PERFORM BDC_DYNPRO      USING 'SAPMF02B' '0110'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                              'BNKA-BRNCH'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                              '=UPDA'.
PERFORM BDC_FIELD       USING 'BNKA-BANKA'
                              WA_BANK-BANKA.
PERFORM BDC_FIELD       USING 'BNKA-PROVZ'
                              WA_BANK-PROVZ.
PERFORM BDC_FIELD       USING 'BNKA-ORT01'
                              WA_BANK-ORT01.
PERFORM BDC_FIELD       USING 'BNKA-BRNCH'
                              WA_BANK-BRNCH.
*PERFORM BDC_TRANSACTION USING 'FI01'.
CALL TRANSACTION 'FI01' USING IT_BDCDATA MODE 'A' UPDATE 'S'.
REFRESH IT_BDCDATA.
ENDLOOP.
*perform close_group.

*----------------------------------------------------------------------*
*        Start new screen                                              *
*----------------------------------------------------------------------*
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.

Execute the program you will see data uploaded successfully and click on OKCODE popup and save the data and data inserted to table successfully.

You can go to SE11 and give the database name BNKA and check the content for your uploaded data.

IDE Used To Test This Code : ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Post a Comment