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: 

Create Sales Order With Reference to Billing Document Using BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Kudos

hi team,

i have a small issue while using the BAPI to generate a sales order with reference to billing document.but i getting a error message as below

SD document 90000182 is not in the database or has been archived.Below is the small piece of code that i have included.any valuable suggestion is helpful.

wa_order_header_in-doc_type = 'ZITF'."""PASSING HEADER DETAILS
wa_order_header_in-sales_org = 'IN'.
wa_order_header_in-distr_chan = '10'.
wa_order_header_in-division = '02'.
wa_order_header_in-ref_doc = lv_bdoc.
select single fktyp from vbrk into fktyp where vbeln = lv_bdoc.
wa_order_header_in-refdoc_cat = fktyp..

wa_order_header_inx-doc_type = 'X'.
wa_order_header_inx-sales_org = 'X'.
wa_order_header_inx-distr_chan = 'X'.
wa_order_header_inx-division = 'X'.
wa_order_header_inx-ref_doc = 'X'.
wa_order_header_inx-refdoc_cat = 'X'.


clear: lv_item,wa_order_items_inx-ref_doc_ca,wa_final3,wa_final.

loop at it_final3 into wa_final3.

wa_order_items_in-itm_number = lv_item.
wa_order_items_in-material = wa_final3-matnr.
wa_order_items_in-ref_doc = lv_bdoc.
wa_order_items_in-currency = lv_waerk.
wa_order_items_in-ref_doc_ca where vbeln = 'G'.

wa_order_items_inx-itm_number = lv_item.
wa_order_items_inx-material = 'X'.
wa_order_items_inx-ref_doc = 'X'.
wa_order_items_inx-ref_doc_ca = 'X'.


append wa_order_items_in to it_order_items_in.
append wa_order_items_inx to it_order_items_inx.
clear: wa_order_items_in,wa_order_items_inx.

wa_order_conditions_in-cond_type = 'ZCPR'.
wa_order_conditions_in-cond_value = wa_final-rev_split.
wa_order_conditions_in-currency = lv_waerk.

wa_order_conditions_inx-cond_type = 'X'.
wa_order_conditions_inx-cond_value = 'X'.
wa_order_conditions_inx-currency = 'X'.

append wa_order_conditions_in to it_order_conditions_in.
append wa_order_conditions_inx to it_order_conditions_inx.
clear: wa_order_conditions_in,wa_order_conditions_inx.

clear: wa_final3.
endloop.

wa_bapiparnr-partn_role = 'WE'.""ship to party
wa_bapiparnr-partn_numb = EBG112.

call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = wa_bapiparnr-partn_numb
importing
output = wa_bapiparnr-partn_numb.
append wa_bapiparnr to it_bapiparnr.
clear: wa_bapiparnr.

wa_bapiparnr-partn_role = 'AG'."""sold to party
wa_bapiparnr-partn_numb = EBG112.

call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = wa_bapiparnr-partn_numb
importing
output = wa_bapiparnr-partn_numb.


append wa_bapiparnr to it_bapiparnr.
clear: wa_bapiparnr.

call function 'BAPI_SALESORDER_CREATEFROMDAT2'
exporting
order_header_in = wa_order_header_in
order_header_inx = wa_order_header_inx
importing
salesdocument = salesdocument
tables
return = it_return
order_items_in = it_order_items_in
order_items_inx = it_order_items_inx
order_partners = it_bapiparnr
* ORDER_SCHEDULES_IN =
* ORDER_SCHEDULES_INX =
order_conditions_in = it_order_conditions_in
order_conditions_inx = it_order_conditions_inx.

in it_return im getting an error message

SD document 90000182 is not in the database or has been archived.

seniors could you please suggest me where i'm going wrong.

thanks in advance.

uday..,

2 REPLIES 2

Former Member
0 Kudos

check the billing document in vf03 and their status to make sure they are existing document number.

Jelena
Active Contributor
0 Kudos

Have you tried debugging? Does the document exist with this number (leading zeroes?)? Are you passing the right document category?

As a side note, it's rather unusual to create a sales order with reference to a billing document, unless it's a return/credit. Regular sales orders are usually created with reference to other sales documents.