‎2010 Jan 07 12:39 PM
Hi All,
I have an issue with COMMIT WORK statement written in USEREXIT_SAVE_DOCUMENT.
Issue :-
1. I am creating Sales Orders using Idocs ( Process Code : ORDE , Function module : IDOC_INPUT_ORDERS )
2. Above mentioned FM does a call transaction BDC on VA01 transaction and creates Sales Orders.
3. The problem that I am facing is Idoc gets failed with Status 51, but Sales Order is getting saved in the system.
4. After analysing further, I got to know that there is a statement COMMIT WORK written in USEREXIT_SAVE_DOCUMENT and it causing this issue.
5. System reaches the above statement and it executes COMMIT WORK and completely comes out of the above mentioned "exit" and "Sales Order processing" without executing the statements followed by that.
6. Now, the control is returned to Idoc processing which is nothing but the FM IDOC_INPUT_ORDERS
7. It simply searches for the message No.311 (Success message "Sales Document XXXXXX has been saved" that gets generated by Sales Order and as it could not find that, it simply turns the Idoc status to 51(which is failure status).
8. The reason why it could not find the mesage 311 is because of the commit statement which did not execute any of the statements after that including standard SAP statements.
Now, I can remove the COMMIT WORK Statement and my Idoc can be seen in status 53.
But, the question is I am seeing this issue only in our Testing Server. It works well with the same code in our development server and none of the Idocs gets into 51. All the Idocs in dev server gets posted successfully. I observed that it passes through COMMIT WORK Statement and executes the statements that are written after that.
I am puzzled with this behaviour. Could you please help me on this.
Thanks,
Babu Kilari
‎2010 Jan 07 3:01 PM
Hi,
As per my understanding, it shouldn't work even in development system. Not sure of the reason.
But if that commit work is coded by you, please remove that statement. Transaction commit will happen once the order is saved and it will take care of other functionalities intended for that COMMIT. If that code is not yours, you can think of using below solution (To be on safe side as removing that may cause some other functionality to fail.)
Create an RFC FM and issue that commit work in that FM by calling the FM in BACKGROUND TASK. Ideally this should solve the issue.
Thanks,
Vinod.
‎2010 Jan 07 1:38 PM
‎2010 Jan 07 1:40 PM
Hello,
There is no need to write a COMMIT Statement in the USEREXIT_SAVE_DOCUMENT. The sales order will get saved automatically.
Regards,
Janani
‎2010 Jan 07 9:56 PM
Hi,
a COMMIT WORK is always wrong in any kind of userexit, because userexits are add-ons to SAP standard transactions. Usually the DB upadte is done in the update task modules. Update task modules are queued by 'CALL FUNCTION IN UPDATE TASK" and released (started) by COMMIT WORK. Thats why COMMIT work is strictly forbidden.
Remove that from the userexit.
Regards,
Clemens
‎2010 Jan 07 3:01 PM
Hi,
As per my understanding, it shouldn't work even in development system. Not sure of the reason.
But if that commit work is coded by you, please remove that statement. Transaction commit will happen once the order is saved and it will take care of other functionalities intended for that COMMIT. If that code is not yours, you can think of using below solution (To be on safe side as removing that may cause some other functionality to fail.)
Create an RFC FM and issue that commit work in that FM by calling the FM in BACKGROUND TASK. Ideally this should solve the issue.
Thanks,
Vinod.
‎2010 Jan 21 1:01 PM
Removed the COMMIT WORK Statement and it worked perfectly. Thanks to everyone