‎2008 Aug 28 9:23 AM
plz let me know if nybody know how to lock the records of a z table that can be displayed in an editable alv . if user1 clicks on edit the record needs to be locked for all other users. if user1 clicks on update the lock is released.
thanks in advance.
‎2008 Aug 28 9:25 AM
You need to create lock objects(SE11) and lock the entries using ENQUEUE & DEQUEUE functions
~Piyush Patil
‎2008 Aug 28 9:25 AM
Hi,
I think you need not to do anything explicitly. It is automaticaly taken care by the internal system of SAP.
check
http://help.sap.com/saphelp_nw04/Helpdata/EN/7b/f9813712f7434be10000009b38f8cf/content.htm
http://help.sap.com/saphelp_nw70/helpdata/en/41/7af4c5a79e11d1950f0000e82de14a/content.htm
Reagrds,
Anirban
‎2008 Aug 28 9:30 AM
Hi Sohi,
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 Aug 28 9:32 AM
hi,
While User Press Edit Button first you have to call
ENQUEUE_E_TABLE Function module to lock the Z table.
And When user clicks on Update button Call FM DEQUEUE for unlocking the Records of the TAble.
Regards
Sumit Agarwal
‎2008 Aug 28 9:32 AM
i've already created a lock object on the table.
the 2 fm's have also been created.
then on click of edit the records that are selected need to be locked.
i've taken the records in an internal table n looped it with the fm calling for lock f or each wa entries but it doesn't lock the object.
‎2008 Aug 28 9:51 AM
Hi,
U cannot lock a single record. The table can be locked using the FM's. If u want to lock it in record level, the record should contain an object, such as Material no, delivery no, etc... So only when objects are there in ur record u can lock otherwise it is not possible.... in record level...
Success........