I have been working on SAP-ABAP from past one year. This is one of the question that has been particularly asked from me many times. So I have decided to properly document the question.
By the book defination taken from IBM site
A logical unit of work identifies input operations that are either committed or rolled back as a group. A unit of work begins when your code changes a recoverable resource; and ends when the first of these events occurs:
Your code invokes the system function sysLib.commit or sysLib.rollback to commit or roll back the changes- Your program executes a transfer with a commit specified
- EGL run-time services performs a rollback in response to a hard error that is not handled in your code; in this case, all the programs in the run unit are removed from memory
In nomal day to day work, if we want to understand a LUW, we have to take an example of a small business.
While building a business(in fact any other) software( in any language), the most important thing is consistancy of data. Let's take an example of fligh booking software, The overall process can be divided into 2 parts,
1. The selection of flight then deducting the money from the user's account.
2.The transferal of the money from user's account to the concerned account.
In between these two process the data is inconsistant (the money belongs to no one) What if some system failure occurs at this point of time? Because the whole process comes under one LUW hence the data can be recovered( Technically Rollbacked).
Every application devloper should understand the fact that while communicating between any two logical points the consistancy should be maintained. If by any chance there is some error in between, we should be able to reset the database/data to the previous consitant state. (While studying the LUW concept , I came across a very interesting phenomenon called Transaction deadlock I will be writing about it and handling this condtion in ABAP here)
There are three units related to this term in SAP are :
1) Database Logical unit of work
The database LUW is a sequence of various database operations that usually ends with the database commit statement. If there are no errors in between the operations then only the LUW will be executed. Hence it's either 100% execution or zero. The changes to the database are not fully written untill database commit is executed. The whole system can be seen graphically as shown.
B.When a new screen is created.
C. When a system sends a RFC (Remote function Call)
2) SAP LUW:
A SAP LUW may have a longer span than a DB LUW, there may be one or more DB LUW corresponding to one SAP LUW. A SAP LUW is triggered.
- A transaction run with a new SAP LUW ( there may be more than one database commit used during one transaction)
- A report run with a new SAP LUW.
2) SAP Logical unit of work
3) SAP Transaction.
What is BAPI??
Can we use commit or rollback in user exit and will it work ?
No comments:
Post a Comment