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

Former Member
0 Kudos

HI Gurus,

I am trying to upload transactional data for tcode Va01,that is sales order. During the recording I give the value of sold to party or PO number only once but when I generate a program of the recording the values get repeated and I see in the subroutines that each value is there atleast twice. In the program, I created and internal table and then gave the internal table fields in the place of the values in the perform fields and created a loop for the table. When I execute the program, only once the values from the flat file are taken and the others agian old values. I am attaching the program also:

report ZSALES_BDC

no standard page heading line-size 255.

include bdcrecx1.

data:begin of itab occurs 1,

auart(4) type c,

vkorg(4) type c,

vtweg(2) type c,

spart(2) type c,

bstkd(35) type c,

kunnr(10) type c,

mabnr(18) type c,

kwmeng(15) type c,

kschl(4) type c,

kbetr(11) type c,

pspnr(8) type c,

end of itab.

start-of-selection.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'D:\zsales_bdc.txt'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = ITAB

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

perform bdc_dynpro using 'SAPMV45A' '0101'.

perform bdc_field using 'BDC_CURSOR'

'VBAK-SPART'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'VBAK-AUART'

ITAB-AUART.

perform bdc_field using 'VBAK-VKORG'

ITAB-VKORG.

perform bdc_field using 'VBAK-VTWEG'

ITAB-VTWEG.

perform bdc_field using 'VBAK-SPART'

ITAB-SPART.

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'VBKD-BSTKD'

ITAB-BSTKD.

perform bdc_field using 'KUAGV-KUNNR'

ITAB-KUNNR.

perform bdc_field using 'RV45A-KETDAT'

'06/03/2008'.

perform bdc_field using 'RV45A-KPRGBZ'

'D'.

perform bdc_field using 'VBKD-PRSDT'

'06/03/2008'.

perform bdc_field using 'BDC_CURSOR'

'RV45A-KWMENG(01)'.

perform bdc_field using 'RV45A-MABNR(01)'

ITAB-MABNR.

perform bdc_field using 'RV45A-KWMENG(01)'

ITAB-KWMENG.

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE'

'=PKO1'.

perform bdc_field using 'VBKD-BSTKD'

'1234321'.

perform bdc_field using 'KUAGV-KUNNR'

'20000'.

perform bdc_field using 'KUWEV-KUNNR'

'20000'.

perform bdc_field using 'RV45A-KETDAT'

'06/03/2008'.

perform bdc_field using 'RV45A-KPRGBZ'

'D'.

perform bdc_field using 'VBKD-PRSDT'

'06/03/2008'.

perform bdc_field using 'VBKD-ZTERM'

'N45'.

perform bdc_field using 'VBKD-INCO1'

'FOB'.

perform bdc_field using 'VBKD-INCO2'

'New York'.

perform bdc_field using 'BDC_CURSOR'

'RV45A-MABNR(02)'.

perform bdc_dynpro using 'SAPMV45A' '5003'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'KOMV-KBETR(07)'.

perform bdc_field using 'KOMV-KSCHL(07)'

ITAB-KSCHL.

perform bdc_field using 'KOMV-KBETR(07)'

ITAB-KBETR.

perform bdc_dynpro using 'SAPMV45A' '5003'.

perform bdc_field using 'BDC_OKCODE'

'=T\05'.

perform bdc_field using 'BDC_CURSOR'

'KOMV-KSCHL(08)'.

perform bdc_dynpro using 'SAPLCNMS' '1300'.

perform bdc_field using 'BDC_CURSOR'

'MLSTS-PSPNR'.

perform bdc_field using 'BDC_OKCODE'

'=GO'.

perform bdc_field using 'MLSTS-SELNW'

''.

perform bdc_field using 'MLSTS-SELPS'

'X'.

perform bdc_field using 'MLSTS-PSPNR'

ITAB-PSPNR.

perform bdc_dynpro using 'SAPLCNMS' '1310'.

perform bdc_field using 'BDC_CURSOR'

'MSTSD-TEDAT(03)'.

perform bdc_field using 'BDC_OKCODE'

'=GET'.

perform bdc_field using 'SCROLL_TAB-MARK(01)'

'X'.

perform bdc_field using 'SCROLL_TAB-MARK(02)'

'X'.

perform bdc_field using 'SCROLL_TAB-MARK(03)'

'X'.

perform bdc_dynpro using 'SAPLV60F' '4001'.

perform bdc_field using 'BDC_OKCODE'

'=S\BACK'.

perform bdc_field using 'BDC_CURSOR'

'FPLA-BEDAT'.

perform bdc_field using 'FPLA-BEDAT'

'06/03/2008'.

perform bdc_field using 'FPLA-BEDAR'

'07'.

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE'

'=SICH'.

perform bdc_field using 'VBKD-BSTKD'

'1234321'.

perform bdc_field using 'KUAGV-KUNNR'

'20000'.

perform bdc_field using 'KUWEV-KUNNR'

'20000'.

perform bdc_field using 'RV45A-KETDAT'

'06/03/2008'.

perform bdc_field using 'RV45A-KPRGBZ'

'D'.

perform bdc_field using 'VBKD-PRSDT'

'06/03/2008'.

perform bdc_field using 'VBKD-ZTERM'

'N45'.

perform bdc_field using 'VBKD-INCO1'

'FOB'.

perform bdc_field using 'VBKD-INCO2'

'New York'.

perform bdc_field using 'BDC_CURSOR'

'RV45A-MABNR(02)'.

perform bdc_transaction using 'VA01'.

ENDLOOP.

perform close_group.

As you can see in the program I gave the internal table fields only for some perform fields. But why is the same value repeating so many times and should I give the value in the flat file every single time?

Thanks and Regards,

Vishwa.

1 REPLY 1

Former Member
0 Kudos

You should use BAPI_SALESORDER_CREATEFROMDAT2 to create sales orders instead of the BDC method.