2018 Feb 06 12:41 PM
Hi experts,
I have inherited an issue from another abaper in my team.
The problem is the following: whenever the user saves a sales order, he wants to change some information in this SO, which I do in USEREXIT_SAVE_DOCUMENT_PREPARE.
And also they want to modify some other related sales orders. I tried to do that by using
BAPI_SALESORDER_CHANGE in USEREXIT_SAVE_DOCUMENT. But I get SAP error V1045 (Enter the document number).
Can I change a different SO while saving the first one?
Thanks in advance,
María
2018 Feb 06 1:33 PM
Hi Maria Merino,
Can you check by calling FM SD_SALES_DOCUMENT_INIT before FM BAPI_SALESORDER_CHANGE. It deletes the buffer status(STATUS_BUFF_INIT) value. Also please check the below note
1871065 - BAPI processing is cancelling with error V1045
Regards
Rajkumar Narasimman
2018 Feb 06 1:57 PM
Thankns Rajkunar, I'll check this note.
My code is like this:
[fill data]
CALL FUNCTION 'SD_SALES_DOCUMENT_INIT'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
STARTING NEW TASK 'TASK1'
EXPORTING
salesdocument = vbeln
order_header_inx = gv_header_inx
TABLES
return = po_return
* order_item_in = li_order_item_in
* order_item_inx = li_order_item_inx
* partnerchanges = li_order_partners
schedule_lines = li_order_schedules_in
schedule_linesx = li_order_schedules_inx.
extensionin = i_extensionin.
2018 Feb 07 6:06 AM
Hi Maria Merino,
What are you trying to update in Sales Order inside User Exit, Header or Schedule Lines or Extension? For Header order_header_in is not filled only order_header_inx is filled.
Did you pass and checked the FM whether it is working correctly outside the EXIT?
If still not working, create new FM paste all the codes and call FM using STARTING NEW TASK
Regards
Rajkumar Narasimman
.
2018 Feb 07 9:39 AM
Thanks Rajkumar, I tried with FM using STARTING NEW TASK but didn't work so I created a new report that calls the BAPI and I run this report by creating a job. I think it's working but I still have to do some more examples.
thanks for all your replies !
2018 Feb 07 8:52 AM
I won't change another order in the same luw to prevent such problem, you could either
CALL z_FM IN BACKGROUND TASK. " or UNIT)
PERFORM yourform ON COMMIT.
...
FORM yourform.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE' DESTINATION NONE
...
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' DESTINATION NONE
...
CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
DESTINATION = 'NONE'.
2018 Feb 07 9:41 AM
Thanks Raymond !! As I told Rajkumar, I created a new report that calls the BAPI and I run this report by creating a job. Now I have to check if this solution is ok, otherwise I'll try your suggestion.
Thanks a lot !
2018 Feb 07 7:42 PM
Instead of a job why not just use output with a custom function? In this way, you'll see right there in the order if it was processed and can even update the processing log with any messages.
We used this as sort of a "reverse third party process" to create a sales order from purchase order. Very convenient, does not require additional monitoring as a job and transparent to the business users.
2018 Feb 09 11:51 AM
Hi Jelena, I used a job because maybe I'll have to update too many sales orders, so I don't want the user waiting untill this process finishes.