Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

COMMIT WORK in USEREXIT_SAVE_DOCUMENT

Former Member
0 Likes
2,259

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

1 ACCEPTED SOLUTION
Read only

vinod_vemuru2
Active Contributor
0 Likes
1,526

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.

5 REPLIES 5
Read only

Former Member
0 Likes
1,526

Is there anyone who can help me with this???

Read only

0 Likes
1,526

Hello,

There is no need to write a COMMIT Statement in the USEREXIT_SAVE_DOCUMENT. The sales order will get saved automatically.

Regards,

Janani

Read only

0 Likes
1,526

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

Read only

vinod_vemuru2
Active Contributor
0 Likes
1,527

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.

Read only

Former Member
0 Likes
1,526

Removed the COMMIT WORK Statement and it worked perfectly. Thanks to everyone