Lock Objects

The R/3 System synchronizes simultaneous access of several users to the same data records with a Lock Mechanism . When interactive transactions are programmed, locks are set and released by calling function modules (see Function Modules for Lock Requests ). These function modules are automatically generated from the definition of lock objects in the ABAP Dictionary.

Structure of a Lock Object

The tables in which data records should be locked with a lock request are defined in a lock object together with their key fields. When tables are selected, one table (the primary table) is first selected. Further tables (secondary tables) can then be selected using the foreign key relationships (see also Conditions Required of Foreign Keys ).

Lock Arguments

The lock argument of a table consists of the key fields of the table.

The lock argument fields of a lock object are used as input parameters in the function modules for setting and removing locks generated from the lock object definition. When these function modules are called, the table lines that are to be locked or unlocked are specified by indicating certain values in these fields. The lock argument fields therefore define which subset of the table lines should be locked.

The simplest case of a lock object consists of exactly one table and the lock argument of the table is the primary key of this table. Several tables can also be included in a lock object. A lock request therefore can lock an entire logical object, and not only a record of a table. Such a logical object can be for example a document comprising an entry in a header table and N entries in a position table.

Locks can also be set from programs in other systems with the corresponding interfaces if the lock object was defined with RFC permission.

A Lock Mode can be assigned for each table in the lock object. This mode defines how other users can access a locked record of the table.

Table SFLIGHT in the Flight Model contains all the scheduled flights of a carrier. Field SEATSMAX contains the number of available seats and field SEATSOCC contains the number of booked seats. When a booking is made for a customer (by a travel agency or carrier counter), a check must be made whether there are enough seats available. If there are, the number of seats booked is incremented.

This mechanism must ensure that two counters do not make the same booking at the same time and that the flight is not overbooked.

This can be done by creating lock object ESFLIGHT. Only the table SFLIGHT must be included in this lock object. The flight can then be locked (with the function modules generated from the lock object) during the booking. If another counter also wants to book seats for this flight, the lock will prevent the flight from being overbooked.

See also:

Creating Lock Objects

Changing Lock Objects

Deleting Lock Objects