Application Development and Automation 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: 
Read only

Help regarding Table Lock

Former Member
0 Likes
1,004

Hi folks,

I am writing a FM to insert data into a Z table, but before inserting the data I have to check if the Z table is locked or not. If the table is locked I have to wait for lock to disappear and then continue processing.

I am using FM 'ENQUEUE_E_TABLE' to lock the table but is there is any way to find out when the lock is released?

Thanks in Advance,

Punit

7 REPLIES 7
Read only

Former Member
0 Likes
932

Hi,

One of the exceptions raised by 'ENQUEUE_E_TABLE' is FORIEGN_LOCK. SO if this exception is raised then your table will not get locked.

So i think it is taken care of automatically.

Read only

Former Member
0 Likes
932

Hi

After calling fm ENQUEUE_E_TABLE you have to check the SY-SUBRC, if it' zero it means the table is unlocked.

Remember the lock is automatically released only at the end of trx.

Max

Read only

0 Likes
932

If u want lock ur Ztables then create the lock objects for the same using Tcode SE11. The Lock Object name should start with EZ or EY.

Once u activated the Lock Object which u have created a Fm will be created automatically with the name ENQUEUE_EZ(name) for locking and DEQUEUE_EZ(NAME).

Use these FM for locking and unloking.

same procedure can be followed for the Std. Tables also.

refer for example..

if useful reward points.

Read only

Former Member
0 Likes
932

Hi Punit,

Releasing of Lock depends on the person who is using that particular Lock, u cannot blindly wait for the lock to be released, one thing you can try out is call the Enqueue FM(lock) in the PBO of the dialog program and the Dequeue FM(Unlock) just before you come out of the transaction, thats the probable solution what i feel from your question. For any clarrification Revert back.

Cheers...

<b>Santosh.D</b>

Read only

Former Member
0 Likes
932

Hello,

Check for the exception FORIEGN_LOCK raised by that FM.

Regs,

Venkat Ramanan N

Read only

Former Member
0 Likes
932

Thanks Every body for help,

The problem I am facing is suppose I make an attempt to lock the Z table with my ID, but I it was already locked by some another user. Now I have to wait for the lock by another user to release and then lock the table with my ID.

How can I check when the other user will release the lock and I can lock the table with my ID?

Thanks,

Punit

Read only

0 Likes
932

check out tcode SM12 for Lock Entries

Cheers..

<b>Santosh.D</b>