Bdc in table control

hi friends,
can any body plz send me one example in table contols in bdc.STEP BY STEP.
thanks & regards
ram

hi,
Here is the code.
report zmm_update_contracts_cpy no standard page heading
                                line-count 45
                                line-size  115
                                message-id zmm.
*                  Types Declarations                                 
types: begin of ty_ekko,
        ebeln type ekko-ebeln,
        bukrs type ekko-bukrs,
        kdate type ekko-kdate,
        kdatb type ekko-kdatb,
       end of   ty_ekko,
*-- Structure for success and failed records
       begin of ty_status,
        bukrs type ekko-bukrs,
        ebeln type ekko-ebeln,
        kdate type ekko-kdate,
        kdatb type ekko-kdatb,
       end   of ty_status.
*                  Internal Table Declarations                         *
data : it_ekko    type standard table of ty_ekko    with header line,
       it_ekpo    type standard table of ekpo       with header line,
       it_success type standard table of ty_status  with header line,
       it_fail    type standard table of ty_status  with header line,
       bdcdata    type standard table of bdcdata    with header line,
       msgtab     type standard table of bdcmsgcoll with header line.
*                  Structure  Declarations                             *
*-- Structure for Parameter string for runtime of CALL TRANSACTION
data : x_ctu_params type ctu_params.
*                  Data Declarations                                   *
data : v_bukrs      type ekko-bukrs, "Company code
       v_ebeln      type ekko-ebeln, "Contract no
       v_ekorg      type ekko-ekorg, "Purchasing Org
       v_bsart      type ekko-bsart, "Document Type
       v_kdatb      type ekko-kdatb,
       v_counter(2) type n ,"value '01',
       v_first(5)   type n,
       v_field      type string.
*                        Selection Screen                              *
*-- Selection screen Details
selection-screen begin of block b1 with frame title text-001.
select-options :
   s_bukrs for v_bukrs obligatory default '0111', "Company code
   s_ebeln for v_ebeln obligatory,                "Contract no
   s_ekorg for v_ekorg,
   s_bsart for v_bsart,
   s_dats  for v_kdatb.
selection-screen end of block b1.
*               Start-of-Selection                                     *
start-of-selection.
*-- Get data from DB table ekko based on selection-screen
  perform fetch_data.
*-- for each record found process BDC
  perform process_bdc.
  perform init_page_head.
*               End-of-Selection                                     *
end-of-selection.
*-- Display report
  perform display_report.
*                      Top-of-page
top-of-page.
*--  Subroutine to print header on top of the page
  perform print_header.
  skip.
  uline.
*&      Form  fetch_data
*       text
form fetch_data.
  select ebeln bukrs kdate kdatb
    from ekko
    into table it_ekko
    where ebeln in s_ebeln
      and bukrs in s_bukrs
      and bstyp = 'K'
      and bsart in s_bsart
      and ekorg in s_ekorg
      and kdatb in s_dats
      and kdate in s_dats.
  if sy-subrc <> 0.
    exit.
  else.
    select * from ekpo
      into table it_ekpo
      for all entries in it_ekko
      where ebeln = it_ekko-ebeln
        and bukrs = it_ekko-bukrs.
*        and loekz = ''.
  endif.
endform.                    " fetch_data
*&      Form  process_bdc
*       text
form process_bdc.
  sort it_ekko by ebeln.
  sort it_ekpo by ebeln ebelp.
  loop at it_ekko.
    clear   : bdcdata.
*              v_counter.
    refresh : bdcdata.
    perform fill_bdctable.
  endloop.
endform.                    " process_bdc
*        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.
  if fval <> ' '.
    clear bdcdata.
    bdcdata-fnam = fnam.
    bdcdata-fval = fval.
    append bdcdata.
  endif.
endform.
*&      Form  fill_bdctable
*       text
form fill_bdctable.
* To have default screen size, mode and update
  x_ctu_params-defsize = 'X'.
  x_ctu_params-dismode = 'E'.
  x_ctu_params-updmode = 'S'.
  v_first = 1.
  shift v_first left DELETING leading '0'.
  perform bdc_dynpro      using 'SAPMM06E' '0205'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RM06E-EVRTN'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_field       using 'RM06E-EVRTN'
                                it_ekko-ebeln.
*reading item data table based on header data table
  loop at it_ekpo where ebeln = it_ekko-ebeln.
    clear v_field.
    v_counter = v_counter + 1.
*Page Down
    if v_counter = '15' .
      v_counter = '01'.
      concatenate 'RM06E-EVRTP('
                  v_counter
                  into v_field.
      perform bdc_dynpro      using 'SAPMM06E' '0220'.
      perform bdc_field       using 'BDC_CURSOR'
                                     v_field.
      perform bdc_field       using 'BDC_OKCODE'
                                    '=P+'.
      perform bdc_field       using 'RM06E-EBELP'
                                     v_first.
      v_first = v_first + 14.
*Compare first entry in table control with line item
*As there are some missing line items in Purchasing Document Item table
      IF V_FIRST <> IT_EKPO-EBELP.
        V_FIRST = IT_EKPO-EBELP.
      ENDIF.
    endif.
* Check for deletion indicator
    if it_ekpo-loekz is initial.
      concatenate 'RM06E-EVRTP('
                  v_counter
                  into v_field.
      perform bdc_dynpro      using 'SAPMM06E' '0220'.
      perform bdc_field       using 'BDC_CURSOR'
                                     v_field.
      perform bdc_field       using 'BDC_OKCODE'
                                    '=DETZ'.
      perform bdc_field       using 'RM06E-EBELP'
                                     v_first."it_ekpo-ebelp.
      clear v_field.
      concatenate 'RM06E-TCSELFLAG('
                  v_counter
                  into v_field.
      perform bdc_field       using v_field
                                    'X'.
      perform bdc_dynpro      using 'SAPMM06E' '0212'.
      perform bdc_field       using 'BDC_CURSOR'
                                    'EKPO-BRGEW'.
      perform bdc_field       using 'BDC_OKCODE'
                                    '=BACK'.
      perform bdc_field       using 'EKPO-NTGEW'    "netweight
                                    '0'.
      perform bdc_field       using 'EKPO-GEWEI'    "unit
                                    'LB'.
      perform bdc_field       using 'EKPO-BRGEW'    "gross weight
                                    '0'.
    endif.
  endloop.
  perform bdc_dynpro      using 'SAPMM06E' '0220'.
  concatenate 'RM06E-EVRTP('
              v_field
              into v_field.
  perform bdc_field       using 'BDC_CURSOR'
                                v_field.
  perform bdc_field       using 'BDC_OKCODE'
                                '=BU'.
  perform bdc_dynpro      using 'SAPLSPO1' '0300'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=YES'.
*  PERFORM BDC_FIELD       USING 'RM06E-EBELP'
*                                '10'.
  call transaction 'ME32K' using bdcdata
                      options from x_ctu_params
                        messages into msgtab.
  clear v_counter.
  if sy-subrc = 0.
*-- populate the success records
    clear it_success.
    it_success-ebeln = it_ekko-ebeln.
    it_success-bukrs = it_ekko-bukrs.
    it_success-kdate = it_ekko-kdate.
    it_success-kdatb = it_ekko-kdatb.
    append it_success.
  else.
*-- populate the error records
    clear it_fail.
    it_fail-ebeln = it_ekko-ebeln.
    it_fail-bukrs = it_ekko-bukrs.
    it_fail-kdate = it_ekko-kdate.
    it_fail-kdatb = it_ekko-kdatb.
    append it_fail.
  endif.
endform.                    " fill_bdctable
*&      Form  display_report
*       text
form display_report.
  data : lv_success type i,
         lv_failure type i,
         lv_lines   type i.
  clear : lv_success,
          lv_failure,
          lv_lines.
  describe table it_success lines lv_success.
  describe table it_fail    lines lv_failure.
  lv_lines = lv_failure + lv_success.
  write : / 'Total no of records uploaded :'(002) .
  write : lv_lines.
  write : / 'Total no of successes        :'(003).
  write : lv_success.
  write : / 'Total no of errors           :'(004).
  write : lv_failure.
  if not it_success[] is initial.
    sort it_success by bukrs.
    skip 2.
    write : / 'Success Records'(005).
    loop at it_success.
      at new bukrs.
        write : /    'Company Code '(006) , it_success-bukrs.
        write : /1   'Contract'(007),
                 13  'Validity Dates'(008).
      endat.
      write : /1  it_success-ebeln,
               13 it_success-kdatb,
               26 it_success-kdate.
    endloop.
  endif.
  if not it_fail[] is initial.
    sort it_fail by bukrs.
    skip 2.
    write : / 'Error Records'(009).
    loop at it_fail.
      at new bukrs.
        write : /    'Company Code '(006) , it_fail-bukrs.
        write : /1   'Contract'(007),
                 13  'Validity Dates'(008).
      endat.
      write : /1  it_fail-ebeln,
               13 it_fail-kdatb,
               26 it_fail-kdate.
    endloop.
  endif.
endform.                    " display_report
Regards,
Richa

Similar Messages

  • How to create bdc with table control

    hi all.
    please some body tell me how to create bdc with table control
    or suggest any www with screen shots
    thanks in advance ,
    aparna

    Hi AParna,
    Its very Simple.
    ALl you have to do is set up a counter based on the number of lines in the tabke. when the counter reaches the number of lines in the table hit the next page button which is at the top of every screen in SAP.
    Please refer to the following BDC program I had developed using Table control,
    this is for ME01 transaction.
      LOOP AT T_EORD_HED.
        SELECT SINGLE * FROM MARA WHERE MATNR = T_EORD_HED-MATNR.
        IF SY-SUBRC = 0.
          PERFORM BDC_DYNPRO      USING 'SAPLMEOR' '0200'.
          PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                        'EORD-MATNR'.
          PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                        '/00'.
          PERFORM BDC_FIELD       USING 'EORD-MATNR'
                                        T_EORD_HED-MATNR.       "'58335'.
          PERFORM BDC_FIELD       USING 'EORD-WERKS'
                                        T_EORD_HED-WERKS.       "'0253'.
          L_COUNT = 1.
          LOOP AT T_EORD WHERE MATNR = T_EORD_HED-MATNR
                           AND WERKS = T_EORD_HED-WERKS.
            SELECT SINGLE * FROM LFA1 WHERE LIFNR = T_EORD-LIFNR.
            IF SY-SUBRC = 0.
    * Look into the if condition below
              IF L_COUNT = 010.
                L_COUNT = 1.
                PERFORM BDC_DYNPRO      USING 'SAPLMEOR' '0205'.
                PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'EORD-MATNR'.
                PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                       '=NS'.
                L_COUNT = L_COUNT + 1.
              ENDIF.
              PERFORM BDC_DYNPRO      USING 'SAPLMEOR' '0205'.
              PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                            'EORD-AUTET(01)'.
              PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                            '/00'.
              CONCATENATE 'EORD-VDATU' '(' L_COUNT ')' INTO OPR_FIELD.
              WRITE SY-DATUM TO T_EORD-VDATU.
              PERFORM BDC_FIELD       USING OPR_FIELD
                                            T_EORD-VDATU.
              CONCATENATE 'EORD-BDATU' '(' L_COUNT ')' INTO OPR_FIELD.
              WRITE T_EORD-BDATU TO V_BDATU.
              PERFORM BDC_FIELD       USING OPR_FIELD
                                            V_BDATU.
              CONCATENATE 'EORD-LIFNR' '(' L_COUNT ')' INTO OPR_FIELD.
              PERFORM BDC_FIELD       USING OPR_FIELD
                                            T_EORD-LIFNR.
              CONCATENATE 'EORD-EKORG' '(' L_COUNT ')' INTO OPR_FIELD.
              PERFORM BDC_FIELD       USING OPR_FIELD
                                            '0001'.
              CONCATENATE 'EORD-RESWK' '(' L_COUNT ')' INTO OPR_FIELD.
              PERFORM BDC_FIELD       USING OPR_FIELD
                                            T_EORD-RESWK.
              WRITE T_EORD-MEINS TO V_MEINS.
              CONCATENATE 'EORD-MEINS' '(' L_COUNT ')' INTO OPR_FIELD.
              PERFORM BDC_FIELD       USING OPR_FIELD
                                            V_MEINS.
    *          CONCATENATE 'EORD-EBELN' '(' L_COUNT ')' INTO OPR_FIELD.
    *          PERFORM BDC_FIELD       USING 'OPR_FIELD'
    *                                        T_EORD-EBELN.
              CONCATENATE 'EORD-EBELP' '(' L_COUNT ')' INTO OPR_FIELD.
              PERFORM BDC_FIELD       USING OPR_FIELD
                                            T_EORD-EBELP.
              IF T_EORD-FLIFN NE SPACE OR T_EORD-FRESW NE SPACE OR
                 T_EORD-FEBEL NE SPACE.
                CONCATENATE 'RM06W-FESKZ' '(' L_COUNT ')' INTO OPR1_FIELD.
                PERFORM BDC_FIELD       USING OPR1_FIELD
                                              'X'.
              ENDIF.
              IF T_EORD-NOTKZ <> ''.
                CONCATENATE 'EORD-NOTKZ' '(' L_COUNT ')' INTO OPR_FIELD.
                PERFORM BDC_FIELD       USING OPR_FIELD
                                              'X'.
              ENDIF.
              CONCATENATE 'EORD-AUTET' '(' L_COUNT ')' INTO OPR_FIELD.
              PERFORM BDC_FIELD       USING OPR_FIELD
                                            T_EORD-AUTET.
              L_COUNT = L_COUNT + 1.
            ENDIF.
          ENDLOOP.
          PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                        'EORD-MATNR'.
          PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                        '=BU'.
          CALL TRANSACTION 'ME01' USING I_BDCDATA
                        MODE UP_MODE
    *                     optIONS  FROM l_opt
                        MESSAGES INTO I_BDCMSGCOLL.
          PERFORM FORMAT_OUTPUT.
        ENDIF.
      ENDLOOP.

  • How to give line items in flatfile while doing BDC for Table control

    Hi all,
    I am writing BDC for Multiple line items and Transaction  is : FSE5N.
    How do i give the data in the flat file. I mean how do we give the multiple line items in flat file , i.e for second line item again we have to header data or not ?
    ex:
    1015;ALL;demo;kr;INR;01;0001;3000172;100
    1015;ALL;demo;kr;INR;01;0001;3000172;200
    for first lineitem  : 3000172;100
    for 2nd line item : 3000172; 200.
    header data : 1015;ALL;demo;kr;INR;01;0001.
    Thanks in advance
    krupali

    Hii ,
    u can give in the same format as u have done in the example.
    A       B    C     D  E    F   G        H          I
    1015;ALL;demo;kr;INR;01;0001;3000172;100
    1015;ALL;demo;kr;INR;01;0001;3000172;200
    and while writing the loop u can give
    loop at it_head.
    loop at it_head where a = it_head-A and b = it_head-B ..........upto G = it_head-G.
      endloop.
    endloop.
    check this
    http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
    Neeraj

  • Problem in bdc for table control for line items

    Hi experts,
    I am runnig a bdc for ME52.
    i am just entering PR number, in the second screen i have got all the line items. I need to select these line item 10 and double click or hit enter, it takes me to screen 3, there im just checking a checkbox and saving.
    Again i need to select the line item 20 and double click or hit enter. again the same process.
    Again repeat for all the line items.
    But my problem is it is updating everytime for only line item  10. for line item 20 and others it say "no chnge in the data".
    I am pasting my code here. please check and revert me back .plz.
    DATA: w_output LIKE LINE OF i_output.
      REFRESH I_ITAB[].
      SELECT * FROM EBAN
               INTO TABLE i_itab
               WHERE banfn in s_banfn AND
                     bsart in s_bsart AND
                     bstyp in s_bstyp AND
                     matnr in s_matnr AND
                     werks in s_werks AND
                     lfdat in s_lfdat AND
                     pstyp in s_pstyp AND
                     knttp in s_knttp AND
                     estkz in s_estkz AND
                     loekz eq ' '.
      IF sy-subrc = 0.
        CLEAR: w_itab,
                 i_poitab[].
        SORT i_itab by banfn.
        LOOP AT i_itab INTO w_itab where menge GT eban-bsmng.
          IF p_close = 'X' AND p_rep = 'X'.
            IF w_itab-ebakz = 'X'.
              w_itab-ebakz = ' '.
              APPEND w_itab to i_poitab.
            ENDIF.
          ELSEIF p_open = 'X' AND p_rep = 'X'.
            IF w_itab-ebakz = ' '.
              w_itab-ebakz = 'X'.
              APPEND w_itab to i_poitab.
            ENDIF.
          ELSEIF p_close = 'X' AND p_repw = 'X'.
            IF w_itab-ebakz = ' '.
              APPEND w_itab to i_poitab.
            ENDIF.
          ELSEIF p_open = 'X' AND p_repw = 'X'.
            IF w_itab-ebakz = 'X'.
              APPEND w_itab to i_poitab.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDIF.
      LOOP AT i_poitab into w_output.
        APPEND w_output to i_output.
       PERFORM CALL_BDC.
      endloop.
    IF p_rep = 'X'.
    PERFORM CALL_BDC.
    ENDIF.
    ENDFORM.                    " GET_DATA
    *&      Form  CALL_BDC
          text
    -->  p1        text
    <--  p2        text
    FORM CALL_BDC.
    DATA: seltab(5) TYPE N,
          seltab1(2) TYPE N,
          tempvar(30) TYPE N,
          cnt TYPE N.
    LOOP AT i_output.
    clear: seltab,
           seltab1.
    seltab = i_output-bnfpo.
    seltab1 = seltab+2(2).
    perform bdc_dynpro      using 'SAPMM06B' '0105'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'EBAN-BANFN'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'EBAN-BANFN'
                                  i_output-banfn.
    perform bdc_dynpro      using 'SAPMM06B' '0106'.
    clear tempvar.
    *cnt = 1.
    concatenate 'EBAN-BNFPO(' seltab1 ')' into tempvar.
    perform bdc_field       using 'BDC_CURSOR'
                                 'EBAN-BNFPO(seltab1)'.
                                    tempvar.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=DETA'.
    perform bdc_field       using 'RM06B-BNFPO'
                                  i_output-bnfpo.
    perform bdc_field       using 'RM06B-TCSELFLAG(seltab1)'
                                 'X'.
    perform bdc_dynpro      using 'SAPMM06B' '0102'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'EBAN-EBAKZ'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BU'.
    perform bdc_field       using 'EBAN-EBAKZ'
                                  i_output-ebakz.
    CALL TRANSACTION 'ME52' USING bdc_data MODE 'A'
                                   MESSAGES INTO i_bdcmsg.
        COMMIT WORK AND WAIT.
    ENDLOOP.
    ENDFORM.                    " CALL_BDC
    *&      Form  bdc_dynpro
          text
         -->P_0686   text
         -->P_0687   text
    FORM bdc_dynpro USING    program dynpro.
    CLEAR bdc_data.
      bdc_data-program  = program.
      bdc_data-dynpro   = dynpro.
      bdc_data-dynbegin = 'X'.
      APPEND bdc_data.
      CLEAR bdc_data.
    ENDFORM.   
    thanks,
    N

    Looks like table control logic is wrong -- do compare with below program...
    only table contril area
    REPORT ZPadmam
    NO STANDARD PAGE HEADING LINE-SIZE 255.
    DATA : BEGIN OF itab OCCURS 0,
    i1 TYPE i,
    lifnr LIKE rf02k-lifnr,
    bukrs LIKE rf02k-bukrs,
    ekorg LIKE rf02k-ekorg,
    ktokk LIKE rf02k-ktokk,
    anred LIKE lfa1-anred,
    name1 LIKE lfa1-name1,
    sortl LIKE lfa1-sortl,
    land1 LIKE lfa1-land1,
    akont LIKE lfb1-akont,
    fdgrv LIKE lfb1-fdgrv,
    waers LIKE lfm1-waers,
    END OF itab.
    DATA : BEGIN OF jtab OCCURS 0,
    j1 TYPE i,
    banks LIKE lfbk-banks,
    bankl LIKE lfbk-bankl,
    bankn LIKE lfbk-bankn,
    END OF jtab.
    DATA : cnt(4) TYPE n.
    DATA : fdt(20) TYPE c.
    DATA : c TYPE i.
    INCLUDE bdcrecx1.
    START-OF-SELECTION.
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
    filename = 'C:\first1.txt'
    filetype = 'DAT'
    TABLES
    data_tab = itab.
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
    filename = 'C:\second.txt'
    filetype = 'DAT'
    TABLES
    data_tab = jtab.
    LOOP AT itab.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0100'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'RF02K-KTOKK'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '/00'.
    PERFORM bdc_field USING 'RF02K-LIFNR'
    itab-lifnr.
    PERFORM bdc_field USING 'RF02K-BUKRS'
    itab-bukrs.
    PERFORM bdc_field USING 'RF02K-EKORG'
    itab-ekorg.
    PERFORM bdc_field USING 'RF02K-KTOKK'
    itab-ktokk.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFA1-LAND1'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '/00'.
    PERFORM bdc_field USING 'LFA1-ANRED'
    itab-anred.
    PERFORM bdc_field USING 'LFA1-NAME1'
    itab-name1.
    PERFORM bdc_field USING 'LFA1-SORTL'
    itab-sortl.
    PERFORM bdc_field USING 'LFA1-LAND1'
    itab-land1.
    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-BANKN(01)'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=ENTR'.
    cnt = 0.
    LOOP AT jtab WHERE j1 = itab-i1.
    cnt = cnt + 1.
    CONCATENATE 'LFBK-BANKS(' cnt ')' INTO fdt.
    PERFORM bdc_field USING fdt jtab-banks.
    CONCATENATE 'LFBK-BANKL(' cnt ')' INTO fdt.
    PERFORM bdc_field USING fdt jtab-bankl.
    CONCATENATE 'LFBK-BANKN(' cnt ')' INTO fdt.
    PERFORM bdc_field USING fdt jtab-bankn.
    IF cnt = 5.
    cnt = 0.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFBK-BANKS(01)'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=P+'.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFBK-BANKN(02)'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=ENTR'.
    ENDIF.
    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'
    itab-akont.
    PERFORM bdc_field USING 'LFB1-FDGRV'
    itab-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'
    itab-waers.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0320'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'RF02K-LIFNR'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=ENTR'.
    PERFORM bdc_dynpro USING 'SAPLSPO1' '0300'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=YES'.
    PERFORM bdc_transaction USING 'XK01'.
    ENDLOOP.
    PERFORM close_group.
    Thanks
    Seshu

  • Field is not populating in BDC from Table Control value????

    Hi Experts,
    After adding a new Quantity (MY_QUANTITY) field to the existing Table control, I populated the data from SAP into it.
    Now, the user will change (if he wants) its value, then he clicks the Push Button by expecting the posting of the Document i.e.in other words. the Control encounters the statement of MY_FORM_CREATE_ABAVN_VIA_BDC in my Prog.
    But, MY_QUANTITY (changed, even not changed too) value/s is not passing in to my BDC_DATA table/code?
    I am doing BDC for ABAVN transaction and wanting the Quantity filed of ''Partial Retirement'' tab to b populated in BDC. So, I am using as,
    SAPLAMDP--Screen 100--Field as ANLA-MENGE (its a Subscreen/Tabs of SAP Screen)
    So,
    1) Problem is with my BDC code?
    2) or, ''SAPLAMDP--Screen 100--Field as ANLA-MENGE'' is this wrong?
    3) or else any other?
    Message was edited by:
            Sridhar
    Message was edited by:
            Sridhar
    Message was edited by:
            Sridhar

    Hai sridhar,
    The problem is within the BDC  Code.
    Because For the effect of adding the field there is no correspong change in bdc is done.So record one more time use the latest one(After adding the field)
    Hope this helps you.
    Regds,
    Rama.Pammi

  • Bulk GR posting through BDC from table control - Multiple GRs posted

    Hi all,
    I have a GR interface which is actually a module pool screen containing a table control.Where i give the users an option to select multiple rows and click on a button called 'POST' and i use the contents of the ITAB connected to the table control to fire a BDC on 'POST'' s click.i use a field gate entry no as the primary key and controller of operations in my app.
    Now, The issue i am facing is that once in 500 entries that the user posts. there is a case of multiple GR's being posted in the system.cud not trace it why is it happening.
    Can any one help me out on this.
    Eagerly Waiting,
    Sachin Soni

    any one.please let me knw if i am unclear anywhr

  • More than 1 line items in bdc using table controls for BOM

    Hi....
    how do u update more than one line item for BOM using BDC table control.......
    is there any specific command for doing that.......
    hav tried d following code bt it takes the flatfile i/p FOR 2 LINE ITEMS as 2 different BOM'S.....
    would appreciate ur help....plz provide code.............
    REPORT zbdc4_cs01
           NO STANDARD PAGE HEADING LINE-SIZE 255.
    INCLUDE bdcrecx1.
    DATA : a TYPE i,
           b type i,
           c type i.
    DATA : BEGIN OF it_rec OCCURS 0,
           rec(200) TYPE c,
           END OF it_rec.
    DATA : BEGIN OF ctab OCCURS 0,
           matnr(18),
           werks(4),
           stlan(1),
           END OF ctab.
    DATA : BEGIN OF xtab OCCURS 0,
           idnrk(18),
           menge(13),
           postp(1),
           END OF xtab.
    DATA : BEGIN OF itab OCCURS 0,
           matnr(18),
           werks(4),
           stlan(1),
           idnrk(18),
           menge(13),
           postp(1),
           END OF itab.
    START-OF-SELECTION.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename            = 'C:/TEST4.TXT'
          filetype            = 'ASC'
          has_field_separator = 'X'
        TABLES
          data_tab            = it_rec.
      LOOP AT  it_rec.
        a = strlen( it_rec-rec ).
        if a = 55.
        itab-matnr = it_rec-rec+0(18).
        itab-werks = it_rec-rec+18(4).
        itab-stlan = it_rec-rec+22(1).
        itab-idnrk = it_rec-rec+23(18).
        itab-menge = it_rec-rec+41(13).
        itab-postp = it_rec-rec+54(1).
        APPEND itab.
        elseif a > 55.
        itab-matnr = it_rec-rec+0(18).
        itab-werks = it_rec-rec+18(4).
        itab-stlan = it_rec-rec+22(1).
        itab-idnrk = it_rec-rec+23(18).
        itab-menge = it_rec-rec+41(13).
        itab-postp = it_rec-rec+54(1).
        APPEND itab.
        itab-idnrk = it_rec-rec+55(18).
        itab-menge = it_rec-rec+73(13).
        itab-postp = it_rec-rec+86(1).
        APPEND itab.
        endif.
      ENDLOOP.
      PERFORM open_group.
      LOOP AT itab.
        PERFORM bdc_dynpro      USING 'SAPLCSDI' '0100'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RC29N-STLAN'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM bdc_field       USING 'RC29N-MATNR'
                                       itab-matnr.           "'3000000107'.
        PERFORM bdc_field       USING 'RC29N-WERKS'
                                       itab-werks.              "'UN02'.
        PERFORM bdc_field       USING 'RC29N-STLAN'
                                       itab-stlan.              "'1'.
        PERFORM bdc_field       USING 'RC29N-STLAL'
        PERFORM bdc_field       USING 'RC29N-DATUV'
                                      '11.08.2008'.
        PERFORM bdc_dynpro      USING 'SAPLCSDI' '0110'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM bdc_field       USING 'RC29K-BMENG'
                                      '1'.
        PERFORM bdc_field       USING 'RC29K-STLST'
                                      '1'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RC29K-EXSTL'.
        PERFORM bdc_dynpro      USING 'SAPLCSDI' '0111'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RC29K-LABOR'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM bdc_dynpro      USING 'SAPLCSDI' '0140'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RC29P-POSTP(01)'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM bdc_field       USING 'RC29P-IDNRK(01)'
                                       itab-idnrk.             "'1000000232'.
        PERFORM bdc_field       USING 'RC29P-MENGE(01)'
                                       itab-menge.              "'100'.
        PERFORM bdc_field       USING 'RC29P-POSTP(01)'
                                       itab-postp.             "'L'.
        PERFORM bdc_dynpro      USING 'SAPLCSDI' '0130'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RC29P-POSNR'.
        PERFORM bdc_field       USING 'RC29P-POSNR'
                                      '0010'.
        PERFORM bdc_field       USING 'RC29P-IDNRK'
                                      '1000000232'.
        PERFORM bdc_field       USING 'RC29P-MENGE'
                                      '100'.
        PERFORM bdc_field       USING 'RC29P-MEINS'
                                      'KG'.
        PERFORM bdc_dynpro      USING 'SAPLCSDI' '0131'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RC29P-POTX1'.
        PERFORM bdc_field       USING 'RC29P-SANKA'
                                      'X'.
        PERFORM bdc_dynpro      USING 'SAPLCSDI' '0140'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RC29P-POSNR(01)'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM bdc_dynpro      USING 'SAPLCSDI' '0140'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RC29P-POSNR(01)'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=FCBU'.
        PERFORM bdc_transaction USING 'CS01'.
      ENDLOOP.
      PERFORM close_group.

    Hi
    Check this sample code for the Table Control in BDC:
    data: fnam(20) type c.
    move 1 to id.
        loop at TI_STAGING WHERE VENDOR = IT_STAGING-VENDOR AND DOCDATE = IT_STAGING-DOCDATE.
          concatenate 'RM06E-EPSTP(0' id ')' into fnam.
          perform bdc_field       using fnam TI_STAGING-itmcategory.
          concatenate 'EKPO-KNTTP(0' id ')' into fnam.
          perform bdc_field       using fnam TI_STAGING-accassignment.
          concatenate 'EKPO-EMATN(0' id ')' into fnam.
          perform bdc_field       using fnam TI_STAGING-material.
          concatenate 'EKPO-TXZ01(0' id ')' into fnam.
          perform bdc_field       using fnam TI_STAGING-shortxt.
          quan = ti_staging-poqty.
          concatenate 'EKPO-MENGE(0' id ')' into fnam.
          perform bdc_field       using fnam quan.
          concatenate 'RM06E-EEIND(0' id ')' into fnam.
          perform bdc_field       using fnam TI_STAGING-deliverydate.
          netpr = ti_staging-netpr.
          concatenate 'EKPO-NETPR(0' id ')' into fnam.
          perform bdc_field       using fnam netpr.
          concatenate 'EKPO-MATKL(0' id ')' into fnam.
          perform bdc_field       using fnam TI_STAGING-mategroup.
          concatenate 'EKPO-WERKS(0' id ')' into fnam.
          perform bdc_field       using fnam TI_STAGING-plant.
          ID = ID + 1.
        ENDLOOP.
    Regards,
    Vishwa.

  • BDC in table control of  MM02

    Hi
    I have problem while inserting values in UNIT of measure in MM02 transaction. I recorded transaction for second field of table control , but while running BDC it inserts value in 2nd row only. How to increase counter while inserting values.
    Plz do needful.

    hi,
    *& Report  ZMMGB_MM02PLANPRICE_BDC
    report  zmmgb_mm02planprice_bdc.
    tables : marc.
    data: begin of bdcdata occurs 0.
            include structure bdcdata.
    data: end of bdcdata.
    data: w_tcode     like sy-tcode,      " Transaction code
          w_tkstatus  like t130m-pstat,   " SAP Transaction status
          w_anzgstatus like t130m-pstat,   " Summary Display status
          w_t130m     like t130m,         " Transaction control: mat.master
          w_bilds     like t133a-bilds,   " Screen sequence
          w_dytxt     like t133b-dytxt,   " View description
          w_linex(5)  type c,             " View # in table
          w_line      like sy-tabix,      " View # on selection screen
          w_num       like sy-tabix,
          w_matnr     like mara-matnr,    " Material
          w_mtart     like mara-mtart,    " Material type
          w_vpsta     like mara-vpsta,    " Material maintenance status
          w_pstat     like t134-pstat.    " Material type maintenance status
    data: begin of it_views occurs 30.
            include structure mbildtab.   " Selection Views
    data: end of it_views.
    data : mbrsh(1) type c,
           mtart(4) type c,
           kzsel(20) type c,
           price(14) type c,
           pdate(10) type c,
           dytxt(20) type c,
           pos(2) type n.
    data : begin of itab occurs 0,
              matnr like mara-matnr,     "Material
              werks like t001w-werks,    "Plant
              zplp1 like mbew-zplp1,    "Planned Price1
              zpld1 like mbew-zpld1,    "Planned Price1 Date
           end of itab.
    parameters : upd as checkbox.
    start-of-selection.
      check upd eq 'X'.
      perform upload_data.
      loop at itab.
        refresh bdcdata.
        perform get_viewpos.
    w_linex = w_linex - 17 .
    pos = w_linex+2(2).
        concatenate 'MSICHTAUSW-KZSEL('  pos ')' into kzsel.
    concatenate 'MSICHTAUSW-DYTXT('  pos ')' into dytxt.
      perform bdc_dynpro      using 'SAPLMGMM' '0060'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RMMG1-MATNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RMMG1-MATNR'
                                  itab-matnr .            "'93110989'.
    perform bdc_dynpro      using 'SAPLMGMM' '0070'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MSICHTAUSW-DYTXT(08)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=P+'.
    perform bdc_dynpro      using 'SAPLMGMM' '0070'.
    perform bdc_field       using 'BDC_CURSOR'
                                  dytxt.                  "'MSICHTAUSW-DYTXT(05)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_field       using kzsel                   "'MSICHTAUSW-KZSEL(05)'
                                  'X'.
    perform bdc_dynpro      using 'SAPLMGMM' '0080'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RMMG1-WERKS'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_field       using 'RMMG1-WERKS'
                                  itab-werks.                   "'7100'.
    perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    move itab-zplp1 to price.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MBEW-ZPLP1'.
    perform bdc_field       using 'MBEW-ZPLP1'
                                  price.              "'103.00'.
    PERFORM convert_date_external.
    perform bdc_field       using 'MBEW-ZPLD1'
                                  pdate.              "'27.03.2008'.
    perform bdc_dynpro      using 'SAPLSPO1' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=YES'.
        call transaction 'MM02' using bdcdata mode 'A' update 'S'.
        clear : itab,price,pdate,pos,w_linex.
      endloop.
    *        Start new screen                                              *
    form bdc_dynpro using program dynpro.
      clear bdcdata.
      bdcdata-program  = program.
      bdcdata-dynpro   = dynpro.
      bdcdata-dynbegin = 'X'.
      append bdcdata.
    endform.                    "BDC_DYNPRO
    *        Insert field                                                  *
    form bdc_field using fnam fval.
      clear bdcdata.
      bdcdata-fnam = fnam.
      bdcdata-fval = fval.
      append bdcdata.
    endform.                    "BDC_FIELD
    *&      Form  GET_VIEWPOS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form get_viewpos .
      if itab-matnr na sy-abcde.
        unpack itab-matnr to itab-matnr.
      endif.
      select single * from marc where matnr = itab-matnr and
                                       werks = itab-werks.
      if sy-subrc eq 0.
        w_tcode = 'MM02'.           "Change view
      endif.
      call function 'MATERIAL_INIT'
        exporting
          tcode                     = w_tcode
          kz_berprf                 = 'X'
        importing
          it130m                    = w_t130m
          tkstatus                  = w_tkstatus
        exceptions
          no_authority              = 1
          wrong_call                = 2
          kstatus_empty             = 3
          tkstatus_empty            = 4
          aktyp_tcode_mismatch      = 5
          tcode_not_found           = 6
          material_article_mismatch = 7
          others                    = 8.
      if sy-subrc <> 0.
        write: 'MATERIAL_INIT error code =', sy-subrc.
        exit.
      endif.
    * 2. Get Material type and maintenance statuses
      select single matnr mtart vpsta from mara
             into (w_matnr, w_mtart, w_vpsta)
             where matnr = itab-matnr.
    *  if sy-subrc <> 0.
    *    write: 'Material', material, 'not in material master'.
    *    exit.
    *  endif.
      select single pstat from t134 into w_pstat
             where mtart = w_mtart.
      if sy-subrc <> 0.
        write: 'Material type', w_mtart, 'not found'.
      endif.
    * 3. Get Screen Sequence for Tcode/Material
      call function 'BILDSEQUENZ_IDENTIFY'
        exporting
          materialart = w_mtart
          tcode_ref   = w_t130m-trref
        importing
          bildsequenz = w_bilds
        exceptions
          wrong_call  = 1
          not_found   = 2
          others      = 3.
      if sy-subrc <> 0.
        write: 'BILDSEQUENZ_IDENTIFY error code =', sy-subrc.
        exit.
      endif.
    * 4. Get Summary status (Transaction+Material+Material Type)
      call function 'ANZGSTATUS_SETZEN'
        exporting
          aktyp            = w_t130m-aktyp
          marastatus       = w_vpsta
          t134status       = w_pstat
          tkstatus         = w_tkstatus
        importing
          anzgstatus       = w_anzgstatus
        exceptions
          anzgstatus_empty = 1
          wrong_call       = 2
          others           = 3.
      if sy-subrc <> 0.
        write: 'ANZGSTATUS_SETZEN error code =', sy-subrc.
        exit.
      endif.
    * 5. Get all selection views:
      call function 'SELECTION_VIEWS_FIND'
        exporting
          bildsequenz     = w_bilds
          pflegestatus    = w_anzgstatus
        tables
          bildtab         = it_views
        exceptions
          call_wrong      = 1
          empty_selection = 2
          others          = 3.
      if sy-subrc <> 0.
        write: 'SELECTION_VIEWS_FIND error code =', sy-subrc.
        exit.
      endif.
    * 5. Get view #:
      read table it_views with key auswg = 35 .   "35  - Costing View 2
      if sy-subrc = 0.
        w_linex = sy-tabix.
    *  else.
    *    write: 'View', view, 'not found'.
    *    exit.
      endif.
    endform.                    " GET_VIEWPOS
    *&      Form  CONVERT_DATE_EXTERNAL
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form convert_date_external .
      call function 'CONVERT_DATE_TO_EXTERNAL'
        exporting
          date_internal            = itab-zpld1
        importing
          date_external            = pdate
        exceptions
          date_internal_is_invalid = 1
          others                   = 2.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform.                    " CONVERT_DATE_EXTERNAL
    *&      Form  UPLOAD_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form upload_data .
      data : file_table type file_table occurs 0,
               fwa type file_table,
               filename type string,
               rc type i.
      call method cl_gui_frontend_services=>file_open_dialog
        exporting
          window_title            = 'Open File'
    *    DEFAULT_EXTENSION       =
    *    DEFAULT_FILENAME        =
    *    FILE_FILTER             =
    *    INITIAL_DIRECTORY       =
    *    MULTISELECTION          =
    *    WITH_ENCODING           =
        changing
          file_table              = file_table
          rc                      = rc
    *    USER_ACTION             =
    *    FILE_ENCODING           =
        exceptions
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 4
          others                  = 5
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                   with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
      read table file_table index 1 into fwa.
      filename = fwa-filename.
      call function 'GUI_UPLOAD'
           exporting
                filename                = filename
                filetype                = 'DAT'
    *        IMPORTING
    *             FILELENGTH              =
           tables
                data_tab                = itab
           exceptions
                file_open_error         = 1
                file_read_error         = 2
                no_batch                = 3
                gui_refuse_filetransfer = 4
                invalid_type            = 5
                others                  = 6 .
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform.                    " UPLOAD_DATA
    Regards,
    Morris Bond.
    Reward Points if Helpful.

  • Bdc for table control in abap -hr

    Dear all,
    how can we read if infotype is having table control 0008
    how to record 0008 infotype please suggest me
    Regards.
    bose,

    HI,
    Have two internal table, one containing the primary data and other with multiple data regarding to particular primary data with one column as key field. In the BDC code, write LOOP Statement with the second internal table. No other modification is required for it.
    Hope you understand it.

  • BDC With table Control

    Dear All .
    can you give me some idea how to do BDC with tbale Control . Any documentation on the same or some simple example .

    Handling Table Control in BDC
    An example abap program of handling Table Control during bdc programming.
    REPORT zmm_bdcp_purchaseorderkb02
           NO STANDARD PAGE HEADING LINE-SIZE 255.
                    Declaring internal tables                            *
    *-----Declaring line structure
    DATA : BEGIN OF it_dummy OCCURS 0,
             dummy(255) TYPE c,
           END OF it_dummy.
    *-----Internal table for line items
    DATA :  BEGIN OF it_idata OCCURS 0,
              ematn(18),      "Material Number.
              menge(13),      "Qyantity.
              netpr(11),      "Net Price.
              werks(4),       "Plant.
              ebelp(5),       "Item Number.
            END OF it_idata.
    *-----Deep structure for header data and line items
    DATA  :  BEGIN OF it_me21 OCCURS 0,
               lifnr(10),      "Vendor A/c No.
               bsart(4),       "A/c Type.
               bedat(8),       "Date of creation of PO.
               ekorg(4),       "Purchasing Organisation.
               ekgrp(3),       "Purchasing Group.
               x_data LIKE TABLE OF it_idata,
             END OF it_me21.
    DATA  :  x_idata LIKE LINE OF it_idata.
    DATA  :  v_delimit VALUE ','.
    DATA  :  v_indx(3) TYPE n.
    DATA  :  v_fnam(30) TYPE c.
    DATA  :  v_count TYPE n.
    DATA  :  v_ne TYPE i.
    DATA  :  v_ns TYPE i.
    *include bdcrecx1.
    INCLUDE zmm_incl_purchaseorderkb01.
                    Search help for file                                 *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
        IMPORTING
          file_name     = p_file.
    START-OF-SELECTION.
           To upload the data into line structure                        *
      CALL FUNCTION 'WS_UPLOAD'
        EXPORTING
          filename = p_file
          filetype = 'DAT'
        TABLES
          data_tab = it_dummy.
        Processing the data from line structure to internal tables       *
      REFRESH:it_me21.
      CLEAR  :it_me21.
      LOOP AT it_dummy.
        IF it_dummy-dummy+0(01) = 'H'.
          v_indx = v_indx + 1.
          CLEAR   it_idata.
          REFRESH it_idata.
          CLEAR   it_me21-x_data.
          REFRESH it_me21-x_data.
          SHIFT it_dummy.
          SPLIT it_dummy AT v_delimit INTO it_me21-lifnr
                                           it_me21-bsart
                                           it_me21-bedat
                                           it_me21-ekorg
                                           it_me21-ekgrp.
          APPEND it_me21.
        ELSEIF it_dummy-dummy+0(01) = 'L'.
          SHIFT it_dummy.
          SPLIT it_dummy AT v_delimit INTO it_idata-ematn
                                           it_idata-menge
                                           it_idata-netpr
                                           it_idata-werks
                                           it_idata-ebelp.
          APPEND it_idata TO it_me21-x_data.
          MODIFY it_me21 INDEX v_indx.
        ENDIF.
      ENDLOOP.
                    To open the group                                    *
      PERFORM open_group.
            To populate the bdcdata table for header data                *
      LOOP AT it_me21.
        v_count = v_count + 1.
        REFRESH it_bdcdata.
        PERFORM subr_bdc_table USING:   'X' 'SAPMM06E'    '0100',
                                        ' ' 'BDC_CURSOR'  'EKKO-LIFNR',
                                        ' ' 'BDC_OKCODE'  '/00',
                                        ' ' 'EKKO-LIFNR'  it_me21-lifnr,
                                        ' ' 'RM06E-BSART' it_me21-bsart,
                                        ' ' 'RM06E-BEDAT' it_me21-bedat,
                                        ' ' 'EKKO-EKORG'  it_me21-ekorg,
                                        ' ' 'EKKO-EKGRP'  it_me21-ekgrp,
                                        ' ' 'RM06E-LPEIN' 'T'.
        PERFORM subr_bdc_table USING:   'X' 'SAPMM06E'    '0120',
                                        ' ' 'BDC_CURSOR'  'RM06E-EBELP',
                                        ' ' 'BDC_OKCODE'  '/00'.
        MOVE 1 TO v_indx.
    *-----To populate the bdcdata table for line item data
        LOOP AT it_me21-x_data INTO x_idata.
          CONCATENATE 'EKPO-EMATN(' v_indx ')'  INTO v_fnam.
          PERFORM  subr_bdc_table USING ' ' v_fnam x_idata-ematn.
          CONCATENATE 'EKPO-MENGE(' v_indx ')'  INTO v_fnam.
          PERFORM  subr_bdc_table USING ' ' v_fnam x_idata-menge.
          CONCATENATE 'EKPO-NETPR(' v_indx ')'  INTO v_fnam.
          PERFORM  subr_bdc_table USING ' ' v_fnam x_idata-netpr.
          CONCATENATE 'EKPO-WERKS(' v_indx ')'  INTO v_fnam.
          PERFORM  subr_bdc_table USING ' ' v_fnam x_idata-werks.
          v_indx = v_indx + 1.
          PERFORM subr_bdc_table USING:  'X' 'SAPMM06E'    '0120',
                                         ' ' 'BDC_CURSOR'  'RM06E-EBELP',
                                         ' ' 'BDC_OKCODE'  '/00'.
        ENDLOOP.
        PERFORM subr_bdc_table USING:    'X' 'SAPMM06E'    '0120',
                                         ' ' 'BDC_CURSOR'  'RM06E-EBELP',
                                         ' ' 'BDC_OKCODE'  '=BU'.
        PERFORM bdc_transaction USING 'ME21'.
      ENDLOOP.
      PERFORM close_group.
                      End of selection event                             *
    END-OF-SELECTION.
      IF session NE 'X'.
    *-----To display the successful records
        WRITE :/10  text-001.          "Sucess records
        WRITE :/10  SY-ULINE(20).
        SKIP.
        IF it_sucess IS INITIAL.
          WRITE :/  text-002.
        ELSE.
          WRITE :/   text-008,          "Total number of Succesful records
                  35 v_ns.
          SKIP.
          WRITE:/   text-003,          "Vendor Number
                 17 text-004,          "Record number
                 30 text-005.          "Message
        ENDIF.
        LOOP AT it_sucess.
          WRITE:/4  it_sucess-lifnr,
                 17 it_sucess-tabix CENTERED,
                 30 it_sucess-sucess_rec.
        ENDLOOP.
        SKIP.
    *-----To display the erroneous records
        WRITE:/10   text-006.          "Error Records
        WRITE:/10   SY-ULINE(17).
        SKIP.
        IF it_error IS INITIAL.
          WRITE:/   text-007.          "No error records
        ELSE.
          WRITE:/   text-009,          "Total number of erroneous records
                 35 v_ne.
          SKIP.
          WRITE:/   text-003,          "Vendor Number
                 17 text-004,          "Record number
                 30 text-005.          "Message
        ENDIF.
        LOOP AT it_error.
          WRITE:/4  it_error-lifnr,
                 17 it_error-tabix CENTERED,
                 30 it_error-error_rec.
        ENDLOOP.
        REFRESH it_sucess.
        REFRESH it_error.
      ENDIF.
    CODE IN INCLUDE.
    Include           ZMM_INCL_PURCHASEORDERKB01
    DATA:   it_BDCDATA LIKE BDCDATA    OCCURS 0 WITH HEADER LINE.
    DATA:   it_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    DATA:   E_GROUP_OPENED.
    *-----Internal table to store sucess records
    DATA:BEGIN OF it_sucess OCCURS 0,
           msgtyp(1)   TYPE c,
           lifnr  LIKE  ekko-lifnr,
           tabix  LIKE  sy-tabix,
           sucess_rec(125),
         END OF it_sucess.
    DATA: g_mess(125) type c.
    *-----Internal table to store error records
    DATA:BEGIN OF it_error OCCURS 0,
           msgtyp(1)   TYPE c,
           lifnr  LIKE  ekko-lifnr,
           tabix  LIKE  sy-tabix,
           error_rec(125),
         END OF it_error.
           Selection screen
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS session RADIOBUTTON GROUP ctu.  "create session
    SELECTION-SCREEN COMMENT 3(20) text-s07 FOR FIELD session.
    SELECTION-SCREEN POSITION 45.
    PARAMETERS ctu RADIOBUTTON GROUP ctu.     "call transaction
    SELECTION-SCREEN COMMENT 48(20) text-s08 FOR FIELD ctu.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(20) text-s01 FOR FIELD group.
    SELECTION-SCREEN POSITION 25.
    PARAMETERS group(12).                      "group name of session
    SELECTION-SCREEN COMMENT 48(20) text-s05 FOR FIELD ctumode.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS ctumode LIKE ctu_params-dismode DEFAULT 'N'.
    "A: show all dynpros
    "E: show dynpro on error only
    "N: do not display dynpro
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 48(20) text-s06 FOR FIELD cupdate.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS cupdate LIKE ctu_params-updmode DEFAULT 'L'.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(20) text-s03 FOR FIELD keep.
    SELECTION-SCREEN POSITION 25.
    PARAMETERS: keep AS CHECKBOX.       "' ' = delete session if finished
    "'X' = keep   session if finished
    SELECTION-SCREEN COMMENT 48(20) text-s09 FOR FIELD e_group.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS e_group(12).             "group name of error-session
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 51(17) text-s03 FOR FIELD e_keep.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS: e_keep AS CHECKBOX.     "' ' = delete session if finished
    "'X' = keep   session if finished
    SELECTION-SCREEN END OF LINE.
    PARAMETERS:p_file LIKE rlgrap-filename.
      at selection screen                                                *
    AT SELECTION-SCREEN.
    group and user must be filled for create session
      IF SESSION = 'X' AND
         GROUP = SPACE. "OR USER = SPACE.
        MESSAGE E613(MS).
      ENDIF.
      create batchinput session                                          *
    FORM OPEN_GROUP.
      IF SESSION = 'X'.
        SKIP.
        WRITE: /(20) 'Create group'(I01), GROUP.
        SKIP.
    *----open batchinput group
        CALL FUNCTION 'BDC_OPEN_GROUP'
          EXPORTING
            CLIENT = SY-MANDT
            GROUP  = GROUP
            USER   = sy-uname.
        WRITE:/(30) 'BDC_OPEN_GROUP'(I02),
                (12) 'returncode:'(I05),
                     SY-SUBRC.
      ENDIF.
    ENDFORM.                    "OPEN_GROUP
      end batchinput session                                             *
    FORM CLOSE_GROUP.
      IF SESSION = 'X'.
    *------close batchinput group
        CALL FUNCTION 'BDC_CLOSE_GROUP'.
        WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),
                (12) 'returncode:'(I05),
                     SY-SUBRC.
      ELSE.
        IF E_GROUP_OPENED = 'X'.
          CALL FUNCTION 'BDC_CLOSE_GROUP'.
          WRITE: /.
          WRITE: /(30) 'Fehlermappe wurde erzeugt'(I06).
        ENDIF.
      ENDIF.
    ENDFORM.                    "CLOSE_GROUP
           Start new transaction according to parameters                 *
    FORM BDC_TRANSACTION USING TCODE TYPE ANY.
      DATA: L_SUBRC LIKE SY-SUBRC.
    *------batch input session
      IF SESSION = 'X'.
        CALL FUNCTION 'BDC_INSERT'
          EXPORTING
            TCODE     = TCODE
          TABLES
            DYNPROTAB = it_BDCDATA.
        WRITE: / 'BDC_INSERT'(I03),
                 TCODE,
                 'returncode:'(I05),
                 SY-SUBRC,
                 'RECORD:',
                 SY-INDEX.
      ELSE.
        REFRESH it_MESSTAB.
        CALL TRANSACTION TCODE USING it_BDCDATA
                         MODE   CTUMODE
                         UPDATE CUPDATE
                         MESSAGES INTO it_MESSTAB.
        L_SUBRC = SY-SUBRC.
        WRITE: / 'CALL_TRANSACTION',
                 TCODE,
                 'returncode:'(I05),
                 L_SUBRC,
                 'RECORD:',
                 SY-INDEX.
      ENDIF.
      Message handling for Call Transaction                              *
      perform subr_mess_hand using g_mess.
    *-----Erzeugen fehlermappe
      IF L_SUBRC <> 0 AND E_GROUP <> SPACE.
        IF E_GROUP_OPENED = ' '.
          CALL FUNCTION 'BDC_OPEN_GROUP'
            EXPORTING
              CLIENT = SY-MANDT
              GROUP  = E_GROUP
              USER   = sy-uname
              KEEP   = E_KEEP.
          E_GROUP_OPENED = 'X'.
        ENDIF.
        CALL FUNCTION 'BDC_INSERT'
          EXPORTING
            TCODE     = TCODE
          TABLES
            DYNPROTAB = it_BDCDATA.
      ENDIF.
      REFRESH it_BDCDATA.
    ENDFORM.                    "BDC_TRANSACTION
         Form  subr_bdc_table                                            *
          text
         -->P_0220   text                                                *
         -->P_0221   text                                                *
         -->P_0222   text                                                *
    FORM subr_bdc_table  USING      VALUE(P_0220) TYPE ANY
                                    VALUE(P_0221) TYPE ANY
                                    VALUE(P_0222) TYPE ANY.
      CLEAR it_bdcdata.
      IF P_0220 = ' '.
        CLEAR it_bdcdata.
        it_bdcdata-fnam     = P_0221.
        it_bdcdata-fval     = P_0222.
        APPEND it_bdcdata.
      ELSE.
        it_bdcdata-dynbegin = P_0220.
        it_bdcdata-program  = P_0221.
        it_bdcdata-dynpro   = P_0222.
        APPEND it_bdcdata.
      ENDIF.
    ENDFORM.                    " subr_bdc_table
         Form  subr_mess_hand                                            *
          text                                                           *
         -->P_G_MESS  text                                               *
    FORM subr_mess_hand USING  P_G_MESS TYPE ANY.
      LOOP AT IT_MESSTAB.
        CALL FUNCTION 'FORMAT_MESSAGE'
          EXPORTING
            ID     = it_messtab-msgid
            LANG   = it_messtab-msgspra
            NO     = it_messtab-msgnr
            v1     = it_messtab-msgv1
            v2     = it_messtab-msgv2
          IMPORTING
            MSG    = P_G_MESS
          EXCEPTIONS
            OTHERS = 0.
        CASE it_messtab-msgtyp.
          when 'E'.
            it_error-error_rec   =  P_G_MESS.
            it_error-lifnr       =  it_me21-lifnr.
            it_error-tabix       =  v_count.
            APPEND IT_ERROR.
          when 'S'.
            it_sucess-sucess_rec =  P_G_MESS.
            it_sucess-lifnr      =  it_me21-lifnr.
            it_sucess-tabix      =  v_count.
            APPEND IT_SUCESS.
        endcase.
      ENDLOOP.
      Describe table it_sucess lines v_ns.
      Describe table it_error  lines v_ne.
    ENDFORM.                    " subr_mess_hand

  • BDC with Table control. how to handle the scrolling function?

    I have 20 records to be uploaded to table control using BDC. But the screen displayed shows only 10 rows and i have to scroll down to enter the 11th record onwards. but this job has to be done in the background. give me sugesstions on this isssue.

    Moderator message - Please search before asking - post locked
    Moderator message - Cross post locked

  • How to add rows in table control for data recording BDC?

    hello,
    pl tell me the way to upload data through BDC in table control of screen .
    how to add fields inrecording of table control?
    Please give some code in this regard.
    I am generous in giving points..pl help!

    Hi,
    While doing code under recording first you need to do the recording with sample data under a particular transaction like T-code XK01 (Vendor creation).
    Take an example of create vendor using T-code XK01:
    Go to t-code 'SHDB' under make recording for XK01 with sample data and once if you complete the recording means after vendor creation check the source code bye by pressing the button  'Program', it shows the total coding for recording of what you entered the test data.
    Then you will create one program and copy that source code of recording into your program, and now you have to remove the values at perform statement and give the internal table field name.
    Like that you can develop your own code along with your validations.
    my best suggestion is don’t see the example code of recording method because any one for standard t-code should get the code from recording with sample data, so first tryout with your own recording method and you can understand the code step by step.
    With these I hope you will get some idea of recoding method.
    Let me know for further doubts.
    Regards,
    Vijay.

  • Page down functionality in table control BDC-CJ02 tcode

    Hi Friends,
    I am doing a BDC with Table control for Tcode CJ02.
    When I reach certain number of records, say 13, the page down functionality doesnt work.I tried different ways like using the BDC_OKCODE as "=P" and "=P+".Also, I tried doing a recording by pressing the down key in the table contral, in SHDB, but none of them worked.
    Refered a post in SDN as well, but it doesnt hold any solution.
    Do throw some light on the same to achieve page down functionality for the bdc tcode CJ02.
    Thanks in advance.
    Shri.

    Hi,
    I already posted an answer to that here Re: BDC scroll down with OK_CODE '=P+':
    P+ (=P+ in the BDC) is not a universal function code, but only one which is defined in ABAP lists . So, 99% of time, it doesn't work for all others situations (like yours).
    Scrolling a table control is not so easy to do. When you record a page down on a table control in SHDB, you'll get probably a /00 which corresponds to Enter. When you play the recording, it won't scroll. The issue is that "page down" is processed in 2 parts, it changes the "top line" of the table control, and executes Enter. But it's not possible to record/play the "top line" information.
    The solution is that the program usually implements a function code:
    either "add new line"
    or "position at line"
    Sometimes, the function code is hidden so you must look at inside the program (or search SAP notes, like here: [SAP note 187946 (No positioning on PRT overview in routing)|https://service.sap.com/sap/support/notes/187946 ])
    And sometimes, there's no function code at all, and then you're stuck ! (or use SAP GUI scripting, but it may only work in dialog).
    For CJ02, I can't tell how to scroll through BDC, but anyway, there is a BAPI (don't remember the name, search the forum, it will be easy to find it), so you should always prefer them over BDC.
    Sandra

  • Update records in table control BDC

    I am using BDC on table control in which I have to scroll the table. The table shows 4 rows by default. I want to enter values for the 1st and 6th row. I use =p+ OK code to scroll.
    When enter value for 6th row the value in the first row vanishes.
    Please suggest

    I have to perform f_bdc_dynpro for screen 'MP901200' '2000' repeatedly for scrolling
    perform f_bdc_dynpro      using 'MP901200' '2000'.
    perform f_bdc_field       using 'BDC_CURSOR'
                                  'PT9012-SALARYSCHED'.
    perform f_bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform f_bdc_field       using 'P9012-BEGDA'
                                  '19.01.2009'.
    perform f_bdc_field       using 'P9012-ENDDA'
                                  '31.12.9999'.
    perform f_bdc_field       using 'PT9012-PLANN'
                                  '1143'.
    perform f_bdc_field       using 'PT9012-SALARYSCHED'
                                  '01'.
    perform f_bdc_field       using 'PPHDX-ENTRY_IDX'
                                  '1'.
    Here I enter value for individual fields other than the table control.
    perform f_bdc_dynpro      using 'MP901200' '2000'.
    perform f_bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform f_bdc_field       using 'P9012-BEGDA'
                                  '19.01.2009'.
    perform f_bdc_field       using 'P9012-ENDDA'
                                  '31.12.9999'.
    perform f_bdc_field       using 'PT9012-PLANN'
                                  '1143'.
    perform f_bdc_field       using 'PT9012-SALARYSCHED'
                                  '01'.
    perform f_bdc_field       using 'PPHDX-ENTRY_IDX'
                                  '1'.
    perform f_bdc_field       using 'PT9012-DEGREE(01)'
                                  '03'.
    Here I enter value in the first row of table control.
    perform f_bdc_dynpro      using 'MP901200' '2000'.
    perform f_bdc_field       using 'BDC_OKCODE'
                                  '=p+'.
    perform f_bdc_field       using 'P9012-BEGDA'
                                  '19.01.2009'.
    perform f_bdc_field       using 'P9012-ENDDA'
                                  '31.12.9999'.
    perform f_bdc_field       using 'PT9012-PLANN'
                                  '1143'.
    perform f_bdc_field       using 'PT9012-SALARYSCHED'
                                  '01'.
    perform f_bdc_field       using 'PPHDX-ENTRY_IDX'
                                  '1'.
    here i scroll down to come to the sixth row.
    perform f_bdc_field       using 'BDC_OKCODE'
                                  '=/00'.
    perform f_bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform f_bdc_field       using 'P9012-BEGDA'
                                  '19.01.2009'.
    perform f_bdc_field       using 'P9012-ENDDA'
                                  '31.12.9999'.
    perform f_bdc_field       using 'PT9012-PLANN'
                                  '1143'.
    perform f_bdc_field       using 'PT9012-SALARYSCHED'
                                  '01'.
    perform f_bdc_field       using 'PPHDX-ENTRY_IDX'
                                  '6'.
    perform f_bdc_field       using 'PT9012-DEGREE(02)'
                                  '01'.
    Here I enter the value at second row as the 6th row is now the 2nd row after scrolling.
    but due to this the value in the first row vanishes.

  • Problem in Table controls in BDC

    Hi All,
    I have porblem in BDC using table controls.
    I am working on VBO2 transaction i developed BDC for that i used CTUParameters for screen resulution
    whenever press P+ it will go 11 recors in up and 11 is the first line in second page so how to map that
    please help me.

    HI...
    when that screen perform will come follow these steps...
    before the table control screen... write following code.....
    v_count = v_count + 1. ( you need to declare this variable )
    (as your screen contains 11 row....)
    IF v_count le 11.
    pass the values to the perform statements.......
    else.
    add the perform related to P+ .
    v_count = 1.
    pass the values to the perform statements.......
    ENDLOOP.
    i hoep this info will be helpfull for you,,,,,,
    if you need any clarification please revert back....
    regards,
    nag.

Maybe you are looking for

  • How to Generate CSV Output from JD Edwards BI Publisher

    Hi All, I have a report "Critical Date Report" - R15611 in JD Edwards 8.11. This report has to be generated as CSV output from BI Publisher which is embedded to JDE. The purpose we want use BI Publisher is to move some of the data displaying to diffe

  • Logging Problems on CSS11503 - please help

    Hi, 1 of our CSS11503 is not functioning properly. Our ITO system is receiving "server down" messages for services but the "server up" message is not coming through. We have 2 load balancers with identical config, the only difference I can see in the

  • GL Posting ALE IDOC - To be send as File

    Hello, It is possible to send GL Posting from SAP HR system to another system as a file. Option is that I am looking through Standard ALE whether we can create a GL Posting document file which will be transferred thru FTP file to client system. Quest

  • Contact sheet title

    Working with iPhoto 4.0.3 I know how to print a contact sheet using iPhoto. Is it possible for iPhoto to add the title of the photo next to each image? Marc

  • Counting columns based on set criteria?

    Hello gurus, I've been trying for the past hour to count the number of columns that have a certain condition met, that is two check boxes are ticked. For example: I want to count the number of columns where both Apples & Oranges is TRUE. I've tried c