Skip to Content
0

Save aditional dato to sales order after saving sales order

Feb 06 at 12:41 PM

70

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Raymond Giuseppi
Feb 07 at 08:52 AM
2

I won't change another order in the same luw to prevent such problem, you could either

  • Execute the update in a custom RFC enabled functionmodule that wraps BAPI call and commit
CALL z_FM IN BACKGROUND TASK. " or UNIT)
  • Execute the call in a form executed at commit using DESTINATION NONE.
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'.
Show 3 Share
10 |10000 characters needed characters left characters exceeded

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 !

0

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.

1

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.

0
Rajkumar Narasimman Feb 06 at 01:33 PM
1

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

Show 3 Share
10 |10000 characters needed characters left characters exceeded

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.

And I get the error.
0

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

.

1

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 !

0