Skip to Content
avatar image
Former Member

how do we handle BDC table control

hi sap technical guru,

PLS suggest me how to handle BDC table control while uploading data to sap R/3

regards,

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • avatar image
    Former Member
    Feb 05, 2013 at 11:31 AM

    Check this Sample program  for VA01.

    *&---------------------------------------------------------------------*

    *& Report  ZALANBDC2

    *&

    *&---------------------------------------------------------------------*

    *&

    *&

    *&---------------------------------------------------------------------*

    report  zalanbdc2.

    types : begin of ty_va01,

            auart type vbak-auart,

            vkorg type vbak-vkorg,

            vtweg type vbak-vtweg,

            spart type vbak-spart,

            bstkd type vbkd-bstkd,

            bstdk(10) type c,

            kunnr1 type kuagv-kunnr,

            kunnr type kuwev-kunnr,

            ketdat type rv45a-ketdat,

            zterm type vbkd-zterm,

            inco1 type vbkd-inco1,

            inco2 type vbkd-inco2,

            mabnr type rv45a-mabnr,

    *        POSNR TYPE VBAP-POSNR,

            kwmeng type rv45a-kwmeng,

            index type i,

            end of ty_va01.

    types : begin of ty_header,

            auart type vbak-auart,

            vkorg type vbak-vkorg,

            vtweg type vbak-vtweg,

            spart type vbak-spart,

            bstkd type vbkd-bstkd,

            bstdk(10) type c,

            kunnr1 type kuagv-kunnr,

            kunnr type kuwev-kunnr,

            ketdat type rv45a-ketdat,

            zterm type vbkd-zterm,

            inco1 type vbkd-inco1,

            inco2 type vbkd-inco2,

            index type i,

            end of ty_header.

    types : begin of ty_va01a,

            index type i,

            mabnr type rv45a-mabnr,

            kwmeng type rv45a-kwmeng,

            end of ty_va01a.

    data : it_va01a type table of ty_va01a,

           wa_va01a type ty_va01a,

           it_header type table of ty_header,

           wa_header type ty_header.

    data : it_va01 type table of ty_va01,

           wa_va01 type ty_va01,

           is_bdcdata          type         bdcdata,

           is_messtab          type         bdcmsgcoll,

           is_t100             type         t100,

           it_lines          type table of tline,

           it_bdcdata        type table of bdcdata,

           it_messtab        like bdcmsgcoll occurs 0 with header line.

    data : v_msg(100) type c.

    data: begin of record,

    * data element: AUART

            auart_001(004),

    * data element: VKORG

            vkorg_002(004),

    * data element: VTWEG

            vtweg_003(002),

    * data element: SPART

            spart_004(002),

    * data element: BSTKD

            bstkd_005(035),

    * data element: BSTDK

            bstdk_006(010),

    * data element: KUNAG

            kunnr_007(010),

    * data element: KUNWE

            kunnr_008(010),

    * data element: KETDAT

            ketdat_009(010),

    * data element: KPRGBZ

            kprgbz_010(001),

    * data element: PRSDT

            prsdt_011(010),

    * data element: DZTERM

            zterm_012(004),

    * data element: INCO1

            inco1_013(003),

    * data element: INCO2

            inco2_014(028),

    * data element: MATNR

            mabnr_01_015(018),

    * data element: MATNR

            mabnr_02_016(018),

    * data element: POSNR_VA

            posnr_01_017(006),

    * data element: POSNR_VA

            posnr_02_018(006),

    * data element: KWMENG

            kwmeng_01_019(019),

    * data element: KWMENG

            kwmeng_02_020(019),

    * data element: BSTKD

            bstkd_021(035),

    * data element: BSTDK

            bstdk_022(010),

    * data element: KUNAG

            kunnr_023(010),

    * data element: KUNWE

            kunnr_024(010),

    * data element: KETDAT

            ketdat_025(010),

    * data element: KPRGBZ

            kprgbz_026(001),

    * data element: PRSDT

            prsdt_027(010),

    * data element: DZTERM

            zterm_028(004),

    * data element: INCO1

            inco1_029(003),

    * data element: INCO2

            inco2_030(028),

          end of record.

    data : it_excel type table of alsmex_tabline,

           wa_excel type alsmex_tabline.

    parameter : pa_file type ibipparms-path.

    at selection-screen on value-request for pa_file.

    call function 'F4_FILENAME'

    * EXPORTING

    *   PROGRAM_NAME        = SYST-CPROG

    *   DYNPRO_NUMBER       = SYST-DYNNR

    *   FIELD_NAME          = ' '

    importing

       file_name           = pa_file

              .

    *** End generated data section ***

    start-of-selection.

    call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

      exporting

        filename                      = pa_file

        i_begin_col                   = 1

        i_begin_row                   = 2

        i_end_col                     = 15

        i_end_row                     = 100

      tables

        intern                        = it_excel

    exceptions

       inconsistent_parameters       = 1

       upload_ole                    = 2

              .

    if sy-subrc = 0.

    endif.

    loop at it_excel into wa_excel.

    case wa_excel-col.

    when 1.

          wa_va01-auart = wa_excel-value.

    when 2.

          wa_va01-vkorg = wa_excel-value.

    when 3.

          wa_va01-vtweg = wa_excel-value.

    when 4.

          wa_va01-spart = wa_excel-value.

    when 5.

          wa_va01-bstkd = wa_excel-value.

    when 6.

          wa_va01-bstdk = wa_excel-value.

    when 7.

          wa_va01-kunnr1 = wa_excel-value.

    when 8.

          wa_va01-kunnr = wa_excel-value.

    when 9.

          wa_va01-ketdat = wa_excel-value.

    when 10.

          wa_va01-zterm = wa_excel-value.

    when 11.

          wa_va01-inco1 = wa_excel-value.

    when 12.

          wa_va01-inco2 = wa_excel-value.

    when 13.

          wa_va01-mabnr = wa_excel-value.

    *WHEN 14.

    *      WA_VA01-POSNR = WA_EXCEL-VALUE.

    when 14.

          wa_va01-kwmeng = wa_excel-value.

    when 15.

          wa_va01-index  = wa_excel-value.

    endcase.

    at end of row.

    append wa_va01 to it_va01.

    endat.

    endloop.

    loop at it_va01 into wa_va01.

    wa_header-auart = wa_va01-auart.

    wa_header-vkorg   = wa_va01-vkorg.

    wa_header-vtweg = wa_va01-vtweg.

    wa_header-spart  = wa_va01-spart.

    wa_header-bstkd = wa_va01-bstkd.

    wa_header-bstdk = wa_va01-bstdk.

    wa_header-kunnr1 = wa_va01-kunnr1.

    wa_header-kunnr = wa_va01-kunnr.

    wa_header-ketdat = wa_va01-ketdat.

    wa_header-zterm = wa_va01-zterm.

    wa_header-inco1 = wa_va01-inco1.

    wa_header-inco2 =  wa_va01-inco2.

    wa_header-index = wa_va01-index.

    append wa_header to it_header.

    endloop.

    loop at it_va01 into wa_va01.

       wa_va01a-index = wa_va01-index.

       wa_va01a-mabnr = wa_va01-mabnr.

       wa_va01a-kwmeng = wa_va01-kwmeng.

       append wa_va01a to it_va01a.

    endloop.

    sort it_header by index.

    delete adjacent duplicates from it_header comparing index.

    loop at it_header into wa_header.

    refresh it_bdcdata.

    perform bdc_dynpro      using 'SAPMV45A' '0101'.

    perform bdc_field       using 'BDC_CURSOR'

                                  'VBAK-AUART'.

    perform bdc_field       using 'BDC_OKCODE'

                                  '/00'.

    perform bdc_field       using 'VBAK-AUART'

                                  wa_header-auart.

    perform bdc_field       using 'VBAK-VKORG'

                                  wa_header-vkorg.

    perform bdc_field       using 'VBAK-VTWEG'

                                  wa_header-vtweg.

    perform bdc_field       using 'VBAK-SPART'

                                  wa_header-spart.

    perform bdc_dynpro      using 'SAPMV45A' '4001'.

    perform bdc_field       using 'BDC_OKCODE'

                                  '/00'.

    perform bdc_field       using 'VBKD-BSTKD'

                                  wa_header-bstkd.

    perform bdc_field       using 'VBKD-BSTDK'

                                  wa_header-bstdk.

    perform bdc_field       using 'KUAGV-KUNNR'

                                  wa_header-kunnr1.

    perform bdc_field       using 'KUWEV-KUNNR'

                                  wa_header-kunnr.

    perform bdc_field       using 'RV45A-KETDAT'

                                  wa_header-ketdat.

    *perform bdc_field       using 'RV45A-KPRGBZ'

    *                              record-KPRGBZ_010.

    *perform bdc_field       using 'VBKD-PRSDT'

    *                              record-PRSDT_011.

    perform bdc_field       using 'VBKD-ZTERM'

                                  wa_header-zterm.

    perform bdc_field       using 'VBKD-INCO1'

                                  wa_header-inco1.

    perform bdc_field       using 'VBKD-INCO2'

                                  wa_header-inco2.

    data : fnam(20) type c,

           idx      type c.

    move 1 to idx.

    loop at it_va01a into wa_va01a where index = wa_header-index.

    *perform bdc_field       using 'BDC_CURSOR'

    *                              wa_va01a-KWMENG.

    concatenate 'RV45A-MABNR(' idx ')' into fnam.

    perform bdc_field       using fnam

                                  wa_va01a-mabnr.

    *perform bdc_field       using 'RV45A-MABNR(02)'

    **                              record-MABNR_02_016.

    *perform bdc_field       using 'VBAP-POSNR(01)'

    *                              record-POSNR_01_017.

    *perform bdc_field       using 'VBAP-POSNR(02)'

    *                              record-POSNR_02_018.

    concatenate 'RV45A-KWMENG(' idx ')' into fnam.

    perform bdc_field       using fnam

                                  wa_va01a-kwmeng.

    *perform bdc_field       using 'RV45A-KWMENG(02)'

    *                              record-KWMENG_02_020.

    idx = idx + 1.

    endloop.

    perform bdc_dynpro      using 'SAPMV45A' '4001'.

    perform bdc_field       using 'BDC_OKCODE'

                                  '=SICH'.

    *perform bdc_field       using 'VBKD-BSTKD'

    *                              record-BSTKD_021.

    *perform bdc_field       using 'VBKD-BSTDK'

    *                              record-BSTDK_022.

    *perform bdc_field       using 'KUAGV-KUNNR'

    *                              record-KUNNR_023.

    *perform bdc_field       using 'KUWEV-KUNNR'

    *                              record-KUNNR_024.

    *perform bdc_field       using 'RV45A-KETDAT'

    *                              record-KETDAT_025.

    *perform bdc_field       using 'RV45A-KPRGBZ'

    *                              record-KPRGBZ_026.

    *perform bdc_field       using 'VBKD-PRSDT'

    *                              record-PRSDT_027.

    *perform bdc_field       using 'VBKD-ZTERM'

    *                              record-ZTERM_028.

    *perform bdc_field       using 'VBKD-INCO1'

    *                              record-INCO1_029.

    *perform bdc_field       using 'VBKD-INCO2'

    *                              record-INCO2_030.

    *perform bdc_field       using 'BDC_CURSOR'

    *                              'RV45A-MABNR(03)'.

    *perform bdc_transaction using 'VA01'.

        call transaction 'VA01' using it_bdcdata

                         mode   'A'

                         update 'S'

                         messages into it_messtab.

        perform fill_message.

        refresh it_bdcdata[].

    endloop.

    *&---------------------------------------------------------------------*

    *&      Form  bdc_dynpro

    *&---------------------------------------------------------------------*

    *       text

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

    *      -->P_0381   text

    *      -->P_0382   text

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

    form bdc_dynpro  using    program type sy-cprog

                              dynpro type sy-cprog.

      clear is_bdcdata.

      is_bdcdata-program  = program.

      is_bdcdata-dynpro   = dynpro.

      is_bdcdata-dynbegin = 'X'.

      append is_bdcdata to it_bdcdata.

    endform.                    " bdc_dynpro

    *&---------------------------------------------------------------------*

    *&      Form  bdc_field

    *&---------------------------------------------------------------------*

    *       text

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

    *      -->P_0386   text

    *      -->P_0387   text

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

    form bdc_field  using    fnam type any

                             fval type any.

      clear is_bdcdata.

      is_bdcdata-fnam = fnam.

      is_bdcdata-fval = fval.

      shift is_bdcdata-fval left deleting leading space. .

      append is_bdcdata to it_bdcdata.

    endform.                    " bdc_field

    *&---------------------------------------------------------------------*

    *&      Form  fill_message

    *&---------------------------------------------------------------------*

    *       text

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

    *  -->  p1        text

    *  <--  p2        text

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

    form fill_message .

    clear v_msg.

      loop at it_messtab .

        call function 'FORMAT_MESSAGE'

          exporting

            id        = it_messtab-msgid

            lang      = 'EN'

            no        = it_messtab-msgnr

            v1        = it_messtab-msgv1

            v2        = it_messtab-msgv2

            v3        = it_messtab-msgv3

            v4        = it_messtab-msgv4

          importing

            msg       = v_msg

          exceptions

            not_found = 1.

      endloop .

      write : / v_msg.

      refresh it_messtab .

    endform.                    " fill_message

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 17, 2008 at 11:20 AM

    Aswini,

    just use SDN search option by giving BDC table control you will get hell lot of answer.

    Amit.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 17, 2008 at 11:22 AM

    Check the link for handling bdc table control

    http://www.sap-basis-abap.com/abap/handling-table-control-in-bdc.htm

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 17, 2008 at 11:24 AM

    Hello,

    Following is a sample code of handling table control in BDC.

    REPORT Y730_BDC5 .

    *HANDLING TABLE CONTROL IN BDC

    DATA : BEGIN OF IT_DUMMY OCCURS 0,

    DUMMY(100) TYPE C,

    END OF IT_DUMMY.

    DATA : BEGIN OF IT_XK01 OCCURS 0,

    LIFNR(10) TYPE C,

    BUKRS(4) TYPE C,

    EKORG(4) TYPE C,

    KTOKK(4) TYPE C,

    NAME1(30) TYPE C,

    SORTL(10) TYPE C,

    LAND1(3) TYPE C,

    SPRAS(2) TYPE C,

    AKONT(6) TYPE C,

    FDGRV(2) TYPE C,

    WAERS(3) TYPE C,

    END OF IT_XK01,

    BEGIN OF IT_BANK OCCURS 0,

    BANKS(3) TYPE C,

    BANKL(10) TYPE C,

    BANKN(10) TYPE C,

    KOINH(30) TYPE C,

    LIFNR(10) TYPE C,

    END OF IT_BANK.

    DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,

    IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

    CALL FUNCTION 'WS_UPLOAD'

    EXPORTING

    FILENAME = 'C:\VENDOR.TXT'

    FILETYPE = 'ASC'

    TABLES

    DATA_TAB = IT_DUMMY.

    LOOP AT IT_DUMMY.

    IF IT_DUMMY-DUMMY+0(2) = '11'.

    IT_XK01-LIFNR = IT_DUMMY-DUMMY+2(10).

    IT_XK01-BUKRS = IT_DUMMY-DUMMY+12(4).

    IT_XK01-EKORG = IT_DUMMY-DUMMY+16(4).

    IT_XK01-KTOKK = IT_DUMMY-DUMMY+20(4).

    IT_XK01-NAME1 = IT_DUMMY-DUMMY+24(30).

    IT_XK01-SORTL = IT_DUMMY-DUMMY+54(10).

    IT_XK01-LAND1 = IT_DUMMY-DUMMY+64(3).

    IT_XK01-SPRAS = IT_DUMMY-DUMMY+67(2).

    IT_XK01-AKONT = IT_DUMMY-DUMMY+69(6).

    IT_XK01-FDGRV = IT_DUMMY-DUMMY+75(2).

    IT_XK01-WAERS = IT_DUMMY-DUMMY+77(3).

    APPEND IT_XK01.

    ELSE.

    IT_BANK-BANKS = IT_DUMMY-DUMMY+2(3).

    IT_BANK-BANKL = IT_DUMMY-DUMMY+5(10).

    IT_BANK-BANKN = IT_DUMMY-DUMMY+15(10).

    IT_BANK-KOINH = IT_DUMMY-DUMMY+25(30).

    IT_BANK-LIFNR = IT_DUMMY-DUMMY+55(10).

    APPEND IT_BANK.

    ENDIF.

    ENDLOOP.

    LOOP AT IT_XK01.

    REFRESH IT_BDCDATA.

    perform bdc_dynpro using 'SAPMF02K' '0100'.

    perform bdc_field using 'BDC_CURSOR'

    'RF02K-REF_LIFNR'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_field using 'RF02K-LIFNR'

    IT_XK01-LIFNR.

    perform bdc_field using 'RF02K-BUKRS'

    IT_XK01-BUKRS.

    perform bdc_field using 'RF02K-EKORG'

    IT_XK01-EKORG.

    perform bdc_field using 'RF02K-KTOKK'

    IT_XK01-KTOKK.

    perform bdc_dynpro using 'SAPMF02K' '0110'.

    perform bdc_field using 'BDC_CURSOR'

    'LFA1-TELX1'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_field using 'LFA1-NAME1'

    IT_XK01-NAME1.

    perform bdc_field using 'LFA1-SORTL'

    IT_XK01-SORTL.

    perform bdc_field using 'LFA1-LAND1'

    IT_XK01-LAND1.

    perform bdc_field using 'LFA1-SPRAS'

    IT_XK01-SPRAS.

    perform bdc_dynpro using 'SAPMF02K' '0120'.

    perform bdc_field using 'BDC_CURSOR'

    'LFA1-KUNNR'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_dynpro using 'SAPMF02K' '0130'.

    perform bdc_field using 'BDC_CURSOR'

    'LFBK-KOINH(02)'.

    perform bdc_field using 'BDC_OKCODE'

    '=ENTR'.

    DATA : FNAM(20) TYPE C,

    IDX TYPE C.

    MOVE 1 TO IDX.

    LOOP AT IT_BANK WHERE LIFNR = IT_XK01-LIFNR.

    CONCATENATE 'LFBK-BANKS(' IDX ')' INTO FNAM.

    perform bdc_field using FNAM

    IT_BANK-BANKS.

    CONCATENATE 'LFBK-BANKL(' IDX ')' INTO FNAM.

    perform bdc_field using FNAM

    IT_BANK-BANKL.

    CONCATENATE 'LFBK-BANKN(' IDX ')' INTO FNAM.

    perform bdc_field using FNAM

    IT_BANK-BANKN.

    CONCATENATE 'LFBK-KOINH(' IDX ')' INTO FNAM.

    perform bdc_field using FNAM

    IT_BANK-KOINH.

    IDX = IDX + 1.

    ENDLOOP.

    perform bdc_dynpro using 'SAPMF02K' '0130'.

    perform bdc_field using 'BDC_CURSOR'

    'LFBK-BANKS(01)'.

    perform bdc_field using 'BDC_OKCODE'

    '=ENTR'.

    perform bdc_dynpro using 'SAPMF02K' '0210'.

    perform bdc_field using 'BDC_CURSOR'

    'LFB1-FDGRV'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_field using 'LFB1-AKONT'

    IT_XK01-AKONT.

    perform bdc_field using 'LFB1-FDGRV'

    IT_XK01-FDGRV.

    perform bdc_dynpro using 'SAPMF02K' '0215'.

    perform bdc_field using 'BDC_CURSOR'

    'LFB1-ZTERM'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_dynpro using 'SAPMF02K' '0220'.

    perform bdc_field using 'BDC_CURSOR'

    'LFB5-MAHNA'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_dynpro using 'SAPMF02K' '0310'.

    perform bdc_field using 'BDC_CURSOR'

    'LFM1-WAERS'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_field using 'LFM1-WAERS'

    IT_XK01-WAERS.

    perform bdc_dynpro using 'SAPMF02K' '0320'.

    perform bdc_field using 'BDC_CURSOR'

    'WYT3-PARVW(01)'.

    perform bdc_field using 'BDC_OKCODE'

    '=ENTR'.

    perform bdc_dynpro using 'SAPLSPO1' '0300'.

    perform bdc_field using 'BDC_OKCODE'

    '=YES'.

    CALL TRANSACTION 'XK01' USING IT_BDCDATA

    MODE 'A'

    UPDATE 'S'

    MESSAGES INTO IT_BDCMSGCOLL.

    ENDLOOP.

    FORM BDC_DYNPRO USING PROG SCR.

    CLEAR IT_BDCDATA.

    IT_BDCDATA-PROGRAM = PROG.

    IT_BDCDATA-DYNPRO = SCR.

    IT_BDCDATA-DYNBEGIN = 'X'.

    APPEND IT_BDCDATA.

    ENDFORM.

    FORM BDC_FIELD USING FNAM FVAL.

    CLEAR IT_BDCDATA.

    IT_BDCDATA-FNAM = FNAM.

    IT_BDCDATA-FVAL = FVAL.

    APPEND IT_BDCDATA.

    ENDFORM.

    Neeraj

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 05, 2013 at 12:19 PM

    Hi,

    First take BDC recording for required transaction from SHDB then you will find screen field names, screen numbers sequence, According to that pass values to below BDC_DYNPRO and BDC_FIELD forms and append data to BDC table. In my requirement I have done this for VB03 transaction passed values to VB03 transaction from my selection screen.

    *&---------------------------------------------------------------------*
    *& Report  ZS_VB03_TRANSACTION
    *&
    *&---------------------------------------------------------------------*
    *&
    *&
    *&---------------------------------------------------------------------*

    REPORT  ZS_VB03_TRANSACTION.

    TABLES: KOMGG,                        "Dialogkommunikationstab
    T685T,                         "Text zum Konditionsart
    T185F,                         "Folgebildsteurung
    T681,                          "Konditionstabelle
    TMC1T, G000, TPARA.                         "Kurztext zur Konditionstabell
    * Sales Organization                                                   *
    SELECT-OPTIONS S_F001 FOR KOMGG-VKORG.
    *MEMORY ID VKO.
    * Distribution Channel                                                 *
    SELECT-OPTIONS S_F002 FOR KOMGG-VTWEG
    MEMORY ID VTW.
    * Division                                                             *
    SELECT-OPTIONS S_F003 FOR KOMGG-SPART
    MEMORY ID SPA.
    * CustomerHierarchy 01                                                 *
    SELECT-OPTIONS S_F004 FOR KOMGG-HIENR01.
    * Material                                                             *
    SELECT-OPTIONS S_F005 FOR KOMGG-MATNR
    MEMORY ID MAT
    MATCHCODE OBJECT MAT1.
    * Customer                                                             *
    SELECT-OPTIONS S_F006 FOR KOMGG-KUNNR
    MEMORY ID KUN
    MATCHCODE OBJECT DEBI.

    *                       "Selektionsdatum                               *
    SELECTION-SCREEN SKIP 1.
    PARAMETERS SEL_DATE LIKE RV130-DATAM
    DEFAULT SY-DATLO.

    PARAMETERS: r_vb03 TYPE c RADIOBUTTON GROUP rb1 DEFAULT 'X',
    r2 type c RADIOBUTTON GROUP rb1.

    *    *       Batchinputdata of single transaction
    DATA:   BDCDATA LIKE BDCDATA    OCCURS 0 WITH HEADER LINE.
    *       messages of call transaction
    DATA:   MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

    data: lv TYPE i.
    data: s1 type KOMGG-VKORG,
    s2 type KOMGG-VKORG.
    START-OF-SELECTION.

    if r_vb03 = 'X'.

    data: num(2) TYPE n VALUE '01',
    lv_string(40) type c,
    lv_s_f001 like s_f001.
    set PARAMETER ID: 'VGK' FIELD 'A001'. "Place ur default value here in A001 place.



    If S_f001-high is INITIAL.
    perform bdc_field       using 'BDC_CURSOR'
    'F001-LOW'.
    perform bdc_field       using 'BDC_OKCODE'
    '=%003'.


    perform bdc_dynpro      using 'SAPLALDB' '3000'.

    perform bdc_field       using 'BDC_OKCODE'
    '=ACPT'.

    perform bdc_field       using 'BDC_CURSOR'
    'RSCSEL-SLOW_I(01)'.
    loop at S_f001 into lv_s_f001.
    CONCATENATE 'RSCSEL-SLOW_I(' num ')' INTO lv_string.
    perform bdc_field       using 'BDC_CURSOR'
    lv_string.
    perform bdc_field       using lv_string
    lv_s_f001-low.
    clear: lv_s_f001, lv_string.
    num = num + 1.
    ENDLOOP.
    clear num.
    perform bdc_dynpro      using 'RV13GAAB' '1000'.
    perform bdc_field       using 'BDC_CURSOR'
    'F002-LOW'.
    ELSE.
    perform bdc_dynpro      using 'RV13GAAB' '1000'.
    perform bdc_field       using 'BDC_CURSOR'
    'F001-LOW'.
    perform bdc_field       using 'F001-LOW' S_f001-low.

    perform bdc_field       using 'F001-HIGH' S_f001-high.
    endif.

    perform bdc_field       using 'F002-LOW' S_F002-low.
    perform bdc_field       using 'F002-HIGH' S_F002-High.
    perform bdc_field       using 'F004-high' S_F004-high.
    perform bdc_field       using 'F005-LOW' S_F005-low.
    perform bdc_field       using 'F003-LOW' S_F003-low.
    perform bdc_field       using 'F003-High' S_F003-high.
    perform bdc_field       using 'F004-LOW' S_F004-low.

    perform bdc_field       using 'F005-high' S_F005-high.
    perform bdc_field       using 'F006-LOW' S_F006-low.
    perform bdc_field       using 'F006-high' S_F006-high.

    call TRANSACTION 'VB03' USING BDCDATA MODE 'E' MESSAGES INTO MESSTAB.
    ENDIF.
    *----------------------------------------------------------------------*
    *        Start new screen                                              *
    *----------------------------------------------------------------------*
    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.

    CLEAR BDCDATA.
    BDCDATA-FNAM = FNAM.
    BDCDATA-FVAL = FVAL.
    APPEND BDCDATA.

    ENDFORM.

    Add comment
    10|10000 characters needed characters exceeded