Monday, April 27, 2009

Lock Objects

These types of objects are used for locking the access to database records in table. This mechanism is used to enforce data integrity that is two users cannot update the same data at the same time. With lock objects you can lock table-field or whole table.

In a system where many users can access the same data, it becomes necessary to control the access to the data. In R/3 system this access control is built-in on database tables. Developers can also lock objects over table records.

To lock an object you need to call standard functions, which are automatically generated while defining the lock object in ABAP/4 dictionary. This locking system is independent of the locking mechanism used by the R/3 system. Whenever an object is locked, either by in built locking mechanism or by function modules, it creates corresponding entry in global system table i.e. table is locked. The system automatically releases the lock at the end of transaction.

Creating Lock Objects

Lock object is an aggregated dictionary object and can be defined by using the following steps:

1. From initial data dictionary screen, enter the name for the object, Click Lock object radiobutton and then click on Create. The system displays a dialog box for Maintain Lock Objects screen
2. Enter short text as usual and the name for primary table.
3. Save
4. Select Tables option
From this screen you can: Select secondary tables, if any, linked by foreign key relationship.

Fields for the lock objects. This option allows you to select fields for objects (R/3 system allows locking up to record level). Lock object argument are not selected by user but are imposed by the system and includes all the primary keys for the table.


Types of locks

You can lock the table or record by using following types of locking:

Exclusive (E) or Read mode: The locked data can only be displayed or modified by single user i.e. the owner of the object. Access to other users is denied.

Shared (S) or Write Mode: Several users can access the same record simultaneously, but only in display mode and except the first one, who has asked for the data in update mode.

Exclusive not cumulating (X) it is similar to exclusive lock. It allows only a single user access. E can be called several times from the same transaction. In contrast, a lock type X can be called only once during the transaction. Any other call for this lock is rejected.

When you activate the lock object, the functions are automatically generated. And these are ENQUEUE-EZN and DEQUEUE-EZN. EZN is name of the lock object.

While ENQUEUE is used in program to set the code over the selected data depending upon the lock object arguments. DEQUEUE is used to release the lock.

4 comments:

  1. you have covered all usable basics.. thnks for post.. its rely usefull to revise in a minute

    ReplyDelete
  2. Thank you, But the shared and exclusive is confusing by its name, Bcoz, check this link http://www.erpgreat.com/abap/type-and-uses-of-lock-objects-in-sap.htm, They just reciprocal ur concept.

    ReplyDelete
  3. Really Good One... Thanks

    ReplyDelete