Show TOC Start of Content Area

Object documentation Lock Objects  Locate the document in its SAP Library structure

Definition

The SAP system synchronizes several users’ simultaneous access to the same data records with a lock mechanism. When interactive transactions are programmed, the system sets and releases locks 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

In a lock object, you must define the tables in which data records must be locked with a lock request, and the key fields of these tables. When you select the tables, you must first select the primary table. You can also add further tables (secondary tables), using foreign key relationships (see Conditions for Foreign Keys). The following figure shows a primary table and its relations with two other tables (secondary tables).

This graphic is explained in the accompanying text

Lock Arguments

The lock argument of a table in the lock object 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 rows to be locked or unlocked are specified by defining certain values in these fields. These values can also be generic. The lock argument fields define which subset of the table rows must be locked.

This graphic is explained in the accompanying text

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. You can also include several tables in a lock object. A lock request can lock not only a record of a table, but also an entire logical object. Such a logical object can be a document comprising an entry in a header table and N entries in a position table, for example. The figure below shows the locked records in an example with three tables.

This graphic is explained in the accompanying text

Note

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

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

Example

Table SFLIGHT in the flight model contains all the scheduled flights of a carrier. Field SEATSMAX contains the number of seats available. Field SEATSOCC contains the number of seats already booked. If a booking is made for a customer (by a travel agency or sales desk), you must check whether there are enough seats available. The number of seats booked increases when the booking is made.

This mechanism must ensure that two sales desks 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 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 sales desk also wants to book seats for this flight, the lock prevents the flight from being overbooked.

See also:

Example of Lock Objects

Creating Lock Objects

Deleting Lock Objects

 

 

End of Content Area