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

sales order creation using bapi

Former Member
0 Likes
495

Hi ,

I want to create a sales order using bapi BAPI_SALESORDER_CREATEFROMDAT2.

I have created a program but its giving some errors (like please mention either sold to party or ship to party , and sales order was not <b>Changed</b>) .

can any body provide some code which is creating sales order successfully.

Regards,

sandeep.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
465

Hello,

In the Item table being passed into the BAPI...

You need to fill

<b> ORDER_PARTNERS..: PARTN_ROLE Partner role, SP sold-to party

PARTN_NUMB Customer number</b>

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
ORDER_HEADER_IN = hdr
convert = 'X'
IMPORTING
SALESDOCUMENT = salesdoc
TABLES
return = ret_tbl
ORDER_ITEMS_IN = itm
ORDER_PARTNERS = prtnr
ORDER_ITEMS_inx = itmx
ORDER_CONDITIONS_IN = conds
ORDER_CONDITIONS_INX = condsx
order_schedules_in = schd_lin.

Make sure that you fill in:

* Assigning ref doc to create line item entries in VBFA.
itm-REF_DOC = i_vakgu-vbeln. "ref doc
itm-REF_DOC_IT = i_vbap-posnr. "line item of ref doc
itm-REF_DOC_CA = 'B'. "doc type of ref doc

Reward points accordingly.

Vasanth

3 REPLIES 3
Read only

Former Member
0 Likes
466

Hello,

In the Item table being passed into the BAPI...

You need to fill

<b> ORDER_PARTNERS..: PARTN_ROLE Partner role, SP sold-to party

PARTN_NUMB Customer number</b>

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
ORDER_HEADER_IN = hdr
convert = 'X'
IMPORTING
SALESDOCUMENT = salesdoc
TABLES
return = ret_tbl
ORDER_ITEMS_IN = itm
ORDER_PARTNERS = prtnr
ORDER_ITEMS_inx = itmx
ORDER_CONDITIONS_IN = conds
ORDER_CONDITIONS_INX = condsx
order_schedules_in = schd_lin.

Make sure that you fill in:

* Assigning ref doc to create line item entries in VBFA.
itm-REF_DOC = i_vakgu-vbeln. "ref doc
itm-REF_DOC_IT = i_vbap-posnr. "line item of ref doc
itm-REF_DOC_CA = 'B'. "doc type of ref doc

Reward points accordingly.

Vasanth

Read only

Former Member
0 Likes
465

I'm sure lots of people can supply code that works.

But then they would be doing YOUR job. You need to work through the documentation of the function module and speak to a functional person who can help you get the data set up correctly to create an order.

As a start, try creating a sales order in VA01 and write down the data that you used, then transfer this to a test case in SE37 and once that works transfer it to your program.

Gareth.

Read only

Former Member
0 Likes
465

//like please mention either sold to party or ship to party

error will be the customer number which from ur code might not be a valid one for the particular sales area.

see in order to rectify this error fetch the suitable customer for the sales area you are using .

search for the customer in table KNVV

KUNNR

VKORG

VTWEG

SPART

regards,

vijay