Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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.

Tags:
Not what you were looking for? View more on this topic or Ask a question