Skip to Content
0
Former Member
Nov 21, 2005 at 07:29 PM

Problem with table control

48 Views

Hi all,

I am able to loop two items for the sales order using table control.But I am not able to populate more than 2 items. Can anybody explain what exactly is the problem.

I am including my code below.

DATA: BEGIN OF ITAB OCCURS 0,

KUNNR(255) TYPE C,

END OF ITAB.

DATA :BEGIN OF ITAB1 OCCURS 0,

KUNNR1(10) TYPE C,

KUNNR2(10) TYPE C,

KETDAT(8) TYPE C,

DWERK(4) TYPE C,

ZTERM(4) TYPE C,

INCO1(3) TYPE C,

INCO2(16) TYPE C,

AUDAT(8) TYPE C,

VKBUR(4) TYPE C,

BZIRK(3) TYPE C,

END OF ITAB1.

DATA : BEGIN OF ITAB2 OCCURS 0,

KUNNR1(10) TYPE C,

MABNR(8) TYPE C,

KWMENG(1) TYPE C,

END OF ITAB2.

include bdcrecx1.

PARAMETERS PATH(128) DEFAULT 'C:\SALES1.TXT'.

DATA : FNAM(20) TYPE C,

IDX TYPE C.

start-of-selection.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = PATH

FILETYPE = 'ASC'

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT ITAB.

  • itab1-kunnr1 = itab2-kunnr1.

ITAB1-KUNNR1 = ITAB-KUNNR+0(10).

ITAB1-KUNNR2 = ITAB-KUNNR+10(10).

ITAB1-KETDAT = ITAB-KUNNR+20(8).

ITAB1-DWERK = ITAB-KUNNR+28(4).

ITAB1-ZTERM = ITAB-KUNNR+32(4).

ITAB1-INCO1 = ITAB-KUNNR+36(3).

ITAB1-INCO2 = ITAB-KUNNR+39(16).

ITAB1-AUDAT = ITAB-KUNNR+55(8).

ITAB1-VKBUR = ITAB-KUNNR+63(4).

ITAB1-BZIRK = ITAB-KUNNR+67(3).

  • ITAB2-KUNNR1 = ITAB-KUNNR+0(10).

ITAB2-MABNR = ITAB-KUNNR+70(8).

ITAB2-KWMENG = ITAB-KUNNR+78(1).

APPEND ITAB1.

CLEAR ITAB1.

APPEND ITAB2.

CLEAR ITAB2.

ENDLOOP.

perform open_group.

loop at itab1.

perform bdc_dynpro using 'SAPMV45A' '0101'.

perform bdc_field using 'BDC_CURSOR'

'VBAK-AUART'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'VBAK-AUART'

'ZOR'.

perform bdc_field using 'VBAK-VKORG'

'1000'.

perform bdc_field using 'VBAK-VTWEG'

'10'.

perform bdc_field using 'VBAK-SPART'

'10'.

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE'

'KKAU'.

perform bdc_field using 'KUAGV-KUNNR'

itab1-kunnr1.

perform bdc_field using 'KUWEV-KUNNR'

itab1-kunnr2.

perform bdc_field using 'RV45A-KETDAT'

itab1-ketdat.

perform bdc_field using 'RV45A-KPRGBZ'

'D'.

perform bdc_field using 'VBKD-PRSDT'

'11/21/2005'.

perform bdc_field using 'VBKD-ZTERM'

itab1-zterm.

perform bdc_field using 'VBKD-INCO1'

ITAB1-INCO1.

perform bdc_field using 'VBKD-INCO2'

ITAB1-INCO2.

perform bdc_dynpro using 'SAPMV45A' '4002'.

perform bdc_field using 'BDC_OKCODE'

'=T\05'.

perform bdc_field using 'BDC_CURSOR'

'VBKD-BZIRK'.

perform bdc_field using 'VBAK-AUDAT'

ITAB1-AUDAT.

perform bdc_field using 'VBAK-VKBUR'

ITAB1-VKBUR.

perform bdc_field using 'VBAK-WAERK'

'USD'.

perform bdc_field using 'VBKD-PRSDT'

'11/21/2005'.

perform bdc_field using 'VBKD-BZIRK'

ITAB1-BZIRK.

perform bdc_dynpro using 'SAPLV60F' '4001'.

perform bdc_field using 'BDC_OKCODE'

'=T\06'.

perform bdc_field using 'BDC_CURSOR'

'FPLT-AFDAT(05)'.

perform bdc_field using 'FPLA-BEDAT'

'11/21/2005'.

perform bdc_field using 'FPLA-BEDAR'

'01'.

perform bdc_field using 'FPLA-RFPLN'

'0000000042'.

perform bdc_field using 'FPLT-AFDAT(01)'

'11/21/2005'.

perform bdc_field using 'FPLT-AFDAT(02)'

'11/21/2005'.

perform bdc_field using 'FPLT-AFDAT(03)'

'11/21/2005'.

perform bdc_field using 'FPLT-AFDAT(04)'

'11/21/2005'.

perform bdc_field using 'FPLT-AFDAT(05)'

'11/21/2005'.

perform bdc_dynpro using 'SAPMV45A' '4002'.

perform bdc_field using 'BDC_OKCODE'

'=T\09'.

perform bdc_field using 'BDC_CURSOR'

'VBKD-ZLSCH'.

perform bdc_field using 'VBKD-KTGRD'

'01'.

perform bdc_field using 'VBKD-ZLSCH'

'C'.

perform bdc_field using 'VBAK-ZUONR'

'Open Sales order'.

perform bdc_dynpro using 'SAPMV45A' '4002'.

perform bdc_field using 'BDC_OKCODE'

'=T\11'.

perform bdc_field using 'BDC_CURSOR'

'GVS_TC_DATA-REC-PARTNER(05)'.

perform bdc_field using 'GV_FILTER'

'PARALL'.

perform bdc_field using 'GVS_TC_DATA-REC-PARTNER(05)'

'3838'.

perform bdc_dynpro using 'SAPMV45A' '4002'.

perform bdc_field using 'BDC_OKCODE'

'=T\14'.

perform bdc_field using 'BDC_CURSOR'

'VBKD-BSARK'.

perform bdc_field using 'VBKD-BSARK'

'CU01'.

perform bdc_field using 'VBKD-IHREZ'

'12134'.

perform bdc_dynpro using 'SAPMV45A' '4002'.

perform bdc_field using 'BDC_OKCODE'

'/EBACK'.

perform bdc_field using 'BDC_CURSOR'

'VBAK-ZZLEAT'.

perform bdc_field using 'VBAK-ZZWARR'

'12346C'.

perform bdc_field using 'VBAK-ZZFABW'

'F14689'.

perform bdc_field using 'VBAK-ZZWARX'

'12012005'.

perform bdc_field using 'VBAK-ZZLEAT'

'CGUYFIU'.

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE'

'=PKO1'.

perform bdc_field using 'KUAGV-KUNNR'

itab1-kunnr1.

perform bdc_field using 'KUWEV-KUNNR'

itab1-kunnr2.

perform bdc_field using 'RV45A-KETDAT'

itab1-ketdat.

perform bdc_field using 'RV45A-KPRGBZ'

'D'.

perform bdc_field using 'VBKD-PRSDT'

'11/21/2005'.

perform bdc_field using 'VBKD-ZTERM'

itab1-zterm.

perform bdc_field using 'VBKD-INCO1'

ITAB1-INCO1.

perform bdc_field using 'VBKD-INCO2'

ITAB1-INCO2.

perform bdc_field using 'BDC_CURSOR'

'RV45A-ccode(idx)'.

MOVE 1 TO IDX.

LOOP AT ITAB2 WHERE KUNNR1 = ITAB2-KUNNR1.

CONCATENATE 'RV45A-MABNR(' IDX ')' INTO FNAM.

perform bdc_field using FNAM

ITAB2-MABNR.

CONCATENATE 'RV45A-KWMENG(' IDX ')' INTO FNAM.

perform bdc_field using FNAM

ITAB2-KWMENG.

IDX = IDX + 1.

ENDLOOP.

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE'

'=PKO1'.

perform bdc_field using 'KUAGV-KUNNR'

itab1-kunnr1.

perform bdc_field using 'KUWEV-KUNNR'

itab1-kunnr2.

perform bdc_field using 'RV45A-KETDAT'

itab1-ketdat.

perform bdc_field using 'RV45A-KPRGBZ'

'D'.

perform bdc_field using 'VBKD-PRSDT'

'11/21/2005'.

perform bdc_field using 'VBKD-ZTERM'

itab1-zterm.

perform bdc_field using 'VBKD-INCO1'

ITAB1-INCO1.

perform bdc_field using 'VBKD-INCO2'

ITAB1-INCO2.

perform bdc_field using 'RV45A-VBAP_SELKZ(01)'

'X'.

perform bdc_dynpro using 'SAPMV45A' '5003'.

perform bdc_field using 'BDC_OKCODE'

'/EBACK'.

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE'

'=SICH'.

perform bdc_field using 'KUAGV-KUNNR'

itab1-kunnr1.

perform bdc_field using 'KUWEV-KUNNR'

itab1-kunnr2.

perform bdc_field using 'RV45A-KETDAT'

ITAB1-KETDAT.

perform bdc_field using 'RV45A-KPRGBZ'

'D'.

perform bdc_field using 'VBKD-PRSDT'

'11/21/2005'.

perform bdc_field using 'VBKD-ZTERM'

ITAB1-ZTERM.

perform bdc_field using 'VBKD-INCO1'

ITAB1-INCO1.

perform bdc_field using 'VBKD-INCO2'

ITAB1-INCO2.

perform bdc_field using 'BDC_CURSOR'

'RV45A-MABNR(idx)'.

perform bdc_transaction using 'VA01'.

endloop.

Perform close_group.