Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BDC Table control

Former Member
0 Kudos

Hi All,

i am posting this question after searching the scn blog.

i am using BDC for ME31K t-code. and in the last screen has table control. due to this only 17 entries are getting posted and then i get an error message saying the screen size is not enough. I used the concatenate index for the entries and also =P+. still my code isn't working. Please Help!.

I am pasting the code for your reference. please help me find where am i going wrong.

LOOP AT it_contract INTO wa_contract.


       IF wa_contract-lifnr IS INITIAL.
         if v_no gt 17.
           perform bdc_dynpro using 'SAPMM06E' '220'.
           PERFORM bdc_field USING 'BDC_CURSOR'
                                         'RM06E-EBELP'.
           PERFORM bdc_field USING 'BDC_OKCODE' '=P+'.
           CLEAR v_no.
           v_no = 1.
           endif.

         CONCATENATE 'EKPO-NETPR(' v_no ')' INTO v_fld.
         CONDENSE v_fld.
*
         PERFORM bdc_field       USING 'BDC_CURSOR'
                                         v_fld.
         CONCATENATE 'EKPO-EMATN(' v_no ')' INTO v_fld.
         CONDENSE v_fld.

*perform bdc_field1       using      V_FLD
*                              INFO_UPLOAD-KSCHL.
*perform bdc_field       using 'BDC_CURSOR'
*                                    'EKPO-NETPR(01)'.
         PERFORM bdc_field       USING v_fld
                                            wa_contract-ematn.
         CONCATENATE 'EKPO-KTMNG(' v_no ')' INTO v_fld.
         CONDENSE v_fld.
         PERFORM bdc_field       USING v_fld

                                            wa_contract-ktmng.
         CONCATENATE 'EKPO-NETPR(' v_no ')' INTO v_fld.
         CONDENSE v_fld.
         PERFORM bdc_field       USING v_fld
                                       wa_contract-netpr.
         v_no = v_no + 1.

         first = 'X'.

       ELSE.

         IF first = 'X'.
*last record to upload

           PERFORM bdc_dynpro      USING 'SAPLEKPA' '0102'.
           PERFORM bdc_field       USING 'BDC_CURSOR'
                                         'MMPA-EKORG(01)'.
           PERFORM bdc_field       USING 'BDC_OKCODE'
                                         '=DISL'.
           PERFORM bdc_field       USING 'RM06E-SELKZ(01)'
                                         'X'.
           PERFORM bdc_dynpro      USING 'SAPLEKPA' '0101'.
           PERFORM bdc_field       USING 'BDC_CURSOR'
                                         'WRF02K-GPARN(01)'.
           PERFORM bdc_field       USING 'BDC_OKCODE'
                                         '=BACK'.
           PERFORM bdc_field       USING 'MMPA-PARVW(02)'
                                         pre_parvw.
           PERFORM bdc_field       USING 'WRF02K-GPARN(02)'
                                         pre_gparn.
           PERFORM bdc_dynpro      USING 'SAPLEKPA' '0102'.
           PERFORM bdc_field       USING 'BDC_CURSOR'
                                         'MMPA-EKORG(01)'.
           PERFORM bdc_field       USING 'BDC_OKCODE'
                                         '=BACK'.
           PERFORM bdc_field       USING 'RM06E-SELKZ(01)'
                                         'X'.
           PERFORM bdc_dynpro      USING 'SAPMM06E' '0220'.
           PERFORM bdc_field       USING 'BDC_CURSOR'
                                         'RM06E-EBELP'.
           PERFORM bdc_field       USING 'BDC_OKCODE'
                                         '=BU'.
*perform bdc_field       using 'RM06E-EBELP'
*                              '10'.
           PERFORM bdc_dynpro      USING 'SAPLSPO1' '0300'.
           PERFORM bdc_field       USING 'BDC_OKCODE'
                                         '=YES'.
           PERFORM bdc_transaction USING 'ME31K'.

         ENDIF.
* first record for new vendor
         PERFORM bdc_dynpro      USING 'SAPMM06E' '0200'.
         PERFORM bdc_field       USING 'BDC_CURSOR'
                                       'RM06E-WERKS'.
         PERFORM bdc_field       USING 'BDC_OKCODE'
                                       '/00'.
         PERFORM bdc_field       USING 'EKKO-LIFNR'
                                       wa_contract-lifnr.

         PERFORM bdc_field       USING 'RM06E-EVART'
                                       wa_contract-evart.


         PERFORM bdc_field       USING 'RM06E-VEDAT'
                                       wa_contract-vedat.
         PERFORM bdc_field       USING 'EKKO-EKORG'
                                       wa_contract-ekorg.
         PERFORM bdc_field       USING 'EKKO-EKGRP'
                                       wa_contract-ekgrp.
         PERFORM bdc_field       USING 'RM06E-WERKS'
                                       wa_contract-werks.
         PERFORM bdc_dynpro      USING 'SAPMM06E' '0201'.
         PERFORM bdc_field       USING 'BDC_CURSOR'
                                       'EKKO-INCO2'.
         PERFORM bdc_field       USING 'BDC_OKCODE'
                                       '/00'.
         PERFORM bdc_field       USING 'EKKO-EKGRP'
                                       wa_contract-ekgrp.
*perform bdc_field       using 'EKKO-PINCR'
*                              wa_contract-.
*perform bdc_field       using 'EKKO-UPINC'
*                              '1'.
         year wa_contract-kdatb+0(4).
         month wa_contract-kdatb+4(2).
         day wa_contract-kdatb+6(2).

         CLEAR: year, month, day.
         PERFORM bdc_field       USING 'EKKO-KDATB'
                                       wa_contract-kdatb.

         year wa_contract-kdate+0(4).
         month wa_contract-kdate+4(2).
         day wa_contract-kdate+6(2).


         CLEAR: year, month, day.
         PERFORM bdc_field       USING 'EKKO-KDATE'
                                       wa_contract-kdate.
*perform bdc_field       using 'EKKO-SPRAS'
*                              'EN'.
         PERFORM bdc_field       USING 'EKKO-ZTERM'
                                       wa_contract-zterm.
         PERFORM bdc_field       USING 'EKKO-KTWRT'
                                       wa_contract-ktwrt.
         PERFORM bdc_field       USING 'EKKO-WAERS'
                                       wa_contract-waers.
*perform bdc_field       using 'EKKO-WKURS'
*                              '/1.96050'.
         PERFORM bdc_field       USING 'EKKO-INCO1'
                                       wa_contract-inco1.
         PERFORM bdc_field       USING 'EKKO-INCO2'
                                       wa_contract-inco2.
         PERFORM bdc_dynpro      USING 'SAPMM06E' '0220'.

*for multiple records

         PERFORM bdc_field       USING 'BDC_CURSOR'
                                       'EKPO-NETPR(01)'.
         PERFORM bdc_field       USING 'BDC_OKCODE'
                                       '=PRTN'.

         PERFORM bdc_field       USING 'EKPO-EMATN(01)'
                                       wa_contract-ematn.
         PERFORM bdc_field       USING 'EKPO-KTMNG(01)'
                                       wa_contract-ktmng.
         PERFORM bdc_field       USING 'EKPO-NETPR(01)'
                                       wa_contract-netpr.
         first = 'X'.
         pre_parvw = wa_contract-parvw.
         pre_gparn = wa_contract-gparn.
         v_no = 2"
       ENDIF.

     ENDLOOP.

*it is for last record upload
     PERFORM bdc_dynpro      USING 'SAPLEKPA' '0102'.
     PERFORM bdc_field       USING 'BDC_CURSOR'
                                   'MMPA-EKORG(01)'.
     PERFORM bdc_field       USING 'BDC_OKCODE'
                                   '=DISL'.
     PERFORM bdc_field       USING 'RM06E-SELKZ(01)'
                                   'X'.
     PERFORM bdc_dynpro      USING 'SAPLEKPA' '0101'.
     PERFORM bdc_field       USING 'BDC_CURSOR'
                                   'WRF02K-GPARN(01)'.
     PERFORM bdc_field       USING 'BDC_OKCODE'
                                   '=BACK'.
     PERFORM bdc_field       USING 'MMPA-PARVW(02)'
                                   pre_parvw.
     PERFORM bdc_field       USING 'WRF02K-GPARN(02)'
                                   pre_gparn.
     PERFORM bdc_dynpro      USING 'SAPLEKPA' '0102'.
     PERFORM bdc_field       USING 'BDC_CURSOR'
                                   'MMPA-EKORG(01)'.
     PERFORM bdc_field       USING 'BDC_OKCODE'
                                   '=BACK'.
     PERFORM bdc_field       USING 'RM06E-SELKZ(01)'
                                   'X'.
     PERFORM bdc_dynpro      USING 'SAPMM06E' '0220'.
     PERFORM bdc_field       USING 'BDC_CURSOR'
                                   'RM06E-EBELP'.
     PERFORM bdc_field       USING 'BDC_OKCODE'
                                   '=BU'.
*perform bdc_field       using 'RM06E-EBELP'
*                              '10'.
     PERFORM bdc_dynpro      USING 'SAPLSPO1' '0300'.
     PERFORM bdc_field       USING 'BDC_OKCODE'
                                   '=YES'.
     PERFORM bdc_transaction USING 'ME31K'.

     PERFORM close_group.


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 <> NODATA.
     CLEAR BDCDATA.
     BDCDATA-FNAM = FNAM.
     BDCDATA-FVAL = FVAL.
     APPEND BDCDATA.
   ENDIF.
ENDFORM.

9 REPLIES 9

Former Member
0 Kudos

Hi lavanya,

   This problem is may be due to the screen resolution effect.

Dont use Page up/ page down for BDC with table control.

Table Control in BDC depends on screen resolution and if its run from terminal of smaller resolution it will have less number of lines displayed on screen than your desktop.

The BDC is sure to fail there then. Instead in the call transaction use option option-defsize = 'X'. You dont have to code for page up/ page down then and it will be automatically taken care of.

Syntex:

Call transaction using bdcdata options from ctu_params.

Thank You

Best of luck

0 Kudos

hi Dey,

thanks for your respose. i changed the code as suggested and now its working. Thanks!!

0 Kudos

Dey,

contract is now getting created without any errors but when i view the contract it just has 15 line items. i had uploaded 18 items. so the BDC table control  is still not working.

Former Member
0 Kudos

Instead of BDC, you might want to try a BAPI instead - see BAPI_CONTRACT_CREATE or BAPI_CONTRACT_CREATEFROMDATA.

But if you must use batch input, your best option is not to use page up or down, but to use the position button at the bottom of the screen. That will automatically bring that item to the top and you simply fill in the next item.

Rob

0 Kudos

Hi Rob,

BDC program is already existing and i just need to enhance the program for table control. and there is no position button as you suggested.

0 Kudos

Excuse me - it is the "Item" field (RM06E-EBELP on screen 220).

Rob

Message was edited by: Rob Burbank

Former Member
0 Kudos

Hi Lavanya,

       you can try table control and ctu_params at the same time. Check the logic of table control again that you written.

Thanks

Former Member
0 Kudos

Hi lavanya,

You need to repeat the recording with 'Default Size' Check box checked.

Former Member
0 Kudos

Hi Lavanya,

For BTCI in Table-Controls always use this procedure:

Loop at Itab.

  IF sy-tabix = 1. "first line

*Fill all the Dynpros before the table control

*     fill first line of the table control

    EKPO-EMATN(01) = ITAB-MATERIAL.

    EKPO-NETPR(01) = ITAB-PRICE.

    ...

*Press Button 'New Lines'

    BDC_OKCODE =    '=NP'.

  else. "sy-tabix >1, line 2,3,4,5,...

*Fill always line 2 in the control (maybe line 1, depending on transaction)

    EKPO-EMATN(02) = ITAB-MATERIAL

    EKPO-NETPR(02) = ITAB-PRICE.

   ...

*Press Button 'New Lines'

    BDC_OKCODE =    '=NP'.

endif.

endloop.

*Fill all the Dynpros after the table control

*Press Save-Button

BDC_OKCODE =     '=BU'.

Hope this will solve your problem!

Best regards

Alfons