What Is A SAP Lock

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

What is a SAP lock?

The SAP system is equipped with a special lock mechanism the purpose of the lock mechanism is to
prevent two transactions from changing the same data on the database simultaneously.
Locks are defined generically as "lock objects" in the Data Dictionary. Lock entries are usually set and
deleted automatically when user programs access a data object and release it again.
The SAP lock mechanism is closely related to the Update Mechanism .
There are different types of locks:
Write locks (E): This is also known as exclusive lock mode as the lock data can be edited by only one
user. Any other requests from workprocesses to set another write lock or read lock are rejected. A
cumulate lock can be applied on the lock data by the same lock owner again.
Read locks (S): This is also known as shared lock mode as several users can have read access to the
locked data at the same time. Additional read lock requests are entertained even if they are from
different users. However a write lock is rejected.
Enhanced write locks (X): This is also known as exclusive non-cumulative lock mode. An enhanced
write lock can be requested only once even if it is by the same transaction.
Difference between write locks(E) and Enhanced write lock(X) is write locks can be set and released by
the same transaction several times but X type locks can also be set once even by the same transaction.
Optimistic locks (O): These locks are set up when the users displays the data in change mode.
Several optimistic locks can be setup on the same data. Optimistic locks are read locks(S) at first and
converted to write lock (E) when the users want to save the data. If an optimistic locks on a data is
changed to write lock (E), all other optimistic locks on that data will be deleted.
Locks that are set by an application program are released by the program itself or they are released by
the update program once the database has been changed.
How to monitor SAP locks?
Transaction code SM12 can be used to monitor SAP locks.

Here you have option of selecting locks based on following parameters

Tablename
Lock argument
Client
Username

How to delete SAP locks?

In case, as part of monitoring, if you encounter some old sap locks and after thorough analysis, you
would like to delete these, it can be done in the following ways:
Select the locks and delete the lock from SM12
Identify the user who has set the respective lock and end the user session using SM04 transaction code

What is lock table overflow?


SAP manages locks using lock table. The lock table contains all of the information related to locks like
who is holding the lock and which locks are currently held etc. The size of the lock table can be
specified by the SAP parameter enque/table_size. The size of the lock table limits the number of locks,
lock owners and lock names. If this size is exceeded, then the lock table overflow occurs.
How to identify lock table overflow issue?
In SM21 transaction log and ST22 dumps, if you find any error messages like LOCK_TABLE_OVERFLOW,
Lock table overflow, Internal lock administration error it means there is a lock table overflow issue.
What is the parameter to be changed to increase lock table size in SAP?
Parameter enque/table_size to be changed to increase or decrease lock table size using RZ10
transaction. Default value of this parameter is 32768. The min value that can be set is 4096 and max
value is 102400. The unit for this parameter is KB.
What is the reason for lock table overflow?

A lock table overflow can occur due to

The lock table is configured too small (i.e value set to enque/table_size parameter is very low)
Due to improper design of application which sets a large number of locks
Number of enqueue worprocesses configured in a sap system are less and update is very

slow/hanging due to which lots of locks are accumulated in lock table


Running a custom report with improper selection criteria (like very long time periods data pull)
which sets so many locks & eventually lock table overflow occurs

How to resolve lock table overflow?


Increase the size of lock table i.e increase the parameter enque/table_size value using RZ10
transaction.
To determine the optimal value for this parameter, you can check the maximum locks set so far in the
history and the current number of locks set from SM12 -> Extras -> Statistics

You might also like