‎2008 Jul 14 5:54 PM
Hi,
I have a couple of custom tables and many users are going to deal with a custom transaction which will be using these tables. Simultaneous access is possible. I have to handle table locking issues ? What are the issues and what are the best ways to handle the same ? Please suggest.
thks
‎2008 Jul 14 6:00 PM
Hi Friend,
We can use the function modules ENQUEUE_E_TABLE for locking tables and the function module DEQUEUE_E_TABLE for unlocking tables. With this method, we don't need to lock objects in order to lock the tables. In other words, any table can be locked/unlocked using these function modules.
Check this sample code:
*Locking Table*
data:
varkey like rstable-varkey.
varkey = sy-mandt.
locking the tables............................
call function 'ENQUEUE_E_TABLE'
exporting
MODE_RSTABLE = 'E'
tabname = 'MARA'
varkey = varkey
X_TABNAME = ' '
X_VARKEY = ' '
_SCOPE = '2'
_WAIT = ' '
_COLLECT = 'X'
exceptions
foreign_lock = 1
system_failure = 2
others = 3
.
case sy-subrc.
when 1.
message i184(bctrain) with 'Foreignlock'.
when 2.
message i184(bctrain) with 'system failure'.
when 0.
message i184(bctrain) with 'success'.
when others.
message i184(bctrain) with 'others'.
endcase.
unlocking the table
call function 'DEQUEUE_E_TABLE'
exporting
MODE_RSTABLE = 'E'
tabname = 'MARA'
varkey = varkey
X_TABNAME = ' '
X_VARKEY = ' '
_SCOPE = '3'
_SYNCHRON = ' '
_COLLECT = ' '
Hope this helps you.
Regards,
Chandra Sekhar
‎2008 Jul 14 5:57 PM
Hi,
Create lock objects for the tables in SE11..Then use the enqueue function module to lock the record and dequeue function module to unlock the record..
The Dequeue and enqueue function modules will be automatically generated when the lock object is activated in SE11.
Check the standard sap help to create lock objects
http://help.sap.com/saphelp_nw70/helpdata/en/cf/21eef3446011d189700000e8322d00/content.htm
Thanks
Naren
‎2008 Jul 14 6:00 PM
Hi Friend,
We can use the function modules ENQUEUE_E_TABLE for locking tables and the function module DEQUEUE_E_TABLE for unlocking tables. With this method, we don't need to lock objects in order to lock the tables. In other words, any table can be locked/unlocked using these function modules.
Check this sample code:
*Locking Table*
data:
varkey like rstable-varkey.
varkey = sy-mandt.
locking the tables............................
call function 'ENQUEUE_E_TABLE'
exporting
MODE_RSTABLE = 'E'
tabname = 'MARA'
varkey = varkey
X_TABNAME = ' '
X_VARKEY = ' '
_SCOPE = '2'
_WAIT = ' '
_COLLECT = 'X'
exceptions
foreign_lock = 1
system_failure = 2
others = 3
.
case sy-subrc.
when 1.
message i184(bctrain) with 'Foreignlock'.
when 2.
message i184(bctrain) with 'system failure'.
when 0.
message i184(bctrain) with 'success'.
when others.
message i184(bctrain) with 'others'.
endcase.
unlocking the table
call function 'DEQUEUE_E_TABLE'
exporting
MODE_RSTABLE = 'E'
tabname = 'MARA'
varkey = varkey
X_TABNAME = ' '
X_VARKEY = ' '
_SCOPE = '3'
_SYNCHRON = ' '
_COLLECT = ' '
Hope this helps you.
Regards,
Chandra Sekhar