cancel
Showing results for 
Search instead for 
Did you mean: 

what about lockmechanisum?

Former Member
0 Kudos

hi,

plz explain about lockmechanisum.

regards,

reddy

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi

Lock Mechanism

Sperrtabelle

Kollisionen von Sperren

Das R/3 Sperrkonzept

You can synchronize access by several programs to the same data with a logical lock mechanism. This lock mechanism fulfills two main functions:

A program can tell other programs which data records it is just reading or changing.

A program can prevent itself from reading data that is just being changed by another program.

The data records of a table to be locked are defined by a logical condition. When a lock is set, this logical condition is entered in a lock table. This entry is retained until it is removed by the program or the program comes to an end. All the locks set by a program are thus removed at the end of the program.

When accessing data records, the records just being edited by other programs can be identified by the entry in the lock table. Such an entry for the lock must define a number of fully specified key fields, that is either a value is passed for the key field or this field is locked generically.

To set locks, a lock object must be defined in the ABAP Dictionary. When this lock object is activated, two function modules (see Function Modules for Lock Requests) are generated with the names ENQUEUE_<lockobjectname> and DEQUEUE_<lockobjectname>.

If data records are to be locked, you must call function module ENQUEUE_<lockobjectname>. The values of the key fields that specify the records to be locked are passed for all the tables contained in the lock object when the function module is called. There is a generic lock if a value is not passed for all the key fields. The function module writes the appropriate lock entry (see Example for Lock Objects). If another program also requests a lock, it will be accepted or rejected depending on the lock mode (see Lock Collisions). The program can then react to this situation.

Locked data records can be unlocked by calling function module DEQUEUE_<lockobjectname>. The key values and the lock mode used to set the lock must be passed to the function module.

This lock procedure requires that all programs involved cooperate. Inconsistencies can occur if a program reads or changes data without having previously locked it. When a lock is set, the data records are only protected against changes by another program if this program also requests a lock before accessing the data.

Instead of writing lock requests or lock releases directly in the lock table, it is also possible to collect them first in a local lock container. The collected locks can be sent at a later time as a group. A parameter of the relevant function module controls whether a lock request or lock release is sent directly.

You can find further information about the lock concept and how lock management works in the documentation The R/3 Lock Concept.

<a href="http://help.sap.com/saphelp_470/helpdata/en/cf/21eed9446011d189700000e8322d00/frameset.htm">http://help.sap.com/saphelp_470/helpdata/en/cf/21eed9446011d189700000e8322d00/frameset.htm</a>

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Balaram,

The SAP system is equipped with a special lock mechanism that synchronizes access to data on the database. 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. A lock entry is a specific instance of a lock object and locks a certain database object, such as a correction entry or a table entry.

Lock entries are usually set and deleted automatically when user programs access a data object and release it again.

We use transaction SM12 to display, check, and delete lock entries. This may be necessary if the SAP dispatcher, the operating system, or the network connection fails, and the dispatcher cannot delete lock entries. In this case, invalid lock entries remain effective and block access to the locked data when the system is restarted.

Types of locks

Shared lock S (Shared)

Several users (transactions) can access locked data at the same time in display mode. A request for another shared lock is accepted, even if it comes from another user. An exclusive lock set on an object that already has a shared lock will be rejected.

Exclusive lock E (Exclusive)

An exclusive lock protects the locked object against all types of locks from other transactions. Only the same lock owner can reset the lock (accumulate).

Exclusive but not cumulative lock X (eXclusive non-cumulative)

Exclusive locks can be requested several times from the same transaction and are processed successively. In contrast, exclusive but not cumulative locks can be called only once from the same transaction. Each further lock request will be rejected.

Optimistic lock O (Optimistic)

Optimistic locks initially behave like shared locks and can be converted into exclusive locks

Hope it helps.

Regards,

Priyanka