Skip to Content
0
Former Member
Nov 17, 2005 at 04:07 PM

Table control in sales order

577 Views

Hi,

I am using BDC to ceate salesorder.I am able to create sales order for one item. But when I try it for multiple items, it is still creating a new sales order for each item. I am trying to loop the items but still it is creating a new sales order.I am also attaching my code. Can somebody look into it and tell me what should be done to loop the items.

DATA: BEGIN OF ITAB OCCURS 0,

KUNNR1 LIKE KUAGV-KUNNR,

KUNNR2 LIKE KUWEV-KUNNR,

KETDAT LIKE RV45A-KETDAT,

DWERK LIKE RV45A-DWERK,

ZTERM LIKE VBKD-ZTERM,

INCO1 LIKE VBKD-INCO1,

INCO2 LIKE VBKD-INCO2,

AUDAT LIKE RV45A-KETDAT,

VKBUR LIKE VBAK-VKBUR,

BZIRK LIKE VBKD-BZIRK,

IHREZ LIKE VBKD-IHREZ,

MABNR LIKE RV45A-MABNR,

KWMENG LIKE RV45A-KWMENG,

END OF ITAB.

include bdcrecx1.

PARAMETERS: PATH(128) DEFAULT 'C:\sales.txt'.

start-of-selection.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = path

FILETYPE = 'DAT'

TABLES

DATA_TAB = ITAB

.

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

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'

itab-kunnr1.

perform bdc_field using 'KUWEV-KUNNR'

itab-kunnr2.

perform bdc_field using 'RV45A-KETDAT'

itab-ketdat.

perform bdc_field using 'RV45A-KPRGBZ'

'D'.

perform bdc_field using 'VBKD-PRSDT'

'11/17/2005'.

perform bdc_field using 'VBKD-ZTERM'

itab-zterm.

perform bdc_field using 'VBKD-INCO1'

ITAB-INCO1.

perform bdc_field using 'VBKD-INCO2'

ITAB-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'

ITAB-AUDAT.

perform bdc_field using 'VBAK-VKBUR'

ITAB-VKBUR.

perform bdc_field using 'VBAK-WAERK'

'USD'.

perform bdc_field using 'VBKD-PRSDT'

'11/17/2005'.

perform bdc_field using 'VBKD-BZIRK'

ITAB-BZIRK.

perform bdc_dynpro using 'SAPMV45A' '4002'.

perform bdc_field using 'BDC_OKCODE'

'=T\08'.

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\10'.

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\13'.

perform bdc_field using 'BDC_CURSOR'

'VBKD-BSARK'.

perform bdc_field using 'VBKD-BSARK'

'CU01'.

perform bdc_field using 'VBKD-IHREZ'

ITAB-IHREZ.

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'

itab-kunnr1.

perform bdc_field using 'KUWEV-KUNNR'

itab-kunnr2.

perform bdc_field using 'RV45A-KETDAT'

itab-ketdat.

perform bdc_field using 'RV45A-KPRGBZ'

'D'.

perform bdc_field using 'VBKD-PRSDT'

'11/17/2005'.

perform bdc_field using 'VBKD-ZTERM'

itab-zterm.

perform bdc_field using 'VBKD-INCO1'

ITAB-INCO1.

perform bdc_field using 'VBKD-INCO2'

ITAB-INCO2.

perform bdc_field using 'BDC_CURSOR'

'RV45A-CCODE(01)'.

perform bdc_field using 'RV45A-MABNR(01)'

ITAB-MABNR.

perform bdc_field using 'RV45A-KWMENG(01)'

'1'.

perform bdc_field using 'VBAP-WERKS(01)'

itab-dwerk.

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE'

'=PKO1'.

perform bdc_field using 'KUAGV-KUNNR'

itab-kunnr1.

perform bdc_field using 'KUWEV-KUNNR'

itab-kunnr2.

perform bdc_field using 'RV45A-KETDAT'

itab-ketdat.

perform bdc_field using 'RV45A-KPRGBZ'

'D'.

perform bdc_field using 'VBKD-PRSDT'

'11/17/2005'.

perform bdc_field using 'VBKD-ZTERM'

itab-zterm.

perform bdc_field using 'VBKD-INCO1'

ITAB-INCO1.

perform bdc_field using 'VBKD-INCO2'

ITAB-INCO2.

perform bdc_field using 'BDC_CURSOR'

'VBAP-POSNR(01)'.

perform bdc_field using 'RV45A-VBAP_SELKZ(01)'

'X'.

perform bdc_dynpro using 'SAPMV45A' '5003'.

perform bdc_field using 'BDC_OKCODE'

'/EBACK'.

Loop.

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE'

'=PKO1'.

perform bdc_field using 'KUAGV-KUNNR'

itab-kunnr1.

perform bdc_field using 'KUWEV-KUNNR'

itab-kunnr2.

perform bdc_field using 'RV45A-KETDAT'

itab-ketdat.

perform bdc_field using 'RV45A-KPRGBZ'

'D'.

perform bdc_field using 'VBKD-PRSDT'

'11/17/2005'.

perform bdc_field using 'VBKD-ZTERM'

itab-zterm.

perform bdc_field using 'VBKD-INCO1'

ITAB-INCO1.

perform bdc_field using 'VBKD-INCO2'

ITAB-INCO2.

perform bdc_field using 'BDC_CURSOR'

'RV45A-CCODE(02)'.

perform bdc_field using 'BDC_CURSOR'

'VBAP-WERKS(02)'.

perform bdc_field using 'RV45A-MABNR(02)'

ITAB-MABNR.

perform bdc_field using 'RV45A-KWMENG(02)'

'1'.

perform bdc_field using 'VBAP-WERKS(02)'

itab-dwerk.

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE'

'=PKO1'.

perform bdc_field using 'KUAGV-KUNNR'

itab-kunnr1.

perform bdc_field using 'KUWEV-KUNNR'

itab-kunnr2.

perform bdc_field using 'RV45A-KETDAT'

itab-ketdat.

perform bdc_field using 'RV45A-KPRGBZ'

'D'.

perform bdc_field using 'VBKD-PRSDT'

'11/17/2005'.

perform bdc_field using 'VBKD-ZTERM'

itab-zterm.

perform bdc_field using 'VBKD-INCO1'

ITAB-INCO1.

perform bdc_field using 'VBKD-INCO2'

ITAB-INCO2.

perform bdc_field using 'BDC_CURSOR'

'VBAP-POSNR(01)'.

perform bdc_field using 'RV45A-VBAP_SELKZ(01)'

'X'.

perform bdc_dynpro using 'SAPMV45A' '5003'.

perform bdc_field using 'BDC_OKCODE'

'/EBACK'.

endloop.

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE'

'=SICH'.

perform bdc_field using 'KUAGV-KUNNR'

itab-kunnr1.

perform bdc_field using 'KUWEV-KUNNR'

itab-kunnr2.

perform bdc_field using 'RV45A-KETDAT'

ITAB-KETDAT.

perform bdc_field using 'RV45A-KPRGBZ'

'D'.

perform bdc_field using 'VBKD-PRSDT'

'11/17/2005'.

perform bdc_field using 'VBKD-ZTERM'

ITAB-ZTERM.

perform bdc_field using 'VBKD-INCO1'

ITAB-INCO1.

perform bdc_field using 'VBKD-INCO2'

ITAB-INCO2.

  • perform bdc_field using 'BDC_CURSOR'

  • 'RV45A-MABNR(02)'.

perform bdc_transaction using 'VA01'.

endloop.

Perform close_group.