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

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.

  • 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

  • BDC program for rebate with table controls

    Hi Friends,
    Iam Doing  bdc program for Rebate(TCODE VBO1) with table controls..
    can u give the solutions for table controls...
    if anybody having the code..please send me..
    Thanks & Advance,
    sampath

    hi,
    check this example it may help you.
    REPORT  ZSR_BDC_TBCTRL
            NO STANDARD PAGE HEADING LINE-SIZE 255.
    TABLES : RF02K,LFA1,LFBK.
    DATA : BEGIN OF IT_VEN OCCURS 0,
          LIFNR LIKE RF02K-LIFNR,
          KTOKK LIKE RF02K-KTOKK,
          NAME1 LIKE LFA1-NAME1,
          SORTL LIKE LFA1-SORTL,
          LAND1 LIKE LFA1-LAND1,
          SPRAS LIKE LFA1-SPRAS,
          BANKS(6) TYPE C,
          BANKL(17) TYPE C,
          BANKN(19) TYPE C,
          END OF IT_VEN.
    DATA : BEGIN OF BANKS OCCURS 0,
           BANKS LIKE LFBK-BANKS,
           END OF BANKS,
           BEGIN OF BANKL OCCURS 0,
           BANKL LIKE LFBK-BANKL,
           END OF BANKL,
           BEGIN OF BANKN OCCURS 0,
           BANKN LIKE LFBK-BANKN,
           END OF BANKN.
    DATA : FLD(20) TYPE C,
           CNT(2) TYPE N.
    DATA : BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    INCLUDE BDCRECX1.
    START-OF-SELECTION.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = 'Z:\sr.TXT'
       FILETYPE                      = 'ASC'
       HAS_FIELD_SEPARATOR           = 'X'
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      TABLES
        DATA_TAB                      = IT_VEN
    EXCEPTIONS
      FILE_OPEN_ERROR               = 1
      FILE_READ_ERROR               = 2
      NO_BATCH                      = 3
      GUI_REFUSE_FILETRANSFER       = 4
      INVALID_TYPE                  = 5
      NO_AUTHORITY                  = 6
      UNKNOWN_ERROR                 = 7
      BAD_DATA_FORMAT               = 8
      HEADER_NOT_ALLOWED            = 9
      SEPARATOR_NOT_ALLOWED         = 10
      HEADER_TOO_LONG               = 11
      UNKNOWN_DP_ERROR              = 12
      ACCESS_DENIED                 = 13
      DP_OUT_OF_MEMORY              = 14
      DISK_FULL                     = 15
      DP_TIMEOUT                    = 16
      OTHERS                        = 17
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    PERFORM OPEN_GROUP.
    LOOP AT IT_VEN.
        REFRESH BDCDATA.
        REFRESH : BANKS,BANKL,BANKN..
        SPLIT IT_VEN-BANKS AT ',' INTO TABLE BANKS.
        SPLIT IT_VEN-BANKL AT ',' INTO TABLE BANKL.
        SPLIT IT_VEN-BANKN AT ',' INTO TABLE BANKN.
    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'
                                  IT_VEN-LIFNR.
    PERFORM BDC_FIELD       USING 'RF02K-KTOKK'
                                  IT_VEN-KTOKK.
    PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0110'.
    PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                  'LFA1-SPRAS'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '/00'.
    PERFORM BDC_FIELD       USING 'LFA1-NAME1'
                                  IT_VEN-NAME1.
    PERFORM BDC_FIELD       USING 'LFA1-SORTL'
                                  IT_VEN-SORTL.
    PERFORM BDC_FIELD       USING 'LFA1-LAND1'
                                  IT_VEN-LAND1.
    PERFORM BDC_FIELD       USING 'LFA1-SPRAS'
                                  IT_VEN-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-BANKN(02)'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '=ENTR'.
    *perform bdc_field       using 'LFBK-BANKS(01)'
                                 'DE'.
    *perform bdc_field       using 'LFBK-BANKS(02)'
                                 'DE'.
    *perform bdc_field       using 'LFBK-BANKL(01)'
                                 '10020030'.
    *perform bdc_field       using 'LFBK-BANKL(02)'
                                 '67270003'.
    *perform bdc_field       using 'LFBK-BANKN(01)'
                                 '12345'.
    *perform bdc_field       using 'LFBK-BANKN(02)'
                                 '66666'.
    MOVE 1 TO CNT.
        LOOP AT BANKS.
          CONCATENATE 'LFBK-BANKS(' CNT ') ' INTO FLD.
          PERFORM BDC_FIELD USING FLD BANKS-BANKS.
          CNT = CNT + 1.
        ENDLOOP.
        MOVE 1 TO CNT.
        LOOP AT BANKL.
          CONCATENATE 'LFBK-BANKL(' CNT ') ' INTO FLD.
          PERFORM BDC_FIELD USING FLD BANKL-BANKL.
          CNT = CNT + 1.
        ENDLOOP.
        MOVE 1 TO CNT.
        LOOP AT BANKN.
          CONCATENATE 'LFBK-BANKN(' CNT ') ' INTO FLD.
          PERFORM BDC_FIELD USING FLD BANKN-BANKN.
          CNT = CNT + 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 'SAPLSPO1' '0300'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '=YES'.
    PERFORM BDC_TRANSACTION USING 'XK01'.
    ENDLOOP.
    PERFORM CLOSE_GROUP.&----
    *& Report  ZSR_BDC_TBCTRL
    REPORT  ZSR_BDC_TBCTRL
            NO STANDARD PAGE HEADING LINE-SIZE 255.
    TABLES : RF02K,LFA1,LFBK.
    DATA : BEGIN OF IT_VEN OCCURS 0,
          LIFNR LIKE RF02K-LIFNR,
          KTOKK LIKE RF02K-KTOKK,
          NAME1 LIKE LFA1-NAME1,
          SORTL LIKE LFA1-SORTL,
          LAND1 LIKE LFA1-LAND1,
          SPRAS LIKE LFA1-SPRAS,
          BANKS(6) TYPE C,
          BANKL(17) TYPE C,
          BANKN(19) TYPE C,
          END OF IT_VEN.
    DATA : BEGIN OF BANKS OCCURS 0,
           BANKS LIKE LFBK-BANKS,
           END OF BANKS,
           BEGIN OF BANKL OCCURS 0,
           BANKL LIKE LFBK-BANKL,
           END OF BANKL,
           BEGIN OF BANKN OCCURS 0,
           BANKN LIKE LFBK-BANKN,
           END OF BANKN.
    DATA : FLD(20) TYPE C,
           CNT(2) TYPE N.
    DATA : BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    INCLUDE BDCRECX1.
    START-OF-SELECTION.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = 'Z:\sr.TXT'
       FILETYPE                      = 'ASC'
       HAS_FIELD_SEPARATOR           = 'X'
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      TABLES
        DATA_TAB                      = IT_VEN
    EXCEPTIONS
      FILE_OPEN_ERROR               = 1
      FILE_READ_ERROR               = 2
      NO_BATCH                      = 3
      GUI_REFUSE_FILETRANSFER       = 4
      INVALID_TYPE                  = 5
      NO_AUTHORITY                  = 6
      UNKNOWN_ERROR                 = 7
      BAD_DATA_FORMAT               = 8
      HEADER_NOT_ALLOWED            = 9
      SEPARATOR_NOT_ALLOWED         = 10
      HEADER_TOO_LONG               = 11
      UNKNOWN_DP_ERROR              = 12
      ACCESS_DENIED                 = 13
      DP_OUT_OF_MEMORY              = 14
      DISK_FULL                     = 15
      DP_TIMEOUT                    = 16
      OTHERS                        = 17
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    PERFORM OPEN_GROUP.
    LOOP AT IT_VEN.
        REFRESH BDCDATA.
        REFRESH : BANKS,BANKL,BANKN..
        SPLIT IT_VEN-BANKS AT ',' INTO TABLE BANKS.
        SPLIT IT_VEN-BANKL AT ',' INTO TABLE BANKL.
        SPLIT IT_VEN-BANKN AT ',' INTO TABLE BANKN.
    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'
                                  IT_VEN-LIFNR.
    PERFORM BDC_FIELD       USING 'RF02K-KTOKK'
                                  IT_VEN-KTOKK.
    PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0110'.
    PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                  'LFA1-SPRAS'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '/00'.
    PERFORM BDC_FIELD       USING 'LFA1-NAME1'
                                  IT_VEN-NAME1.
    PERFORM BDC_FIELD       USING 'LFA1-SORTL'
                                  IT_VEN-SORTL.
    PERFORM BDC_FIELD       USING 'LFA1-LAND1'
                                  IT_VEN-LAND1.
    PERFORM BDC_FIELD       USING 'LFA1-SPRAS'
                                  IT_VEN-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-BANKN(02)'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '=ENTR'.
    *perform bdc_field       using 'LFBK-BANKS(01)'
                                 'DE'.
    *perform bdc_field       using 'LFBK-BANKS(02)'
                                 'DE'.
    *perform bdc_field       using 'LFBK-BANKL(01)'
                                 '10020030'.
    *perform bdc_field       using 'LFBK-BANKL(02)'
                                 '67270003'.
    *perform bdc_field       using 'LFBK-BANKN(01)'
                                 '12345'.
    *perform bdc_field       using 'LFBK-BANKN(02)'
                                 '66666'.
    MOVE 1 TO CNT.
        LOOP AT BANKS.
          CONCATENATE 'LFBK-BANKS(' CNT ') ' INTO FLD.
          PERFORM BDC_FIELD USING FLD BANKS-BANKS.
          CNT = CNT + 1.
        ENDLOOP.
        MOVE 1 TO CNT.
        LOOP AT BANKL.
          CONCATENATE 'LFBK-BANKL(' CNT ') ' INTO FLD.
          PERFORM BDC_FIELD USING FLD BANKL-BANKL.
          CNT = CNT + 1.
        ENDLOOP.
        MOVE 1 TO CNT.
        LOOP AT BANKN.
          CONCATENATE 'LFBK-BANKN(' CNT ') ' INTO FLD.
          PERFORM BDC_FIELD USING FLD BANKN-BANKN.
          CNT = CNT + 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 'SAPLSPO1' '0300'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '=YES'.
    PERFORM BDC_TRANSACTION USING 'XK01'.
    ENDLOOP.
    PERFORM CLOSE_GROUP.

  • How can I work lsmw with table control using mm01 appl?

    Hi
    How can I work lsmw with table control using mm01 appl?
    Is it difefrent the way we handle table control in BDC?
    Thank You

    Hi
    How can I work lsmw with table control using mm01 appl?
    Is it difefrent the way we handle table control in BDC?
    Thank You

  • Strange issue with table control in dialog programming! Please help!

    Hello everyone:
                I have a table control on screen painter and I have atleast 10 rows on display when user calls the screen. If I have 15 columns then ofcourse user has to scroll down to see extra rows. I have line selection set to "single" for table control so that user can select only one row at a time. This works fine when user does not have to scroll to see extra rows. It is tough for me to explain i.e., if the table control displays 10 rows when the screen opens up then they can only select single row at a time (rows 1 -10). For example user selected row 7 and now they scroll down to see extra rows (for example 13) then it lets them select row 13 also even though I set line selection to "single" in the properties for table control! They should be able to select only one row at a time. Is this some limitation with table control in SAP? Please give me any information you have.
    Thanks.
    Mithun

    Hi,
    As you suspected, this is a limitation in the table control.  You need to take care of the single-selection functionality yourself except for the rows that are actually being displayed.  See [Note 588284|https://service.sap.com/sap/support/notes/588284] for the official SAP explanation.
    Regards,
    Jamie

  • ABAP HR How to create infotype with table control in it like Infotype 0008

    Hi Experts.
    I need help from u guys. My client requirement is to create custom infotype just like 0008 infotype which contain table control to save amount and wage types. I try to create infotype with table control using PM01, but that table control is in display mode only, i almost search every where to create custom infotype with table control but what ever threads in forum all are they unanswered and most of the threads for creating infotype. But i already done with infotype , but my main problem is table control.
    If any one have some suggestion for this please share with me.
    <removed by moderator> i am looking for positive reply.
    Edited by: Thomas Zloch on Aug 30, 2011 12:54 PM

    Hi
    I've created several infotypes with a Table Control and it is always the same story. You have to create a custom Z table to store the Table Control data (if you can have unlimited records), so in the PSXXXX structure you need to add a TABNR field to link the PAXXXX table and the Z one, just like the type table OM infotypes.
    Then in your code you have to control every possible operation, INS, MOD, DEL... and update the Z table accordingly (the standard code won't do that)
    If your TC fields appear in display mode, take a look at the Groups 1 and 3 in your fields, the must be set with the usual values for a PA infotype.
    If you have more questions, just ask,
    Regards

  • Sort up and sort Down push buttons in module pool with table control wizard

    hi,
    i have created 2 buttons for Sort up and sort Down push buttons in module pool with table control wizard
    please any one can help me.
    regards

    Hi
    Following code is to enable and disable the tbl control using two buttons. Just alter the code and for each button write the sort code.
    REPORT  YJAN27_SCREEN                                               .
    TABLES: SFLIGHT, YFLIGHT_28.
    TYPES: BEGIN OF struct1,
          carrid like sflight-carrid,
          connid like sflight-connid,
          fldate like sflight-fldate,
           END OF struct1.
    CONTROLS TBL1 TYPE TABLEVIEW USING SCREEN 2700.
    DATA: OK_CODE LIKE SY-UCOMM,
          CARRID LIKE SFLIGHT-CARRID,                                    "cols in tbl ctrl
          CONNID LIKE SFLIGHT-CONNID,
          FLDATE LIKE SFLIGHT-FLDATE,
          itab TYPE TABLE OF STRUCT1 WITH HEADER LINE,
          cols like line of TBL1-COLS,
          FLAG TYPE I.
    FLAG = 1.
    CALL SCREEN 2700.
    *&      Module  STATUS_2700  OUTPUT
    *       text
    MODULE STATUS_2700 OUTPUT.
      SET PF-STATUS 'BACK'.
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_2700  OUTPUT
    *&      Module  USER_COMMAND_2700  INPUT
    *       text
    MODULE USER_COMMAND_2700 INPUT.
    OK_CODE = SY-UCOMM.
    CASE OK_CODE.
      WHEN 'BACK'.
        LEAVE PROGRAM.
      WHEN 'DIS'.                                                         "write code for sort up
        loop AT TBL1-COLS INTO COLS.
           COLS-SCREEN-INPUT = 0.
            MODIFY TBL1-COLS FROM COLS.
        ENDLOOP.
        FLAG = 2.
      WHEN 'ENA'.                                                       "write code for sort down
        loop AT TBL1-COLS INTO COLS.
            COLS-SCREEN-INPUT = 1.
            MODIFY TBL1-COLS FROM COLS.
        ENDLOOP.
        FLAG = 1.
    ENDCASE.
    ENDMODULE.                 " USER_COMMAND_2700  INPUT
    *&      Module  GET_DATA  OUTPUT
    *       text
    MODULE GET_DATA OUTPUT.
      select carrid connid fldate from SFLIGHT into table itab.
    ENDMODULE.                 " GET_DATA  OUTPUT
    *&      Module  POPULATE_TBL  OUTPUT
    *       text
    MODULE POPULATE_TBL OUTPUT.
        MOVE-CORRESPONDING ITAB TO SFLIGHT.
    ENDMODULE.                 " POPULATE_TBL  OUTPUT
    *&      Module  CHANGE_SCREEN  OUTPUT
    *       text
    MODULE CHANGE_SCREEN OUTPUT.    " use this module if you want to hide the other button
    CASE FLAG.
      WHEN 1.
        LOOP AT SCREEN.
          IF SCREEN-NAME = 'B_ENA'.
            SCREEN-INVISIBLE = 1.
             MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
        LOOP AT SCREEN.
          IF SCREEN-NAME = 'B_DIS'.
            SCREEN-INVISIBLE = 0.
             MODIFY SCREEN.
          ENDIF.
       ENDLOOP.
      WHEN 2.
        LOOP AT SCREEN.
          IF SCREEN-NAME = 'B_DIS'.
            SCREEN-INVISIBLE = 1.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
        LOOP AT SCREEN.
          IF SCREEN-NAME = 'B_ENA'.
            SCREEN-INVISIBLE = 0.
             MODIFY SCREEN.
          ENDIF.
       ENDLOOP.
    ENDCASE.
    ENDMODULE.                 " CHANGE_SCREEN  OUTPUT
    PROCESS BEFORE OUTPUT.
    MODULE STATUS_2700.
    MODULE CHANGE_SCREEN.     " use this if you want to display one button at a time
    MODULE GET_DATA.
    loop at itab WITH control TBL1.
        MODULE POPULATE_TBL.       " populate tbl ctrl
    endloop.
    PROCESS AFTER INPUT.
    MODULE USER_COMMAND_2700.    " do the sort operations
    loop at itab.
      endloop.
    Hope this helps
    Regards,
    Jayanthi.K

  • Problem with Table control lines

    Hi Friends,
    This is the problem with table control lines:
    I have screen with table control and I would like change the table control lines dynamicaly.
    Exp:
    In my PBO the Internal table which I am using to loop the TC is havig 7 records and its displayed with 7 records, now I have added one more record into my ITAB and now ITAB is having 8 records, when I am looping this ITAB with TC its taking the TC lines 7 only.
    here is the code:
    Initial values in gt_scr400 = 8
    Initial values in tc_scr400 = 8
    Now added one more recor into gt_scr400 , now gt_scr400  = 9.
      LOOP AT   gt_scr400
           INTO wa_scr400
           WITH CONTROL tc_scr400
           CURSOR tc_scr400-current_line.
      ENDLOOP.
    I have used this logic :
      DESCRIBE TABLE gt_scr400 LINES g_rec_300 .
      tc_scr300-lines = g_rec_300.
    but its not modifying the lines in my table control.
    How to change the TC lines based on ITAB total records.
    Thanks,
    Sridhar

    there is a field in TableViewName-xxx
    don't remember the exact field name for (total no of records)
    you can check it in debug.  when you add records in Internal table, u need to modify this field which is set at the first time when table control is populated.

  • BDC Recording For J1IG with Table Control Scroll bar

    Dear Friends,
    I am doing BDC program for J1IG Transaction after done recording.
    As you knows that, In J1IG transaction max. 11 materials are shows in table control at a time and if more records are there, then we have to scroll down manually so after that, we can see the records.
    Now my BDC program runs upto 11 materials but when more than 11 materials, selection is coming on first material only and cursor not showing 12th material.
    So i think page down is not working for that issue.
    I have seen lots of search forum for that but not getting the proper answer.
    Please reply.
    Regards,
    Shivam.

    Dear Dinu,
    For better understanding please see the code.
    So you suggest what should i have to do?.
    LOOP AT jtab INTO wb.
         LOOP AT itab INTO wa WHERE mblnr EQ wb-mblnr.
           CLEAR : flag.
           AT NEW mblnr.
             flag = 'X'.
             CLEAR : cnt, var1, var2.
           ENDAT.
           cnt = cnt + 1.
           IF flag EQ 'X'.
             PERFORM bdc_dynpro      USING 'SAPMJ1IG' '0100'.
             PERFORM bdc_field       USING 'BDC_OKCODE'
                                       '=ECAP'.
             PERFORM bdc_dynpro      USING 'SAPMJ1IG' '0200'.
             PERFORM bdc_field       USING 'BDC_CURSOR'
                                       'T_HEADER-EXDAT'.
             PERFORM bdc_field       USING 'BDC_OKCODE'
                                       '/00'.
             PERFORM bdc_field       USING 'J_1IEXCHDR-EXGRP'
                                       wa-exgrp.
             PERFORM bdc_field       USING 'T_HEADER-MBLNR'
                                       wa-mblnr.
             PERFORM bdc_field       USING 'T_HEADER-MJAHR'
                                       wa-mjahr.
             PERFORM bdc_field       USING 'T_HEADER-EXNUM'
                                       wa-exnum.
             PERFORM bdc_field       USING 'T_HEADER-EXDAT'
                                       wa-exdat.
             PERFORM bdc_dynpro      USING 'SAPMJ1IG' '0200'.
             PERFORM bdc_field       USING 'BDC_CURSOR'
                                       'J_1IEXCHDR-EXGRP'.
             PERFORM bdc_field       USING 'BDC_OKCODE'
                                       '=DETL'.
           ENDIF.
           CONCATENATE 'T_ITEM-ZEILE(' cnt ')'  INTO var1.
           CONCATENATE 'T_ITEM-SELECTION(' cnt ')'  INTO var2.
           PERFORM bdc_dynpro      USING 'SAPMJ1IG' '0300'.
           PERFORM bdc_field       USING 'BDC_CURSOR'
                                     var1.           "'T_ITEM-ZEILE(01)'.
           PERFORM bdc_field       USING 'BDC_OKCODE'
                                     '=MORE'.
           PERFORM bdc_field       USING var2 "'T_ITEM-SELECTION(01)'
                                     'X'. "record-selection_01_019.
           PERFORM bdc_dynpro      USING 'SAPMJ1IG' '0400'.
           PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'T_LOCAL_EXC-EXADDRATE1(01)'.
           PERFORM bdc_field       USING 'BDC_OKCODE'
                                     '/00'.
           PERFORM bdc_field       USING 'T_LOCAL_EXC-MENGE(01)'
                                     wa-menge.
           PERFORM bdc_field       USING 'T_LOCAL_EXC-EXBAS(01)'
                                     wa-exbas.
           PERFORM bdc_field       USING 'T_LOCAL_EXC-EXBED(01)'
                                     wa-exbed.
           PERFORM bdc_field       USING 'T_LOCAL_EXC-BEDRATE(01)'
                                     wa-bedrate.
           PERFORM bdc_field       USING 'T_LOCAL_EXC-EXAED(01)'
                                     wa-exaed.
           PERFORM bdc_field       USING 'T_LOCAL_EXC-AEDRATE(01)'
                                     wa-aedrate.
           PERFORM bdc_field       USING 'T_LOCAL_EXC-ECS(01)'
                                     wa-ecs.
           PERFORM bdc_field       USING 'T_LOCAL_EXC-ECSRATE(01)'
                                     wa-ecsrate.
           PERFORM bdc_field       USING 'T_LOCAL_EXC-EXADDTAX1(01)'
                                     wa-exaddtax1.
           PERFORM bdc_field       USING 'T_LOCAL_EXC-EXADDRATE1(01)'
                                     wa-exaddrate1.
           PERFORM bdc_dynpro      USING 'SAPMJ1IG' '0400'.
           PERFORM bdc_field       USING 'BDC_CURSOR'
                                     'T_LOCAL_EXC-RG23ASER(01)'.
           PERFORM bdc_field       USING 'BDC_OKCODE'
                                     '=BACK'.
         ENDLOOP.
         PERFORM bdc_dynpro      USING 'SAPMJ1IG' '0300'.
         PERFORM bdc_field       USING 'BDC_CURSOR'
                                   'T_ITEM-DOCNO(01)'.
         PERFORM bdc_field       USING 'BDC_OKCODE'
                                   '=SAVE'.
         CLEAR opt.
         opt-dismode = 'A'.
         opt-updmode = 'S'.
    *    opt-defsize = '12'.
    *    CLEAR: it_messages[], it_messages.
         CALL TRANSACTION 'J1IG' USING it_bdcdata OPTIONS FROM opt
                                       MESSAGES INTO it_messages.
         REFRESH it_bdcdata.
       ENDLOOP.
       CHECK it_messages[] IS NOT INITIAL.
       LOOP AT it_messages.
         PERFORM fill_messages USING it_messages-msgtyp
                                     it_messages-msgid
                                     it_messages-msgnr
                                     it_messages-msgv1
                                     it_messages-msgv2
                                     it_messages-msgv3
                                     it_messages-msgv4.
       ENDLOOP.
       PERFORM display_messages TABLES tmsg.

  • Problem with Table control in BDC

    Hi Experts,
    I have dought regarding Table control i.e How to handle Table control in BDC? i need explanation for handling TC and senario for using T C in BDC?
      regards,
    Sudha.

    Hello,
    This is the bdc to update the XK01 transaction code (Vendor Creation).
    Here we will use table controls for bankings. Here Iam sending the coding and text files.
    Coding
    REPORT zprataptable2
           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.
    Intial screen data file.
    1     63190      0001     0001     0001     mr     bal188     b     in     31000     a1     inr
    2     63191      0001     0001     0001     mr     bal189     b     in     31000     a1     inr
    Table control Data:
    1     in     sb     11000
    1     in     sb     12000
    1     in     sb     13000
    1     in     sb     14000
    1     in     sb     15000
    1     in     sb     16000
    1     in     sb     17000
    1     in     sb     18000
    1     in     sb     19000
    1     in     sb     20000
    1     in     sb     21000
    1     in     sb     22000
    2     in     sb     21000
    2     in     sb     22000
    Thanks,
    Vasanth

  • 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

  • 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

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

Maybe you are looking for

  • HP Spectre X2 Replacemen​t screen

    Hello, Can anyone tell me if HP sells replacement screens for the HP Spectre x2 computer? I recognize that HP can repair the device, but find the $300 repair cost outrageous.

  • Lightning to Composite A/V

    Hi, all. We've recently purchased a 2014 Murano which has audio L/R jacks as well as a video jack (all RCA). I'd like to be able to pipe audio/video from my iPhone 5 into these. I've been poking around the web and TIL that it may be problematic unles

  • How to re-position scroll pane contents?

    I have a JSplitPane where the top half of the component contains a list of topics and the bottom half contains a scroll pane with a text area inside it. The user clicks a list item and the text for it is shown below it. The problems is when the text

  • Is the Upload to Server feature working in CS6 for Mac . . . or any of the export modules?

    Is the Upload to Server feature working in CS6 for Mac . . . or any of the export modules?

  • ACS 5.4 Access Policies Problem

    Hi Gents, I've been trying to troubleshoot this for a long time but I'm out of ideas now. here is the topo. I've got a Cisco ACS 5.4 VM used for Radius Network Authentication with a Cisco WLC 7.0, I've done the initial setup and all the rules, everyt