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 for ales order by reference of invoice

Former Member
0 Kudos

i need to create a sales order by reference of an invoice but not able to get the document flow.... what fields are needed too be populated...please suggest

8 REPLIES 8

Former Member
0 Kudos

Hi Navid,

The Sales Flow will be like this.

<b>Sales Order

Delivery

Billing.</b>

After Sales Order the Delivery and Billing will come. How u r creating Sales Order with ref. to Invoice.

Regards,

Balavardhan.K

0 Kudos

its a service sales order order ... so the flow is service contract =>service sale => customer bill=> sales order with reference to biiliing doc.

0 Kudos

how can i add a snap shot of what iam looking for?

Former Member
0 Kudos

HI Navid

In BAPI, we can find fields REF_DOC and REFDOC_CAT.

Pass the Invoice Number to REF_DOC and 'M' to REFDOC_CAT.

This will create the sales order with reference to the billing document.

Hope this helps...

Regards

Eswar

0 Kudos

these are the fields that iam populating.... dont know what iam missing


order_header_in-doc_type = 'ZQIC'.
  order_header_in-sales_org = '1000'.
  order_header_in-distr_chan = '30'.
  order_header_in-division = '00'.
  
  <b>order_header_in-ref_doc_l = svbeln.
  order_header_in-refdoc_cat = 'M'.</b>
  order_header_in-sd_doc_cat = 'C'.


  order_header_inx-sd_doc_cat = 'X'.
  order_header_inx-updateflag = 'I'.
  order_header_inx-doc_type = 'X'.
  order_header_inx-sales_org = 'X'.
  order_header_inx-distr_chan = 'X'.
  order_header_inx-division = 'X'.
  order_header_inx-ref_doc_l = 'X'.
  order_header_inx-refdoc_cat = 'X'.


  CLEAR order_partners.
  order_partners-partn_numb = kunnr.
  order_partners-partn_role =  'AG'.

  APPEND order_partners.
*  ENDLOOP.
  itm_number = 10.
  LOOP AT it_vbrp.

    CLEAR: order_items_in,order_items_inx,order_schedules_in,order_schedules_inx.

    order_items_in-itm_number = itm_number .
    order_items_in-material   = it_vbrp-matnr .
    order_items_in-sales_unit = it_vbrp-vrkme .
    order_items_in-plant      = werks .
    order_items_in-target_qty = it_vbrp-fkimg .
*    order_items_in-rnddlv_qty = it_vbrp-fkimg .
    order_items_in-short_text = it_vbrp-arktx.
    order_items_in-profit_ctr = it_vbrp-prctr.
    order_items_in-ref_doc = svbeln.
    order_items_in-ref_doc_it = it_vbrp-posnr.

    APPEND order_items_in.
    order_items_inx-updateflag = 'I'.
    order_items_inx-itm_number = 'X'.
    order_items_inx-itm_number = 'X'.
    order_items_inx-material   = 'X'.
    order_items_inx-sales_unit = 'X'.
    order_items_inx-plant      = 'X'.
    order_items_inx-target_qty = 'X'.
*    order_items_inx-rnddlv_qty = 'X'.
    order_items_inx-short_text = 'X'.
    order_items_inx-profit_ctr = 'X'.
    order_items_inx-ref_doc = 'X'.
    order_items_inx-ref_doc_it = 'X'.
    APPEND order_items_inx.

    order_schedules_in-itm_number = itm_number .
    order_schedules_in-req_qty = it_vbrp-fkimg.
    order_schedules_in-sched_line = '0001'.
    APPEND order_schedules_in .
    order_schedules_inx-sched_line = '0001'.
    order_schedules_inx-itm_number = itm_number.
    order_schedules_inx-req_qty = 'X'.


    APPEND order_schedules_inx.



    itm_number = itm_number + 10.

0 Kudos

also i need to popoulate the conditons...can you help me in that too

0 Kudos

Hi Navid

Have just simulated a scenario in my system and successfully created an order:

Have used BAPI: SD_SALESDOCUMENT_CREATE as i have tried to create CREDIT MEMO with reference to Invoice Document.

As Credit Memo document category is 'K', we can not use normal BAPI for creating the same. Hence i have used SD_SALESDOCUMENT_CREATE.

Below are the parameters i have passed:

<b>SALES_HEADER_IN</b>

--DOC_TYPE
  SALES_ORG
  DISTR_CHAN
  DIVISION
  REF_DOC --> Invoice Document Number
  REFDOC_CAT --> 'M' for Invoice

<b>SALES_HEADER_INX</b>

--UPDATEFLAG --> 'I'
  DOC_TYPE --> 'X'
  SALES_ORG --> 'X'
  DISTR_CHAN --> 'X'
  DIVISION --> 'X'
  REF_DOC --> 'X'
  REFDOC_CAT --> 'X'

<b>SALES_PARTNERS</b>

--PARTN_ROLE(Sold-to Party)
  PARTN_NUMB

Via the copy control the items will be copied from Invoice document, so we need not explicitly pass the items unless we need to manipulate the date.

It is same for Conditions as well...

Hope this helps...

Kind Regards

Eswar

0 Kudos

thank you for your input but the item do not get automatically populated also item of certain category need to be populated. same for conditions. if someone has used the bapi for reference by invoice that would be a great help