Concept of LUW ( Logical unit of work) -

Concept of Database Logical Unit of Work [LUW] :


1).Definition: This is a span of time in which database records are updated either commit or rollback.

2).Explanation:
At the point of view of database programming, a database LUW is an inseparable sequence of database operations that ends with a database commit. So the database LUW is either fully executed by the database system or not at all and a database LUW has been successfully executed, the database will be in a consistent state. So If an error occurs within a database LUW, all of the database changes since the beginning of the database LUW are reversed. It leaves the database in the state it was in before the transaction started.

These database changes that occur within a database LUW are not actually written to the database until after the database commit. So until this happens, you can use a database rollback to reverse the changes. So in the R/3 System, database commits and rollbacks can be triggered either implicitly or using explicit commands.

3).Implicit Database Commits in the R/3 System:
The work process can only execute a single database LUW. If the consequence of this is that a work process must always end a database LUW when it finishes its work for a user or an external call. So work processes trigger an implicit database commit in the following situations:

· a).When a dialog step is completed and control changes from the work process back to the SAP GUI.
· b).When a function module is called in another work process (RFC) and control passes to the other work process.
· c).When the called function module (RFC) in the other work process ends and control returns to the calling work process.
· d).When a WAIT statement interrupts the work process and control passes to another work process.
· e).Error dialogs [information, warning, or error messages] in dialog steps and control passes from the work process to the SAP GUI.

4).Explicit Database Commits in the R/3 System:
2 ways to trigger an explicit database commit in your application programs:
·  a).Call the function module DB_COMMIT and the sole task of this function module is to start a database commit.
·  b).Use the ABAP statement COMMIT WORK and this statement starts a database commit, but also performs other tasks (refer to the keyword documentation for COMMIT WORK).

5).Implicit Database Rollbacks in the R/3 System: 
     These cases can lead to an implicit database rollback
· a).Runtime error in an application program and this occurs whenever an application program has to terminate because of an unforeseen situation (for example, trying to divide by zero).
· b).Termination message -These messages are generated using the ABAP statement MESSAGE with the message type A or X and In certain cases (updates), they are also generated with message types I, W, and E. So these messages end the current application program.

6).Explicit Database Rollbacks in the R/3 System :
We can trigger a database rollback explicitly using the SAP ABAP statement ROLLBACK WORK and this statement starts a database rollback, but also performs other tasks [refer to the keyword documentation for ROLLBACK WORK]. So from the above, we can draw up the following list of points at which database LUW's begin & end.

7).A Database LUW Begins :
· a).Each time a dialog step starts [when the dialog step is sent to the work process].
· b).Whenever the previous database LUW ends in a database commit.
· c).Whenever the previous database LUW ends in a database rollback.
8).A Database LUW Ends :
· a).Each time a database commit occurs and this writes all of the changes to the database.
· b).Each time a database rollback occurs and this reverses all of the changes made during the LUW.

9).Database LUWs and Database Locks :
The changes in database made within it, a database LUW also consists of database locks & the database system uses locks to ensure that two/more users cannot changesamedata simultaneously since thiscouldlead to inconsistentdatabeing writtentothedatabase. So a database lock can only be active for the duration of a database LUW. If they are automatically released when the database LUW ends and in order to program SAP LUWs, we need a lock mechanism within the R/3 System that allows us to create locks with a longer lifetime.


Comments

Popular posts from this blog

EVENTS IN INTERACTIVE REPORTS OF SAP ABAP

Differences Between Classic & New BAdIs :

SAP ABAP Fresher Resume/ CV Writing Format..