Application Development and Automation 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: 
Read only

BDC code to create sales order

Former Member
0 Likes
2,173

Hi.

i have to create BDC program to create seles order (cutover data to upload) for multiple line itels in a single order...how to do this?

if any one have program please send me on rajesh2575@rediffmail.com.

Thanks.

5 REPLIES 5
Read only

Former Member
0 Likes
974

Hi

U can use the BAPI BAPI_SALESORDER_CREATEFROMDAT2

Max

Read only

Former Member
0 Likes
974

Hi Puru,

this is the code which creates a sales order but iam using a file to take the data.

PARAMETERS: p_infile LIKE rlgrap-filename OBLIGATORY.

INCLUDE bdcrecx1.

DATA: qty(19) TYPE c,

efile TYPE string.

DATA: BEGIN OF record OCCURS 0,

auart LIKE vbak-auart,

kunnr LIKE vbak-kunnr,

zterm LIKE vbkd-zterm,

vkorg LIKE vbak-vkorg,

vtweg LIKE vbak-vtweg,

spart LIKE vbak-spart,

matnr LIKE vbap-matnr,

kwmeng LIKE vbap-kwmeng,

END OF record.

DATA: BEGIN OF irecord OCCURS 0,

kunnr LIKE vbak-kunnr,

zterm LIKE vbkd-zterm,

matnr LIKE vbap-matnr,

kwmeng LIKE vbap-kwmeng,

END OF irecord.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_filename = p_infile

mask = ',*.txt.'

  • mode = 'O'

title = 'Upload File'

IMPORTING

filename = p_infile

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

START-OF-SELECTION.

efile = p_infile.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = efile

filetype = 'ASC'

has_field_separator = 'X'

TABLES

data_tab = record

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.

LOOP AT record.

irecord-kunnr = record-kunnr.

irecord-zterm = record-zterm.

irecord-matnr = record-matnr.

irecord-kwmeng = record-kwmeng.

APPEND irecord.

ENDLOOP.

LOOP AT record.

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'

record-auart.

PERFORM bdc_field USING 'VBAK-VKORG'

record-vkorg.

PERFORM bdc_field USING 'VBAK-VTWEG'

record-vtweg.

PERFORM bdc_field USING 'VBAK-SPART'

record-spart.

LOOP AT irecord.

PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

      • PERFORM bdc_field USING 'BDC_CURSOR'

      • 'KUAGV-KUNNR'.

      • PERFORM bdc_field USING 'KUAGV-KUNNR'

      • record-kunnr.

  • PERFORM bdc_field USING 'KUAGV-KUNNR'

  • record-kunnr.

  • PERFORM bdc_field USING 'KUWEV-KUNNR'

  • record-kunnr.

  • PERFORM bdc_field USING 'VBKD-ZTERM'

  • record-zterm.

PERFORM bdc_field USING 'KUAGV-KUNNR'

irecord-kunnr.

PERFORM bdc_field USING 'KUWEV-KUNNR'

irecord-kunnr.

PERFORM bdc_field USING 'VBKD-ZTERM'

irecord-zterm.

PERFORM bdc_field USING 'BDC_CURSOR'

'VBAP-MATNR(01)'.

PERFORM bdc_field USING 'VBAP-MATNR(01)'

irecord-matnr.

PERFORM bdc_field USING 'BDC_CURSOR'

'RV45A-KWMENG(01)'.

qty = irecord-kwmeng.

PERFORM bdc_field USING 'RV45A-KWMENG(01)'

qty.

PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

ENDLOOP.

PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=SICH'.

PERFORM bdc_transaction USING 'VA01'.

ENDLOOP.

Hope this wud help u.

Regds,

Seema.

Read only

0 Likes
974

Hi...

Actually i want for multiple line items in single sales order.

thanks.

Read only

0 Likes
974

Hi again,

I knw u need multiple records i have created this code fot tht only n the contents of the file are-

CPF1 1320 ZB01 1000 10 00 P-101 3

CPF1 1320 ZB01 1000 10 00 P-102 2

CPF1 1320 ZB01 1000 10 00 P-103 1

CPF1 1320 ZB01 1000 10 00 P-104 3

CPF1 1320 ZB01 1000 10 00 P-106 2

CPF1 1320 ZB01 1000 10 00 P-112 1

CPF1 1320 ZB01 1000 10 00 P-100 3

CPF1 1320 ZB01 1000 10 00 P-113 2

CPF1 1320 ZB01 1000 10 00 P-109 1

Hope this wud help u.

Regds,

Seema.

Read only

0 Likes
974

hi seema

i read ur reply that u have given for that creation of slaes order,

i also have some similar problem.i need to create sales orders in which there are multiple line items and for the multiple line items there are again multiple schedule line items.but there are some fields like the schedule line items, in which we are using grids, that are not there,

how can i code this to make things work