sap bdc recording with SHDB and create BDC program


Learn How to do sap bdc recording with SHDB transaction and create BDC program from it

Code
___________________________________________________________________________________
report ZVK11_BDC_DEMO
       no standard page heading line-size 255.

include bdcrecx1.

types begin of tp_itab,
         vkorg(4),
         vtweg(2),
         matnr(18),
         amount(15),
       end of tp_itab.

data gt_itab type STANDARD TABLE OF tp_itab,
       gs_itab type tp_itab.

data gv_file type string.


SELECTION-SCREEN skip.
 PARAMETERS P_FILE TYPE IBIPPARMS-PATH OBLIGATORY.
SELECTION-SCREEN SKIP.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

CALL FUNCTION 'F4_FILENAME'
* EXPORTING
*   PROGRAM_NAME        = SYST-CPROG
*   DYNPRO_NUMBER       = SYST-DYNNR
*   FIELD_NAME          = ' '
 IMPORTING
   FILE_NAME           P_FILE.



start-of-selection.

 clear gv_filegt_itab[].

  gv_file p_file.

 CALL FUNCTION 'GUI_UPLOAD'
   EXPORTING
     FILENAME                      GV_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                      gt_itab
*  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.
* Implement suitable error handling here
 ENDIF.


perform open_group.

loop at gt_itab into gs_itab.

perform bdc_dynpro      using 'SAPMV13A' '0100'.
perform bdc_field       using 'BDC_CURSOR'
                              'RV13A-KSCHL'.
perform bdc_field       using 'BDC_OKCODE'
                              '=ANTA'.
perform bdc_field       using 'RV13A-KSCHL'
                              'ZBAS'.

perform bdc_dynpro      using 'SAPLV14A' '0100'.
perform bdc_field       using 'BDC_CURSOR'
                              'RV130-SELKZ(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '=WEIT'.

perform bdc_dynpro      using 'SAPMV13A' '1004'.
perform bdc_field       using 'BDC_CURSOR'
                              'KOMG-VTWEG'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'KOMG-VKORG'
                              gs_itab-vkorg.           "'1024'.
perform bdc_field       using 'KOMG-VTWEG'
                              gs_itab-vtweg.            "'24'.

perform bdc_dynpro      using 'SAPMV13A' '1004'.
perform bdc_field       using 'BDC_CURSOR'
                              'KONP-KBETR(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.

perform bdc_field       using 'KOMG-MATNR(01)'
                              gs_itab-matnr.                 "'11000004'.

CONDENSE gs_itab-AMOUNT.
perform bdc_field       using 'KONP-KBETR(01)'
                              gs_itab-amount.                   "'             150'.

perform bdc_dynpro      using 'SAPMV13A' '1004'.
perform bdc_field       using 'BDC_CURSOR'
                              'KOMG-MATNR(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '=SICH'.
perform bdc_transaction using 'VK11'.


clear gs_itab.
endloop.

perform close_group.

Post a Comment

2 Comments

  1. Dear Sir, We are using Charactor as data type for AMOUNT field, which is oaky. In Bach Recording for DATE field we have used DDMY as data type, But how we do here in this structure definition with DATE field?.

    Thank you for your attension and Content sharing.

    ReplyDelete
  2. Is there a way to convert this complete code to class/method

    ReplyDelete

Total Pageviews