‎2009 May 24 2:17 AM
Hi Gurus,
I want to lock sap standard table BDRGIN via my program.
I want to use the ENQUEUE and DEQUEUE function modules.
But i am not aware of the steps to be done. Also explain me what is lock object.
How we define it in SE11. is it required prior to the use of ENQUEUE and DEQUEUE function modules?
Thanks in advance
Regards,
Lakshminarasimhan.N
‎2009 May 24 3:12 AM
Hi,
Following are the steps:
1.Go to SE11.
2. Select the Option: Lock Object
3. Give any name for the Lock Object start with "EZ" . For any User defined Lock Object,
"EZ" should be prefiexed and followed with the user defined name.
Say, for example, "EZ_BDRGIN".
4. Give Meaningful Short Description
5. Give the Table Name as "BDRGIN" against Name under Primary Table Block.
6. Select Lock Mode:
SAP Provide three type of Lock objects.
- Read Lock(Shared Locked)
protects read access to an object. The read lock allows other transactions read access but not
write access to the locked area of the table
- *Write Lock(exclusive lock) (DEFAULT LOCK provided by SAP*)
protects write access to an object. The write lock allows other transactions neither read nor
write access to the locked area of the table.
- Enhanced write lock (exclusive lock without cumulating)
works like a write lock except that the enhanced write lock also protects from further accesses
from the same transaction.
7. Go to the TAB "Lock Parameter"
You will find all the Primary Key Field of Table here. Select whaever the field you want,
with that the Lock need to be created.
8. Activate It.
9. Now, the system will create 2 Function Modules such as:
EZ_BDRGIN_ENQUEUE --> For locking the table
EZ_BDRGIN_DEQUEUE --> For Unlocking the table10. Also, Look at the URL for how to call the function modules through the ABAP Programs:
http://help.sap.com/saphelp_nw04/helpdata/en/cf/21eebf446011d189700000e8322d00/content.htm
All the best,
Rgds,
Ramani N
‎2009 May 24 6:48 AM
Hi raghavendra ,
Yes you need to access SE11 before going for lock concept,
Before applying locking in your programs,
you must create lock objects for that particular set of data. You can create new lock objects or display (or change) existing ones via the standard ABAP Dictionary (SE11) transaction. Typical examples of lock objects are:
E_TABLES:Shared Lock Object for Table Views
ESRDIRE:Lock Objects for ABAP/4 programs
EPPRELE:Lock Object for Employee Number Range
Here, the lock conditions and lock modes are specified.
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.
Sample program for your reference
report zsritab_enqueue.
* testing the locking of tables...
data:
varkey like rstable-varkey.
varkey = sy-mandt.
* locking the tables............................
call function 'ENQUEUE_EZ_TABLE' EZ_BDRGIN
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.Edited by: SRIKANTH P on May 24, 2009 11:18 AM
‎2009 May 24 10:14 AM
Hi,
Search the SCN..How to create the LOCK objects and how to use them in the program.
You can find the lot of threads aleardy questioned and answered.