Skip to Content
author's profile photo Former Member
Former Member

BAPI_SALESORDER_CREATEFROMDAT2 - not working for multiple BOM

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.


pls help

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on May 13, 2009 at 11:01 AM


    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.




    D) i_order_schedules_in.

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




    order_header_in = i_order_header_in

    ORDER_HEADER_INX = i_order_header_inx


    salesdocument = i_salesdocument


    return = i_return

    order_items_in = i_order_items_in


    order_partners = i_order_partners

    order_schedules_in = i_order_schedules_in



    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.



    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 13, 2009 at 11:23 AM

    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.



    order_header_in = wa_order_header_in

    order_header_inx = wa_order_header_inx

    • testrun = testrun


    salesdocument = v_salesdocument


    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.



    wait = 'X'.

    ENDLOOP. "loop for the header data.

    Hope it helps.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.