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: 

BAPI_SALESORDER_CREATEFROMDAT2 - not working for multiple BOM

Former Member
0 Kudos

Hi -

I am using BAPI_SALESORDER_CREATEFROMDAT2 function module to create sales order with multiple material. If more than one BOM materials are passed to the FM,this FM is giving error and not creating sales order. I have to pass multiple BOM to the FM and it should create sales order and expand the BOM to its components also.

Can anybody help on this.

An example will be good.

thanks

pls help

Edited by: sanchari g on May 13, 2009 11:05 AM

5 REPLIES 5

Former Member
0 Kudos

Hi,

We can achieve the above definitely through this FM,

The functionality would be like for a single customer for different materials ,it should create sales order.Am i Right?

So U give this FM in a loop where the header level will be of the customer and give input of multiple materials in itab and pass it to the BAPI_SALESORDER_CREATEFROMDAT2

The input should be of the following in the bapi:

loop1 at below

A)TO i_order_header_in.

1)doc_type = vbak-auart.

2)sales_org = vbak-vkorg.

3)distr_chan = vbak-vtweg.

4)division = vbak-spart.

5)purch_no_c = wa_sales_push1-po_no.(purchase order number)

B)TO i_order_partners.

1) sold to party/ship to party

LOOP2now loop at the below and append all the materials related to the above header purchase order number or sold to party(customer)

C)TO i_order_items_in.

1)material

2)quantity

3)batch.....etc

D) i_order_schedules_in.

1)Item number-check for this thing in particular.Item number will be important to disntiguish between multiple materials.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

  • SALESDOCUMENTIN =

order_header_in = i_order_header_in

ORDER_HEADER_INX = i_order_header_inx

IMPORTING

salesdocument = i_salesdocument

TABLES

return = i_return

order_items_in = i_order_items_in

  • ORDER_ITEMS_INX =

order_partners = i_order_partners

order_schedules_in = i_order_schedules_in

endloop

endloop

so by doin the above for single header level of customer(say),we have appened multiple materials and we are gping to pass into the bapi.

The key is ,pass the header level itab and corresponding item level multiple materials itab in one go.

Hope it is clear.If anything specfic,plz mention.i will reply.

Thanks,

SanthoshSivanathan

0 Kudos

Hi Santhos-

It is right that the customer is same.. But i need to create single sales order with multiple BOM and it should expand in the created sales order.

0 Kudos

Hi-

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

  • SALESDOCUMENTIN =

order_header_in = i_order_header_in

ORDER_HEADER_INX = i_order_header_inx

IMPORTING

salesdocument = i_salesdocument

TABLES

return = i_return

order_items_in = i_order_items_in

  • ORDER_ITEMS_INX =

order_partners = i_order_partners

order_schedules_in = i_order_schedules_in

If we pass item number for multiple BOM in i_order_items_in,at the time of expansion, in sales order item number will be changed and the function module will not work.

0 Kudos

Hi Sanchari,

Try the import parameter int_number_assignment.

If you put in an X SAP will number the positions for you.

Martijn

Former Member
0 Kudos

Hi Sanchari,

Try the following logic:

LOOP AT it_salesheader INTO wa_salesheader.

CLEAR wa_order_header_in.

CLEAR wa_order_header_inx.

CLEAR wa_order_partners.

CLEAR wa_bapicond.

CLEAR wa_bapicondx.

REFRESH it_order_items_in.

REFRESH it_order_items_inx.

REFRESH it_order_partners.

REFRESH it_order_schedules_in.

REFRESH it_order_schedules_inx.

REFRESH it_bapicond.

REFRESH it_bapicondx.

wa_order_header_in-doc_type = wa_salesheader-auart.

wa_order_header_in-sales_org = wa_salesheader-vkorg.

wa_order_header_in-distr_chan = wa_salesheader-vtweg.

wa_order_header_in-division = '00'.

wa_order_header_in-purch_no_c = wa_salesheader-bstnk.

wa_order_header_in-purch_date = wa_salesheader-bstdk.

wa_order_header_in-ref_1 = wa_salesheader-vbeln.

wa_order_header_in-price_date = wa_salesheader-prsdt.

LOOP AT it_salesitem INTO wa_salesitem WHERE vbeln = wa_salesheader-vbeln.

wa_order_items_in-itm_number = posnr_temp.

wa_order_items_in-material = wa_salesitem-matnr.

wa_order_items_in-plant = wa_salesitem-werks.

wa_order_items_in-target_qty = wa_salesitem-kwmeng.

wa_order_items_in-ref_doc = wa_salesitem-vbeln.

wa_order_items_in-ref_doc_it = wa_salesitem-posnr.

wa_order_items_in-ref_1_s = wa_salesitem-vbeln1.

wa_order_items_in-poitm_no_s = wa_salesitem-posnn.

APPEND wa_order_items_in TO it_order_items_in.

ENDLOOP. "loop for line item which contains all BOMs.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

order_header_in = wa_order_header_in

order_header_inx = wa_order_header_inx

  • testrun = testrun

IMPORTING

salesdocument = v_salesdocument

TABLES

return = it_return

order_items_in = it_order_items_in

order_items_inx = it_order_items_inx

order_partners = it_order_partners

order_schedules_in = it_order_schedules_in

order_schedules_inx = it_order_schedules_inx

order_conditions_in = it_bapicond.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

ENDLOOP. "loop for the header data.

Hope it helps.

Regards,

Arnab.