‎2007 Jun 17 9:12 AM
Hi every one,
I got a lill question here, can i use COMMIT WORK (AND WAIT ) within a user
exit FM, if yes is do i need any thing extra. Please help.
Thanks in advance
Jahan.
‎2007 Jun 17 9:43 AM
Hi Jahan,
You should NOT use Commit work & wait in a user exit as it can cause data integrity issues within the transaction.
what you can do is use PERFORM <name> ON COMMIT
or call a function module in UPDATE TASK
this way your commit will happen when the transaction decides to commit the data.
if you call a commit work , all the data will be commited to the db , both what you want to & what the standard code may/may not want to.
Kindly reward points to all helpful answers
Regards,
guarav
‎2007 Jun 17 9:55 AM
Dear Jahan,
You should not user commit work (and obviously wait) statement in a user-exit. SAP strongly says that you should not.
It may cause huge data inconsistency. SAP updates the records all at once or reject them all if an error occurs at later point of time.
If you use commit work statement in the user exit, they will be updated even before the transaction is completed. There could be more validations left the in the program. Hence, would definitely cause data inconsistency.
Hope this will help.
Regards,
Srilatha.
‎2007 Jun 17 10:40 AM
Thank you very much ..for sharing this valuable info..
Thnaks alot !
jahan
‎2007 Jun 17 1:10 PM
Hi Jahan,
although your question has been answered, just a few words on COMMIT WORK.
During a LUW (logical unit of work, i.e. transaction) all changes of database records are done within a so-called rollback segment of the database. That means they are visible within the current LUW but invisible to other users.
This makes it easy to do all necessary changes to all tables step by step. And if any step fails, all changes can be thrown away. Thats what we call a rollback - A rollback will just dump the rollback segment.
The reason you should not COMMIT WORK in a user exit is simply you have no idea what other database changes have already been done and what other database changes may follow after the user exit. If in one of the following steps a severe error is detected, all prior changes cannot be rolled back. COMMIT WORK means that all changes still in the rollback segment of the database will be applied and finalized to the database. The rollback segment will also be dumped that there is no chance to find out details about the changes.
An Error message (Type E or A) will automatically finish the LUW without commiting the data in the rollback segment - implicit rollback.
The end of a report not caused by any error will commit the rollback segment to the database - implicit commit.
All function modules called IN UPDATE TASK will be executed in their own update process after COMMIT or DUMPED after rollback.
All form routines called as PERFORM ... ON COMMIT or PERFORM ... ON ROLLBACK will be executed only after explicit COMMIT WORK or ROLLBACK WORK.
The addition 'AND WAIT' just means that the next program statement is not executed before all update processes started with COMMIT WORK have finished.
The general rule derived from this can be:
Never do a commit or rollback in a process which is called by another process. The only place for COMMIT or ROLLBACK is at the end of reports and transactions using CALL ... IN UPDATE TASK or PERFORM ... ON COMMIT - if you call any functions you should be aware that function modules may initiate update calls and/or form calls ...ON COMMIT/ROLLBACK. An explicit COMMIT WORK at the end of a process (or ROLLBACK WORK in case of error) will be OK.
Regards,
Clemens
‎2007 Jun 17 2:02 PM
Hey Clemens,
Thanks for explaining dis to such a gr8 detail.
its ben a gr8 help !
thnx
jahan