12-27-2012 10:04 AM
Hi all,
as per requirement i need to create sales order with reference to other sales document, now i am using BAPI_SALESORDER_CREATEFROMDAT2 Fm to create sales document..
the code as follows:
CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
EXPORTING
input = 'OR'
IMPORTING
output = ls_BAPISDHD1-DOC_TYPE
EXCEPTIONS
others = 1.
ls_BAPISDHD1-ref_doc = '0000000722'. " order number
ls_BAPISDHD1-REFDOC_CAT = 'C'. " order catagory
ls_BAPISDHD1X-DOC_TYPE = 'X'.
ls_BAPISDHD1X-ref_doc = 'X'.
ls_BAPISDHD1X-REFDOC_CAT = 'X'.
ls_BAPIPARNR-PARTN_ROLE = patner_role.
ls_BAPIPARNR-PARTN_NUMB = sold_to_party.
APPEND ls_BAPIPARNR to lt_BAPIPARNR.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
* SALESDOCUMENTIN =
ORDER_HEADER_IN = ls_BAPISDHD1
ORDER_HEADER_INX = ls_BAPISDHD1X
* SENDER =
* BINARY_RELATIONSHIPTYPE =
* INT_NUMBER_ASSIGNMENT =
* BEHAVE_WHEN_ERROR =
* LOGIC_SWITCH =
* TESTRUN =
* CONVERT = ' '
IMPORTING
SALESDOCUMENT = lv_vbeln
TABLES
RETURN = lt_BAPIRET2
* ORDER_ITEMS_IN =
* ORDER_ITEMS_INX =
ORDER_PARTNERS = lt_BAPIPARNR.
the problem is the new sales document is creating but it is incomplete. the new document did not getting the data from reference doc(provided in ref_doc of header parameter), Is i need to pass any other parameters or use any other FM's to create sales document. please suggest me.
Thanks in Advance
Ram
12-27-2012 10:11 AM
hi,
first goto se37 and run 'BAPI_SALESORDER_CREATEFROMDAT2' give all your inputs and see what input you require to complete it .
hope it helps,
Vinoth
12-27-2012 10:48 AM
Hi Ram,
pls. check sap note 550726 FAQ: BAPIs in sales - restrictions, point 7:
Question: Do BAPIs support the "Create with Reference" function?
Answer:
No. However, you can update the document flow, for example, for contracts by
specifying reference documents. You can use the function module
BAPI_SALESDOCUMENT_COPY that has not been released to create a 1:1 copy of sales
documents.
Regrds Hendrik
12-27-2012 1:00 PM
Hi Hendrik,
Thanks for your replay. can you suggest me any other ways to create sales order with reference to other sales order.
12-27-2012 1:27 PM
Hi Parashuram,
it depends on your requierements. If all copy routines must be performed as it is done within dialog, you need do to a batch input for va01/va21/va41....
Other option is to read all the needed datas from the ref. sales order and pass the datas to BAPI_SALESDOCUMENT_COPY. (Rember you will need to implement all the copy routines within your abap).
To get the sales data you could use this code snip:
* Get Data
DATA ls_bapi_view TYPE order_view.
DATA lt_salesdocuments TYPE TABLE OF sales_key.
DATA lt_order_headers_out TYPE TABLE OF bapisdhd.
DATA ls_order_header_out TYPE bapisdhd.
DATA lt_order_items_out TYPE TABLE OF bapisdit.
DATA ls_order_item_out TYPE bapisdit.
DATA lt_order_schedules_out TYPE TABLE OF bapisdhedu.
DATA ls_order_schedules_out TYPE bapisdhedu.
DATA lt_order_conditions_out TYPE TABLE OF bapisdcond.
DATA: ls_order_conditions_out TYPE bapisdcond.
DATA lt_order_partners_out TYPE TABLE OF bapisdpart.
DATA ls_order_partners_out TYPE bapisdpart.
ls_bapi_view-header = 'X'.
ls_bapi_view-item = 'X'.
ls_bapi_view-sdschedule = 'X'.
ls_bapi_view-sdcond = 'X'.
ls_bapi_view-partner = 'X'.
APPEND vbeln TO lt_salesdocuments.
CALL FUNCTION 'BAPISDORDER_GETDETAILEDLIST'
EXPORTING
i_bapi_view = ls_bapi_view
TABLES
sales_documents = lt_salesdocuments
order_headers_out = lt_order_headers_out
order_items_out = lt_order_items_out
order_schedules_out = lt_order_schedules_out
order_partners_out = lt_order_partners_out
order_conditions_out = lt_order_conditions_out.
Regards Hendrik