Controlled SAP LUW
Controlled SAP LUW
In ABAP applications, the SAP LUW (logical unit of work) concept helps developers address the risks of inconsistent data in the
database by providing techniques and statements. However, especially in classic ABAP programming, it was up to the developers
to make their code comply with the SAP LUW rules without any technical checks. Although done unintentionally, it is fairly easy to
create implementations that violate these rules. In newer ABAP technologies, the SAP LUW concept is enhanced by the controlled
SAP LUW. The controlled SAP LUW introduces a checking mechanism to detect violations of transactional contracts, thus making
applications more robust and the SAP LUW tangible.
It is always implicitly supported by the ABAP RESTful Application Programming Model (in short RAP), background
Processing Framework (bgPF), and local consumption of RAP business events.
The controlled SAP LUW can be used by explicitly activating transactional phases with the static methods of the class
CL_ABAP_TX.
In addition, transactional contracts define where (i. e. in which transactional phase) a classified API can be used. It is
checked which operations and statements are allowed in the implementation.
The time interval in which one consistent state of the database is transferred to another consistent state is called a logical unit of
work (LUW). The LUW concept follows an all-or-nothing approach: it ends either with a single and final commit, which persists the
changed data in the database, or with a rollback (for example, in the case of an error during the LUW), which undoes all changes
and restores the consistent state before the changes.
Either all data changes are committed, or none at all. When a new consistent state is reached after a commit, or when an original
state is restored, a new LUW can be opened.
There are two transactional phases in a transaction, which together form a logical unit:
modify
save
In a simplified way, the two transactional phases can be realized in a one-shot scenario as follows. A one-shot scenario may be an
HTTP request using a web API without any user interaction.
One-shot scenario:
This is custom documentation. For more information, please visit SAP Help Portal. 2