Skip to Content

Save aditional dato to sales order after saving sales order

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Feb 07 at 08:52 AM

    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'.
    Add comment
    10|10000 characters needed characters exceeded

  • Feb 06 at 01: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

    Add comment
    10|10000 characters needed characters exceeded

    • 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 !