Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
Showing results for 
Search instead for 
Did you mean: 

regarding lock objects

Former Member
0 Kudos

hi gurus,

i have developed a module pool in which i gave one push buttton called save...

under this button i coded some logic,,,,,during the execution of this logic i want that no body can access my customized database table zmseg (for eg) how can i lock my database table during the execution of this logic ...sud i use lock objects concept if yes plz let me know about the coding....step by step...

thnx in advance....

plz help me.


Active Contributor
0 Kudos


Lock objects are used to lock the database table while making the modifications on the database table.

you can create your own lock objects using SE11.

if you create lock objects on any table system will create two function modules.


first one is used to lock the table

second one used to removing lock on the table.

*-------------lock Table
tabname = table_name
foreign_lock = 1
system_failure = 2

*-------------Unlock Table
tabname = table_name

check this link :

_SCOPE = 1: The lock is not sent to the update program. The lock is removed when the transaction is ended.

_SCOPE = 2: The lock is sent to the update program. The update program is responsible for removing the lock. The dialog program which requested the lock no longer has an influence on the lock behavior. This is the standard setting for the ENQUEUE function module.

_SCOPE = 3: The lock is also sent to the update program. The lock must be removed in both the dialog program and by the update program. This is the standard setting for the ENQUEUE function module.



Former Member
0 Kudos

Hi ravi,

Lock objects are used to synchronize access to the same data by more than one program.

General information about the lock mechanism.

You can synchronize access by several programs to the same data with a logical lock mechanism. This lock mechanism fulfills two main functions:

A program can tell other programs which data records it is just reading or changing.

A program can prevent itself from reading data that is just being changed by another program.

When accessing data records, the records just being edited by other programs can be identified by the entry in the lock table. Such an entry for the lock must define a number of fully specified key fields, that is either a value is passed for the key field or this field is locked generically.

To set locks, a lock object must be defined in the ABAP Dictionary. When this lock object is activated, two function modules (see Function Modules for Lock Requests) are generated with the names ENQUEUE_ are generated from its definition to set and release locks.

You can find information about the activation flow in the activation log, which you can display with Utilities ® Activation log. If errors occurred during activation, the activation log is displayed immediately.

Former Member
0 Kudos

<b>Creating Lock Objects</b>

1. Select object type Lock object in the initial screen of the ABAP Dictionary, enter an object name and choose Create. The name of a lock object should begin with an E (Enqueue).

The maintenance screen for lock objects is displayed.

2. Enter an explanatory short text in the field Short text.

You can then use the short text to find the lock object at a later time, for example with the R/3 Repository Information System.

3. Enter the name of the primary table of the lock object.

All other tables in the lock object must be linked with the primary table using foreign keys. There are also some restrictions on the valid foreign key relationships.

4. Select the lock mode of the primary table in the field below it.

The lock mode is used as the default value for the corresponding parameters of the function modules generated from the lock object.

5. Choose Add if you want to lock records in more than one table with the lock object.

A list of all the tables linked with the primary table using valid foreign keys is displayed. Select the appropriate table. The lock mode of the primary table is copied as lock mode. You can change this setting as required, for example you can assign the lock mode separately for each table.

Similarly, you can add a table linked with the secondary table just added with foreign keys. To do this, place the cursor on the name of the secondary table and choose Add.

Note : If no lock mode is assigned to a table, no lock is set for the entries in this table when the generated function modules are called. You should not assign a lock mode if a secondary table was only used to define a path between the primary table and another secondary table with foreign keys.

6. Save your entries.

A dialog box appears in which you have to assign the lock object a development class.

7. You can (optionally) exclude lock parameters from the function module generation on the Lock parameter tab page. This makes sense for example if you always want to lock a parameter generically.

To do this, simply deselect the Weight flag for the parameter. The parameter is not taken into consideration in the generated function modules. This parameter is then always locked generically.

The name of a lock parameter is usually the name of the corresponding table field. If two fields with the same name are used as lock parameters in the lock object from different tables, you must choose a new name for one of the fields in field Lock parameter.

8. You can define whether the function modules generated from the lock object should be RFC-enabled on the Attributes tab page.

If you set the Allow RFC flag, the generated function modules can be called from within another system with Remote Function Call.

If you permit Remote Function Calls for an existing lock object, you must ensure that the generated function modules are called from within an ABAP program with parameters appropriate for the type. You should therefore check all programs that use the associated function modules before activating the lock object with the new option.

9. Activate

<b>When you activate the lock object, the two function modules ENQUEUE_<lockobjectname> and DEQUEUE_<lockobjectname> are generated from its definition to set and release locks.</b>

<b>Suppose u r lock object name is EZmseg

Call the FM ENQUEUE_EZmseg when u want to lock the table in u r program

Call the FM DEQUEUE_EZmseg when u want to release the lock</b>

Active Contributor
0 Kudos

Hi ravi,

SAP uses a so-called cooperative lock concept. That means: If you lock using ENQUEUE, all other programs must check the locks (try to ENQUEUE) befor doing any update.

There is a generic lock object used for all customizing tables. You give the table name as parameter. Open any customizing table in change mode, second session check lock overview to find out lock objects name.



Former Member
0 Kudos

Hello Ravi,

1)Go to <b>se11</b> transaction.

2)Click on lock object radio button and give a lock object name starting with<b> 'E'</b>.For example 'ESAMPLE'.Click <b>CREATE</b>.

3)In the TABLE tab, you can give the table name for which you require a lock.In the <b>LOCK PARAMETERS</b> tab,you can give the table fields based on which the table should be locked.

4)Call a function module in your program<b> ENQUEUE_lockobjectname</b> to obtain a lock on the required table.In our example the FM will be ENQUEUE_ESAMPLE.

5)To release the lock on the table,call the function module <b>DEQUEUE_lockobjectname</b>.In our example the FM will be DEQUEUE_ESAMPLE.



**Reward if answer helps.