Create S O with reference to an order

Hi Friends,
I am trying to create a sales order with reference to an existing sales order but I am not getting the reference field populated.
I am using SD_SALESDOCUMENT_CREATE for this purpos and code as below
Header details
  l_order_header_in-doc_type   = vbak-auart.
  l_order_header_in-sales_org  = vbak-vkorg.
  l_order_header_in-distr_chan = vbak-vtweg.
  l_order_header_in-division   = vbak-spart.
  l_order_header_in-ref_doc_l  = vbak-vbeln.
  l_order_header_inx-doc_type   = 'X'.
  l_order_header_inx-sales_org  = 'X'.
  l_order_header_inx-distr_chan = 'X'.
  l_order_header_inx-division   = 'X'.
  l_order_header_inx-ref_doc_l  = 'X'.
  l_order_header_inx-updateflag    = 'I'.
  CLEAR v_item_no.
  v_item_no = '000010'.
Item details
  LOOP AT i_unauth.
    i_order_items_in-itm_number  = v_item_no.
    i_order_items_in-material    = i_unauth-matnr.
    i_order_items_in-target_qty  = i_unauth-kwmeng.
    i_order_items_inx-itm_number = i_order_items_in-itm_number.
    i_order_items_inx-material   = 'X'.
    i_order_items_inx-target_qty = 'X'.
    i_order_items_inx-updateflag = 'I'.
    APPEND: i_order_items_in, i_order_items_inx.
    CLEAR: i_order_items_in, i_order_items_inx.
schedule lines
    i_sales_schedules_in-itm_number = v_item_no.
    i_sales_schedules_in-sched_line = v_item_no+1(4).
    i_sales_schedules_in-req_qty    = i_unauth-kwmeng.
    i_sales_schedules_inx-itm_number = i_sales_schedules_in-itm_number.
    i_sales_schedules_inx-sched_line = i_sales_schedules_in-sched_line.
    i_sales_schedules_inx-req_qty    = 'X'.
    i_sales_schedules_inx-updateflag = 'I'.
    APPEND: i_sales_schedules_in, i_sales_schedules_inx.
    CLEAR: i_sales_schedules_in, i_sales_schedules_inx.
    v_item_no = v_item_no + 10.
  ENDLOOP.
Partner details
  i_order_partners-partn_role = 'AG'.
  i_order_partners-partn_numb = vbak-kunnr.
  APPEND i_order_partners. CLEAR i_order_partners.
  SELECT SINGLE * FROM vbpa INTO vbpa
  WHERE vbeln = vbak-vbeln AND
        posnr = '000000' AND
        parvw = 'WE '.
  IF sy-subrc = 0.
    i_order_partners-partn_role = vbpa-parvw.
    i_order_partners-partn_numb = vbpa-kunnr.
    APPEND i_order_partners. CLEAR i_order_partners.
  ENDIF.
I tried to create it with using BAPI_SALESORDER_CREATEFROMDAT2 but was not sucessfull and has to try with the SD_SALESDOCUMENT_CREATE .
Could somebody please suggest me how to acheive this.
Thanks,
Kiran.

There is an OSS note <a href="https://service.sap.com/sap/support/notes/370988">Note 370988 - BAPIs in SD: Creation with reference</a>
<i><b>Symptom</b>
This note describes the problems of the 'Create with reference' function when using BAPIs to create sales documents.
If you are working online, you can use this function module to create a sales document with reference to an existing sales document or a billing document (for example, a debit or credit memo request) according to fixed rules. The rules for transferring information from the source document to the target document are defined in the copying control on header and item level. The creation with reference permits an item selection.
When you use BAPIs in SD, a function of this type is not fully available. A reference is only possible for a quantity contract, so that the target quantity of the contract can be reduced by the order quantity of the sales document. Furthermore, the document flow is also updated.
As an alternative to 'Create with reference' in Transaction VA01, two variants are provided for solving the 'Create with reference' problem in the BAPI.
      1. Create a '1:1 ' - that is, a document copy of a sales document (customer quotation, order) with 'BAPI_SALESDOCUMENT_COPY'. At this point, you cannot create the 1:1 copy of either a billing document or a delivery.
      2. Create a sales document that refers to an existing document with 'BAPISDORDER_GETDETAILEDLIST' and 'BAPI_SALESORDER_CREATEFROMDAT2'.
<b>Other terms</b>
BAPI_SALESDOCUMENT_COPY, BAPI_SALESORDER_CHANGE, BAPI_CUSTOMERINQUIRY_CHANGE, BAPI_CUSTOMERQUOTATION_CHANGE, BAPI_SALESORDER_CREATEFROMDAT1, BAPI_SALESORDER_CREATEFROMDAT2, BAPI_SALESORDER_CREATEFROMDATA, BAPISDORDER_GETDETAILEDLIST
<b>Reason and Prerequisites</b>
As of yet, no method exists for creating a sales document that refers to an existing document.
Solution
For solution No. 1
      1. Create the documents using the BAPI_SALESDOCUMENT_COPY function module. However, this only permits a 1:1 copy without factoring out individual items.
      2. After you have created the document copy, you can use a change BAPI to edit this copy.
For solution No. 2
      1. Collect the data for the reference document (for example a customer quotation) with the 'BAPISDORDER_GETDETAILEDLIST' function module. In the example code, focus exclusively on the partners, items, schedule lines and conditions.
      2. Prepare the Data. Execute the 'copying control' manually. This way, you decide which values are to be transferred.
      3. Create the sales document using the 'BAPI_SALESORDER_CREATEFROMDAT2' function module by transferring the prepared data.
      4. Finally, you must remove a COMMIT WORK so that the sales document can be written into the database.
An example of solution 2 is attached as a text file. You are allowed to select items and quantities for example, if you use input parameters. If there are no entries, then transfer 1:1 from the reference document. When you enter the 'condition type' parameter, you can determine whether conditions are copied or recalculated ('G' for transferring from the preceding document; 'B' or ' ' for re-determining, and 'C' for re-determining with transfer of the manual elements).</i>
Sample : <a href="https://service.sap.com/~sapidb/012003146900000486112004E/BAPI_COPY_WITH_REF.txt">ZZ_MS_BAPI_COPY</a>
Regards

Similar Messages

  • Can we create outbound delivery with reference of purchase order

    Hi All,
    can we create outbound delivery with reference of purchase order?

    dear friend,
    as far as i know you can create it with the following references:
    -to sales order;
    -to STO;
    -to subcontract order;
    -to project;
    -without any ref
    are you talking about stock transport order ?
    regards,

  • Function module to create Inbound delivery with reference to Purchase Order

    Hi experts,
    I want to create Inbound delivery with refernce to Purchase Order. But I want to create item wise. For example If one purchase order is there with 10 line items. 10, 20, 30, 40, 50......100.
    If I am showing report for Purchase Order with select option and if I select first 5 line items 10, 20, 30, 40, 50 then my program should be create one Inbound delivery for selected line items only. I have tried BDC for Tcode VL31N, but its not worked. Is there any Function module to create Inbound delivery with reference to Purchase Order for selected line items????????

    Hi,
    Try FM RV_DELIVERY_CREATE or GN_DELIVERY_CREATE.
    For creating a delivery wrt PO u 1st need to have a sales order i guess.
    Regards,
    Amit

  • Re: Creating credit memo with reference to Sales Order in ICWC

    Hello gurus
    I am new to CRM and we hv ECC 6.0 & CRM 6.0 in our environment.
    We have a process where a Credit Memo Request is created with reference to a Sales Order.
    Now till this point we had launched VA01 in the ICWC and were creating the CMR with reference to the Standard Order.
    Henceforth we want to move this to the CRM ICWC.
    In ICWC we create Standard Sales order using Work Center IC_BT_SLO tied to the Navigation profile.
    I am looking for some way of copying this order to a Credit Memo Request in the ICWC.
    I tried adding the Complaints button on the navigation profile ... however it creates a new CMR ... not sure how to enable copying it from the Original Sales order in ICWC
    Any thoughts ?
    Thanks
    Vinit

    closed
    Edited by: vinit parkar on Sep 1, 2011 4:25 PM

  • BAPI to create notification service with reference to sales order

    Hi,
    My need is to create a service notification TC IW51 with reference to sales order (credit memo request).
    is there a bapi to do this or i must do a bdc?
    please help.
    A+
    Ihsen ABROUG

    I have custom screen fields on notification service!
    i think a bdc is better.

  • Creating material bom with reference to Sales order bom.

    How to create material bom by coping Sales order bom.?

    Mayur,
    Just go to T code: CS01 use BOm  usage 1 & then select the copy from icon in the menu bar.
    On the popup screen enter material no, plat , bom usage =5 (sales bom).
    System will then allow you to select items from Sales bom. Select the items you need copied to Material BOM. Then save.
    Hope this helps.
    Thanks,
    Ram

  • Create outbound delivery with reference to purchase order

    Hi,
    I've created new plant and when i make purchase order i cant see the PO in VL10B, and there for i cant create outbound delivery.
    In the PO in Item Detail there is no shipping category.
    What i need to do ?
    Thank you.

    Step1: In SPRO - Materials Management - Purchasing - Purchase Order - Set up Stock Transport Order - Define Shipping Data for Plants.
    Define the Customer number, Sales Org, Distribution channel and Division for the Plant.
    The Customer you are assigning for the Plant has to be created in the System to create the outbound delivery.
    Step2: In SPRO - Materials Management - Purchasing - Purchase Order - Set up Stock Transport Order - Assign Delivery Type and Checking Rule.
        Then Assign the PO type and the supplying plant to the Delivery Type which is NL (for inter company) and Checking Rule.

  • Create inbound delivery with reference to purchase orders

    Hi,
    I´d like to create inbound deliveries using BAPI or transactions like vl10x (for outbound deliveries) for different purchase orders, items and quantities.
    Does anyone know the way to do it?
    Thank you in advance
    Best regards

    Hi,
    Is there only that transaction to create inbound deliveries??
    We want to do a load a file and create inbound deliveries. I was looking for bapi mass transactions, but I don´t know if the only way is to create a batch input of transaction VL31n.
    Thanks

  • Unable to create PO with reference to sales order

    Hi All,
    While creating a PO with reference to sales order, we are getting an error message as below
    "Error while determining local currency exchange rate type AB45 date 30.06.2010 from EUR to SEK"
    In T.code: OB08, We observed that exchange rates have been maintained for the above combination
    i.e. AB45 is a exchange rate key for our customer.
    exchange entries have been already maintained in OB08,
    Please suggest a solution to resolve this issue.
    Regards,
    Prasad

    Hello,
    While creating a PO with reference to sales order, we are getting an error message as below
    "Error while determining local currency exchange rate type AB45 date 30.06.2010 from EUR to SEK"
    In T.code: OB08, We observed that exchange rates have been maintained for the above combination
    i.e. AB45 is a exchange rate key for our customer. exchange entries have been already maintained in OB08,
    Please suggest a solution to resolve this issue.
    Since you have maintained the setting in OB08, please refer to below link which has the same subject matter.
    [HELP LINK !!|Error determining local currency]
    Regards,
    Sarthak

  • Inbound idoc to create outbound delivary with ref to sales order

    Hi,
           I am getting and inbound idoc from the external party to create Inbound delivary with reference to sales order.
           But my inbound process code FM(IDOC_INPUT_DESADV1) checking PO no. and item which is NON SAP PO no. and item in idoc.  So, it is giving error PO doesnot exist in the system .
           I want to create Inbound delivary with ref to SO not with reference to PO.
            Pls check techincal details which i am using for inbound process :
            Process code : DELS
            Inbound FM    : IDOC_INPUT_DESADV1
            Message type : DESADV
             Idoc : DELVRY05
            Kindly help me.
    Regards,
    Manoj

    Hi,
    For creating inbound Purchase Orders, you can use Idocs PORDCR1.PORDCR101 or PORDCR1.PORDCR102. I have used this and they are working perfectly for us.
    Reg,
    NJ

  • Problem in Sales order create using BAPI with reference to quotation

    Hi,
    I am creating a sales order from Quotation using BAPI /AFS/BAPI_SALESORD_CREATEFDATA.
    The Sale order is getting created and the document flow is updated. When i check the status of quotation it is "OPEN".
    Ideally when a sale order is created in VA01 with reference to a quotation and if all items are added in the order from quotation, then the status of the quotation must be "Complete".
    When i use the BAPI, the status of the quotation is sill "Open". Has anyone faced this issue?
    Even if anyone has faced this issue with BAPI_SALESORDER_CREATEFROMDAT2, please let me know...
    Regards

    Hi RV,
    I am using BAPI  to create order reference to contracts. I am facing same issue. Its not updating document flow (vbfa-plmin field). After creating orders I am forcing to update plmin field in vbfa. This worked fine. But now status in reference document not updating properly. I saw your thread. It looks like similar issue. I saw your comments "Customization was not maintained properly for the Order types ". Please can you explain little bit more about your solution. It will helps us lot.
    Thanks,
    srini

  • How to create a Contract with reference to a Sales-Order(VA01) with a BAPI

    Hi,
    my name is Wadim and i need help.
    My problem:
    I am creating a sales-order(VA01) with the BAPI 'BAPI_SALESORDER_CREATEFROMDAT2'.
    After that i have to create a contract(VA41) with reference to this order. I found the BAPI "BAPI_CONTRACT_CREATEFROMDATA" and it has the same interfaceparameters like the salesorder-bapi. but there are no parameters to get a connection to the sales-order.
    Is it even possible to get a connection to a sales-order with a bapi???
    thanks for help
    regards mark
    Edited by: Krapp Wadim on May 20, 2010 9:19 PM

    Hi Wadim,
    I have a similar requirement to create order lines in an existing contract with reference using  BAPI_CUSTOMERCONTRACT_CHANGE.  The order lines get created in the contract. However, the condition types from the order line which i'm referencing are not getting referenced and are not getting added in the Contract's line after referencing.
    Did you come across any such issue ? If yes , could you suggest the solution ?
    Regards,
    Venkat.

  • Enable - Create With Reference in Sales order

    Hi All,
    I want to enable - Create With Reference in Sales order
    We have 1 billing doc type YX1 to be used as reference for a sales order type ZX3
    How to enable Create with reference from Sales Document type YX1 to Sales Document type ZX3.
    Currently, I am getting error 'Copying from sales document type YX1 to ZX3 is not supported'.
    Please let me know the steps to be followed.
    Thank you!
    Regards,
    Shanu Jain

    Hi,
    The error clearly suggests that there is no copy control maintained b/w invoice YX1 and sales order type ZX3. You need to maintain that in SPRO > Sales and Distribution > Sales Documents > Copy control for sales documents. (You may check the correct node here). Here, you select the billing document to sales document.
    Check for source and destination. You can take the source as F2 and CR (if ZX3 is a credit Memo request) as Destination document. You can copy the same and change the source and destination as YX1 as source and ZX3 as destination. Then, at the item level, if you have a new item category you can specify it as the 'Proposed Item Category'. Save it.
    Now try to create the sales document ZX3 w.r.t YX1... It should work.
    Hope this helps
    Thanks
    Mukund S

  • PR Created with reference to Work Order

    Dear Experts,
    We have Work Order Process where Purchase Requisition for Material & Services are created with reference to Work Order . We have chosen the Option (from release), which means PR is created once the Order is released.
    Our requirement is always from release and when the work order released, system to pick the user details of Work Order Creator (not Work Order Release).
    Hope to get the details on the issue.
    Regards,
    Sahu

    Dear Chaitanya,
    When the work Order is released, system creates the Purchase Requisition and in this case PR Creator is the person who has released the Work Order.
    In Work Order log, we know the details  such as, who has created the Work Order and who has released. As SAP standard, Work Order release person is the PR Creator as we have made the setting with From Release.
    Our Requirement is on PR creation, system to take the user details of Work Order Creator. This would help to determine the PR approval process in a better way.
    Regards,
    Sahu

  • ORDERS05 - Create a Return with reference to a Sales Order

    Hi all,
    I'm trying to create a return with reference to a sales order via IDOC ORDERS05. I'm indicating referenced Sales Order number into segment E1EDK02; indicating qualifier (QUALFR = 002) and Sales order number (BELNR). By this way, I create a Customer Return but without reference.
    Which fields or segment have to be filled in order to create it correctly?
    Thanks
    Marí

    Correct...
    You need something like:
    *Get the pricing cond number.
    select single knumv from vbak into cond
      where vbeln = '0000080347'.
    if sy-subrc = 0.
    Get the pricing record which are by line item.
      select * from konv into table konv_tbl where knumv = cond.
    Loop thru them one line at a time.
      loop at konv_tbl.
       bapi_cond-itm_number = '000010'.
        bapi_cond-cond_st_no = konv_tbl-stunr.
        bapi_cond-cond_count = konv_tbl-zaehk.
    CALL FUNCTION 'BAPI_CUSTOMERRETURN_CREATE'
      EXPORTING
        RETURN_HEADER_IN               = bapi_hdr
       BUSINESS_OBJECT               = 'BUS2102'
        CONVERT                        = 'X'
      IMPORTING
        SALESDOCUMENT                 = bapi_salesdoc
       RETURN                        = BAPI_RET
      TABLES
        RETURN                        = bapi_ret_tbl
        RETURN_ITEMS_IN                = bapi_itm
        RETURN_ITEMS_INX               = bapi_itm_out
        RETURN_PARTNERS                = bapi_prtnr
        RETURN_SCHEDULES_IN            = bapi_schd_lin
        RETURN_CONDITIONS_IN           = bapi_cond.  "pricing
      ORDER_TEXT                    = bapi_text.

Maybe you are looking for