‎2006 Sep 21 7:26 AM
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
‎2006 Sep 21 7:31 AM
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.
‎2006 Sep 21 7:36 AM
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
‎2006 Sep 21 7:37 AM
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.
‎2006 Sep 21 7:42 AM
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>
‎2006 Sep 21 7:43 AM
Hello,
Check for the exception FORIEGN_LOCK raised by that FM.
Regs,
Venkat Ramanan N
‎2006 Sep 21 7:47 AM
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
‎2006 Sep 21 7:55 AM