What is SAP ABAP Cumulating Locks

ABAP cumulative lock (Cumulative Lock) is a special locking mechanism in the SAP system. Before understanding cumulative locks, we need to understand the lock mechanism in the SAP system.

In the SAP system, the lock mechanism is used to protect the integrity of transaction data. When user A is performing an operation to modify data, the system will automatically lock this part of the data to prevent other users from modifying the same data before user A's operation is completed, which ensures data consistency and integrity sex.

However, traditional locking mechanisms can cause some problems in certain situations. For example, when a user needs to perform continuous operations on a series of data, if each operation needs to be independently locked and unlocked, then this will cause a lot of system overhead. In addition, if this series of operations is interrupted by other users' operations, data inconsistency may result. In order to solve this problem, the SAP system introduces the concept of cumulative locks.

ABAP Cumulative Locks are locks that can be accumulated over multiple operations. Unlike traditional locking mechanisms, cumulative locks are not automatically unlocked after each operation, but remain locked until a specific unlock operation is performed. In this way, users only need to add a lock once in a series of operations, reducing system overhead and avoiding data inconsistency.

As an example, suppose we have a sales order with multiple order items. In the traditional lock mechanism, if we need to modify multiple order items, each item needs to be locked and unlocked separately. But if we use the cumulative lock, then lock it when modifying the first item, and all subsequent item modifications can be carried out under the protection of this lock, until all items are modified and then unlocked uniformly.
If the name, parameters and locking mode of the basic locks in the SAP ABAP system are the same, and the locks are not exclusive and non-cumulative, these locks can be set multiple times (the so-called accumulation effect).

The accumulation counter is incremented by one on each successive accumulation and decremented by one each time the lock is released.

When the counter reaches zero, the lock is released.

The following figure shows an example of how locks are accumulated.

  1. The lock request is accepted and written to the lock table with a cumulative counter of 0 for the conversation owner Owner_1. Update the counter to 1 for owner Owner_2.

  2. The second lock request was also successfully accepted. The cumulative counter for dialog owner Owner_1 is still 0 (because _SCOPE is set to 2); the counter for update owner Owner_2 is now 2.

  3. This time, _SCOPE is set to 1. In other words, the dialog owner Owner_1's cumulative counter is incremented to 1, while the update owner Owner_2's cumulative counter remains at 2.

  4. This time _SCOPE=3, i.e. the lock has two owners. Therefore, the cumulative counter for the conversation owner Owner_1 is incremented to 2, and the cumulative counter for Owner_2 is incremented to 3.

Guess you like

Origin blog.csdn.net/i042416/article/details/132254927