Show TOC

 Example of Lock ObjectsLocate this document in the navigation structure

When booking flights, (for more information, see Flight Model ) you have 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 system records the flights 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 contain table SFLIGHT as the primary table and table SBOOK as the secondary table. In the following figure you can see the relations between the primary and the secondary table in our example.

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:

  • ENQUEUE_ E_BOOKING (set locks)
  • DEQUEUE_ E_BOOKING (release locks)

These function modules can now be linked to ABAP programs.

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

With this call, flight LH 400 on November 29,1998 is exclusively locked (lock mode E) in table SFLIGHT. It is locked 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, the system makes another attempt 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:

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