‎2007 Apr 18 8:08 AM
Hi all,
Can any one explain me in details what is the difference between Commit Work, Logical Unit of Work and Roll back work. Pls explain by providing some example.
and also explain me where and when these are used and what are the importance of using these.
Thanks in advance.
Regards
Ramana Prasad.T
‎2007 Apr 18 8:09 AM
Hi Ramana Prasad,
A Logical Unit of Work (LUW or database transaction) is an inseparable sequence of database operations which must be executed either in its entirety or not at all. For the database system, it thus constitutes a unit.
LUWs help to guarantee database integrity. When an LUW has been successfully concluded, the database is once again in a correct state. If, however, an error occurs within an LUW, all database changes made since the beginning of the LUW are canceled and the database is then in the same state as before the LUW started.
An LUW begins
o each time you start a transaction
o when the database changes of the previous LUW have been confirmed (database
commit) or
o when the database changes of the previous LUW have been cancelled (database rollback)
An LUW ends
o when the database changes have been confirmed (database commit) or
o when the database changes have been canceled (database rollback)
COMMIT WORK.
Executes a database commit and thus closes a logical processing unit or Logical Unit of Work ( LUW ) (see also Transaction processing ). This means that
all database changes are made irrevocable and cannot be reversed with ROLLBACK WORK and
all database locks are released.
COMMIT WORK also
calls the subroutines specified by PERFORM ... ON COMMIT * executes asynchronously any update requests (see CALL FUNCTION ... IN UPDATE TASK ) specified in these subroutines or started just before,
processes the function modules specified in CALL FUNCTION ... IN BACKGROUND TASK ,
cancels all existing locks (see SAP locking concept ) if no update requests exist,
closes all open database cursors (see OPEN CURSOR ) and
resets the time slice counter to 0.
COMMIT WORK belongs to the Open SQL command set.
Return code value
The SY-SUBRC is set to 0.
ROLLBACK WORK.
Closes a logical processing unit by reversing all database changes made since the last COMMIT .
You use this statement if you cannot be certain that all the database changes have been executed correctly.
The update routines are not performed.
ROLLBACK WORK belongs to the Open SQL command set.
Note
If the ROLLBACK statement occurs within a SELECT loop, the processing cannot continue because the database cursor is invalid. After the ROLLBACK statement, you should therefore ensure that all SELECT processing has been explicitly terminated.
<b>Plz. Avoid Duplicate Threads.</b>
Hope this resolves your query.
Reward all the helpful answers.
Regards
‎2007 Apr 18 8:10 AM
Hi..,
A database LUW is a non-separable sequence of database operations that ends in a database <b>commit</b>. The database LUW is either executed completely by the database system, or not at all. After a database LUW has been successfully completed, the database returns to a consistent status and a new database LUW is opened. If an error is discovered within a database LUW, all database changes made since the start of the database LUW can be canceled using a database <b>rollback</b>. The database is subsequently restored to the same status as before the start of the database LUW.
<b>The statement COMMIT WORK completes the current LUW and opens a new one, <u>storing all change</u> requests for the currenta LUW in the process.</b>
<b>The statement ROLLBACK WORK closes the current LUW and opens a new one. In doing so, all change requests of the current LUW are <u>canceled</u>.</b>
regards,
sai ramesh
‎2007 Apr 18 8:16 AM
In a ROLLBACK, all the changes made by a transaction or a subtransaction on the database instance are reversed. Changes closed with a COMMIT can no longer be reversed with a ROLLBACK. As a result of a ROLLBACK, a new transaction is implicitly opened. In normal database operation, the database system performs the required ROLLBACK actions independently. However, ROLLBACK can also be explicitly requested using appropriate SQL statements.
LUW is the mechanism used by the database to ensure that its data is always consistent. (DATAbase Context)
An SAP LUW is a logical unit consisting of dialog steps, whose changes are written to the database in a single database LUW.
Commit Work
Executes a database commit and thus closes a logical processing unit or Logical Unit of Work ( LUW )
all database changes are made irrevocable and cannot be reversed with ROLLBACK WORK
all database locks are released.
Regards,
Venkat
‎2007 Apr 18 8:17 AM
Hi Prasad,
Chk this link,
http://help.sap.com/saphelp_47x200/helpdata/EN/41/7af4c2a79e11d1950f0000e82de14a/frameset.htm
Regards,
-->Suresh