Why Lock Objects Are Important ?
Taking the standard SAP example of flights.
Tables Involved:
T000 : Client table
SCURX : Currencies (key: currency key)
SBUSPART : Business partner (key: client, partner number)
STRAVELAG : Travel agencies (key: client, travel agency number)
SCUSTOM : Customers (key: client, customer number)
SCARR : Carriers (key: client, carrier ID)
SCOUNTER : Sales counters (key: client, carrier ID, sales counter number)
SPFLI : Flight schedule (key: client, carrier ID, connection number)
SFLIGHT : Flights (key: client, carrier ID, connection number, date of flight)
SBOOK : Flight bookings (key: client, carrier ID, connection number, date of flight, booking number, customer number)
When booking flights (see 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.
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)
ENQUEUE_ E_BOOKING (release locks)
These function modules can now be linked to ABAP programs.