04-03-2007 9:56 AM
04-03-2007 9:59 AM
Hi Narendra,
Use the Enqueue and Dequeue FM to lock and unlock the entries within the program which we want as per the requirement.
Also try to avoid multiple threads for the same question.
Hope this resolves your query.
Reward all the helpful answers.
Regards
04-03-2007 10:06 AM
04-03-2007 10:15 AM
Hi Narendra,
For lock the table use the FM ENQUE and pass your table name to that FM.
For unlock use FM DEQUE and pass your table name to that FM>
Hope this helps you, reply for queries, Shall post you the updates.
Regards.
Kumar
06-21-2007 9:58 AM
Hi
Could you also advise me the same , I tried to use the Fm ENQUEUE_E_TABLE and ENQUEUE_E_TABLE and DEQUEUE_E_TABLE . Put a break point in between the FMs in the program but I am still able to update the same database table from other programs .
Any suggestions will be appreciated .
06-21-2007 12:55 PM
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.
report zenqueue.
* testing the locking of tables...
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
you can create your own lock objects using SE11.
if you create lock objects on any table system will create two function modules.
1.ENQUEUE....
2.DEQUEUE.....
first one is used to lock the table
second one used to removing lock on the table.
*----
lock Table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
tabname = table_name
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
*----
Unlock Table
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
tabname = table_name
check this link :
http://help.sap.com/saphelp_40b/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
Girish