07-17-2006 2:02 PM
Hi.
Can anyone tell me the function modules used to lock and unlock database table.
Rgds,
Simran
07-17-2006 2:06 PM
Hi,
Lock:
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
tabname = 'ZTABLE'
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
Unlock:
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
tabname = 'ZTABLE'.
Rgds,
Prakash
07-17-2006 2:04 PM
07-17-2006 2:06 PM
Hi,
Lock:
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
tabname = 'ZTABLE'
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
Unlock:
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
tabname = 'ZTABLE'.
Rgds,
Prakash
07-17-2006 2:08 PM
Check FM <b>'ENQUEUE_E_TABLE'/ 'DEQUEUE_E_TABLE'</b>
Check this link out
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.
Regards,
Santosh
Message was edited by: Santosh Kumar P
07-17-2006 2:06 PM
Hello Simran,
Do U want to lock which table.
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.
If useful reward points.
Regards,
Vasanth
07-17-2006 2:12 PM
07-17-2006 2:13 PM
Hi Simran,
You can create Lock Objects in SE11.
1) Goto SE11
2) In Lock Objects give name starting with <b>E</b>
3) Give Table Name in TABLE TAB and Lock Mode
4) Activate it.
After activation two FM's will be created.
<b>DEQUEUE_EZZTEST</b> Release lock on object EZZTEST
<b>ENQUEUE_EZZTEST</b> Request lock for object EZZTEST
Where EZZTEST is your Lock Object Name.
You can then use these Fm's for Locking(<b>ENQUEUE_EZZTEST</b>) the DB table and unlocking(<b>DEQUEUE_EZZTEST</b>) them.
Consider this sample code.
REPORT zzabap_advusers .
DATA : t_ydvp_user_master TYPE STANDARD TABLE OF ydvp_user_master,
wa_ydvp_user_master TYPE ydvp_user_master,
userid TYPE ydvp_user_master-userid.
DATA : int(4) TYPE c VALUE '8240'.
CONSTANTS : ssn(3) TYPE c VALUE 'SSN'.
START-OF-SELECTION.
*Lock the table
CALL FUNCTION 'ENQUEUE_EZZTEST'
EXPORTING
mode_ydvp_user_master = 'E'
mandt = sy-mandt
userid = userid "Primary Key
x_userid = ' '
_scope = '1'
_wait = ' '
_collect = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*Perform SQL operations on it .
REFRESH t_ydvp_user_master.
CLEAR wa_ydvp_user_master.
wa_ydvp_user_master-userid = 'ADMIN'.
APPEND wa_ydvp_user_master TO t_ydvp_user_master.
CLEAR wa_ydvp_user_master.
DO 15 TIMES.
CONCATENATE ssn int INTO wa_ydvp_user_master-userid.
CONDENSE wa_ydvp_user_master-userid NO-GAPS.
APPEND wa_ydvp_user_master TO t_ydvp_user_master.
CLEAR wa_ydvp_user_master.
int = int + 1.
ENDDO.
MODIFY ydvp_user_master FROM TABLE t_ydvp_user_master.
IF sy-subrc EQ 0.
MESSAGE 'Update Successful' TYPE 'S'.
ELSE.
MESSAGE 'Update Unsuccessful' TYPE 'E'.
ENDIF.
*Release the Lock
CALL FUNCTION 'DEQUEUE_EZZTEST'
EXPORTING
mode_ydvp_user_master = 'E'
mandt = sy-mandt
userid = userid "Primary Key
x_userid = ' '
_scope = '3'
_synchron = ' '
_collect = ' '.
Using <b>SM12</b> transaction you can view DB tables presently Locked.
Refer to this Link for further Info.
<a href="http://help.sap.com/saphelp_di471/helpdata/EN/cf/21ea0b446011d189700000e8322d00/frameset.htm">http://help.sap.com/saphelp_di471/helpdata/EN/cf/21ea0b446011d189700000e8322d00/frameset.htm</a>
Regards,
Arun Samabrgi
Message was edited by: Arun Sambargi
07-17-2006 2:16 PM
Hi Simran,
If you want to lock your Ztables then create the lock objects using TXN SE11. The Lock Object name should start with EZ or EY. when you will activate the Lock Object which you created a FM will be created automatically with the name ENQUEUE_(name of lock object) for locking and DEQUEUE_(name of lock object) for unlocking.
Hope this helps You.
Regards,
Seema.
07-26-2006 10:59 AM
Hi, I want to rock some records in the Ztabs
specifyig the fields those are not primary key.
for example,the Pkey of ZTAB is MANDT and BUKRS.
However, I want to rock some records specifying
MANDT, BUKRS, and ZFIELD1, ZFIELD2...
DOES "ENQUEUE_E_TABLES" works?
DOES ANYBODY know another solution?
Thanks.