Entering content frameThis graphic is explained in the accompanying text Example for Lock Objects Locate the document in its SAP Library structure

When booking flights (see Structure link Flight Model) it is important to prevent flights from being overbooked. For this reason, you have to lock the particular flight as well as all the bookings existing for this flight during processing. You can do this with lock object E_BOOKING.

The flights are recorded in table SFLIGHT and the bookings for the flights in table SBOOK. The two tables are linked with a foreign key. Lock object E_BOOKING must therefore contain table SFLIGHT as primary table and table SBOOK as further table.

This graphic is explained in the accompanying text

The lock argument of table SFLIGHT thus contains the fields MANDT, CARRID, CONNID, and FLDATE. The lock argument of table SBOOK thus contains the fields MANDT, CARRID, CONNID, FLDATE, BOOKID and CUSTOMID.

Select exclusive lock mode, that is the locked data can only be displayed and edited by one user.

When the lock object is activated, the following function modules are generated from its definition:

These function modules can now be linked to ABAP programs.

The following example shows how function module ENQUEUE_ E_BOOKING is called.

This graphic is explained in the accompanying text

With this call, flight LH 400 on Nov. 29,1998 is exclusively (lock mode E) locked in table SFLIGHT together with all the bookings entered in table SBOOK for this flight (since the initial value 0 is transferred for BOOKID and CUSTOMID). The lock is sent to the update program (_SCOPE = ‘2’). If there is a lock conflict, another attempt is made to set the lock after a certain time (_WAIT = ‘X’).

The set locks can be removed by calling the function module DEQUEUE_E_BOOKING as follows:

This graphic is explained in the accompanying text

The existing exclusive lock entries for flight LH 400 are deleted in table SFLIGHT and the bookings for this flight are deleted in table SBOOK. The request to delete the lock entries is passed on to the update program (_SCOPE = ‘3’).

See also:

Function Modules for Lock Requests

Leaving content frame