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.
cancel
Showing results for 
Search instead for 
Did you mean: 

Locking a table and then releasing the lock...

Former Member
0 Kudos

Gurus,

I ant to lock a table DMS_LO_CD1 and then do certain upodate and then release the lock after that.

How can I d this ?

Thanks.

Regards,

Rajesh.

1 ACCEPTED SOLUTION

former_member156446
Active Contributor
0 Kudos
* Lock the table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.

IF sy-subrc = 0.

* Modify the database table with these changes
MODIFY (p_table) FROM TABLE <dyn_tab_temp>.

REFRESH <dyn_tab_temp>.

* Unlock the table
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table.

ENDIF.
7 REPLIES 7

former_member156446
Active Contributor
0 Kudos
* Lock the table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.

IF sy-subrc = 0.

* Modify the database table with these changes
MODIFY (p_table) FROM TABLE <dyn_tab_temp>.

REFRESH <dyn_tab_temp>.

* Unlock the table
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table.

ENDIF.

Former Member
0 Kudos

Rajesh,

you can try to create a lock object for this table and then call the function modules that get generated for locking and unlocking the table.

MGS.

Former Member
0 Kudos

Hi,

There are two function modules used to lock and unlock the tables. Those are mentioned below.

Unlocking the table

CALL FUNCTION 'DEQUEUE_E_TABLE'

EXPORTING

tabname = table_name

locking the table

CALL FUNCTION 'ENQUEUE_E_TABLE'

EXPORTING

tabname = table_name

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

Regards,

Midhun Abraham

0 Kudos

How can I create a lock object for a table ? How can I see the lock objects created for the table ?

Regards,

Rajesh.

0 Kudos

http://help.sap.com/saphelp_nw04/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm

https://forums.sdn.sap.com/click.jspa?searchID=115258&messageID=2656474

Do the following steps..

GO TO SE11

Select the radio button "Lock object"..

Give the name starts with EZ or EY..

Example: EYTEST

Press Create button..

Give the short description..

Example: Lock object for table ZTABLE..

In the tables tab..Give the table name..

Example: ZTABLE

Save and generate..

Your lock object is now created..You can see the LOCK MODULES..

In the menu ..GOTO -> LOCK MODULES..There you can see the ENQUEUE and DEQUEUE function

Hope this helps.

Regards,

Midhun Abraham

0 Kudos

Please create a lock object as described by Midhun. To check if there is a lock object for your table follow the steps below

Display the table contents for table DD25L with the selection criteria ROOTTAB = 'Your Table Name' and AGGTYPE = 'E'.

0 Kudos

Hello,

I have found the lock objects. Can someone tell me if I transport lock objects from one system to other the lock function modules also get transported ?

Regards,

Rajesh.