Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading original (before change) DB values in the current LUW?

Tags:

abap

opensql

badi

Is it possible to retrieve the old or original values for a table when it has been changed, but not yet committed, in the current LUW?

I'm implementing a BAdI that's supposed to be used to raise messages based on changes performed to an object, but SAP doesn't actually provide the original object data in the BAdI. Trying to read the data with SELECT statements doesn't work as the pending changes have already been applied at that point, just not committed.

If I debug the code I can see the old values just fine in SE16 but it seems like the uncommitted changed values are being returned by any SELECTs I perform in this BAdI.

Is there any way to read this original data?

like image 502
Lilienthal Avatar asked Mar 22 '18 12:03

Lilienthal


People also ask

What is DB LUW and SAP LUW?

Database LUW also known as DB LUW, each dialog step has its own DB LUW that is used to ensure data consistency. SAP LUW consists of several dialog steps and all the changes to database are written in a single DB LUW. We must note that the database changes are always written in the final database LUW.

What is database LUW?

A database LUW (also called a database transaction) is a non-separable sequence of database operations that ends in a database commit. The database LUW is either executed completely by the database system, or not at all.

What is the Luw in SAP?

A logical unit consisting of dialog steps, whose changes are written to the database in a single database LUW is called an SAPLUW. Unlike a database LUW, an SAP LUW can span multiple dialog steps, and be executed using a series of different work processes.

Which are types of logical unit of work in SAP?

A database LUW is the mechanism used by the database to ensure that its data is always consistent. An SAP LUW is a logical unit consisting of dialog steps, whose changes are written to the database in a single database LUW. An SAP transaction is an ABAP application program that you start using a transaction code.


1 Answers

The reading of a table which was updated previously, during the same Database LUW, will always return the updated values. So, it's at least required to read the table from another Database LUW.

The isolation level used by default depends on the type of database you are using. For HANA and Oracle, the "committed read" is the default, but other databases use the "uncommitted read" by default.

If you don't use HANA/Oracle, you may switch temporarily to the "committed read" isolation level by calling the function module DB_SET_ISOLATION_LEVEL.

Then, you can read the table from another Database LUW by using a service connection (prefixed R/3*), for instance: SELECT ... FROM yourtable ... CONNECTION ('R/3*temp') ...

like image 55
Sandra Rossi Avatar answered Nov 03 '22 02:11

Sandra Rossi