Skip to Content
avatar image
-1
Former Member

Create Sales Order With Reference to Billing Document Using BAPI_SALESORDER_CREATEFROMDAT2

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..,

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Dec 18, 2017 at 05:31 PM

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

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 18, 2017 at 08:32 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded