‎2007 Jul 09 6:39 AM
How to lock a database table. I assume that standard SAP tables have ENQUEUE fm.. I need to do for custom tables.
‎2007 Jul 09 6:44 AM
hi,
You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
<b>This will autogenerate two function modules,Enqueue < lock object > and Dequeue < lock object ></b>
Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
Technicaly:
When you create a lock object System automatically creat two function module.
1. ENQUEUE_<Lockobject name>. to insert the object in a queue.
2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.
You have to use these function module in your program.
Eg:
tables:vbak.
call function 'ENQUEUE_EZLOCK3'
exporting
mode_vbak = 'E'
mandt = sy-mandt
vbeln = vbak-vbeln
X_VBELN = ' '
_SCOPE = '2'
_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.
<b>TO LOCK</b>
Execute CALL FUNCTION statement
CALL FUNCTION " ENQUEUE <lock object ">
EXPORTING . . .
EXCEPTIONS . . .
CASE SY-SUBRC.
.
ENDCASE.
<b>TO UNLOCK</b>
Execute the CALL FUNCTION statement
CALL FUNCTION 'DEQUEUE <lock object >'
EXPORTING . .
It is important to unlock the entry so others can update it.
rewards if useful,
regards,
nazeer
‎2007 Jul 09 6:41 AM
‎2007 Jul 09 6:42 AM
hi...
Good ... check out the following documentation
Lock objects are used to lock the database table while making the modifications on the database table.
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
_SCOPE = 1: The lock is not sent to the update program. The lock is removed when the transaction is ended.
_SCOPE = 2: The lock is sent to the update program. The update program is responsible for removing the lock. The dialog program which requested the lock no longer has an influence on the lock behavior. This is the standard setting for the ENQUEUE function module.
_SCOPE = 3: The lock
Managingin lock entries
http://help.sap.com/saphelp_nw04/helpdata/en/37/a2e3ae344411d3acb00000e83539c3/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/7b/f9813712f7434be10000009b38f8cf/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/cb/168237d30d974be10000009b38f8cf/frameset.htm
<b>Reward points if useful</b>
Regards
Ashu
‎2007 Jul 09 6:42 AM
‎2007 Jul 09 6:42 AM
FORM LOCK_ZFISVTAX_GPA_VOL.
CLEAR : V_FLAG.
* Lock database table ZFISVTAX_GPA_VOL
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
MODE_RSTABLE = C_E
TABNAME = C_GPA_VOL
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
IF SY-SUBRC = 0.
V_FLAG = 'X'.
ELSEIF SY-SUBRC = 1.
MESSAGE E000 WITH TEXT-026 C_GPA_VOL
TEXT-027.
ELSEIF SY-SUBRC = 2.
MESSAGE E000 WITH TEXT-026 C_GPA_VOL
TEXT-028.
ELSEIF SY-SUBRC = 3.
MESSAGE E000 WITH TEXT-026 C_GPA_VOL
TEXT-029.
ENDIF.
ENDFORM. " LOCK_ZFISVTAX_GPA_VOL
FORM UNLOCK_ZFISVTAX_GPA_VOL.
* Unlock database table ZFISVTAX_GPA_VOL
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
MODE_RSTABLE = C_E
TABNAME = C_GPA_VOL.
ENDFORM. " UNLOCK_ZFISVTAX_GPA_VOL
Message was edited by:
Santosh Kumar Patha
‎2007 Jul 09 6:44 AM
hi,
You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
<b>This will autogenerate two function modules,Enqueue < lock object > and Dequeue < lock object ></b>
Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
Technicaly:
When you create a lock object System automatically creat two function module.
1. ENQUEUE_<Lockobject name>. to insert the object in a queue.
2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.
You have to use these function module in your program.
Eg:
tables:vbak.
call function 'ENQUEUE_EZLOCK3'
exporting
mode_vbak = 'E'
mandt = sy-mandt
vbeln = vbak-vbeln
X_VBELN = ' '
_SCOPE = '2'
_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.
<b>TO LOCK</b>
Execute CALL FUNCTION statement
CALL FUNCTION " ENQUEUE <lock object ">
EXPORTING . . .
EXCEPTIONS . . .
CASE SY-SUBRC.
.
ENDCASE.
<b>TO UNLOCK</b>
Execute the CALL FUNCTION statement
CALL FUNCTION 'DEQUEUE <lock object >'
EXPORTING . .
It is important to unlock the entry so others can update it.
rewards if useful,
regards,
nazeer
‎2007 Jul 09 6:45 AM
You can create lock objects for your custom table using SE11. Make sure the following thigs
the lock object name should start with E.
Once you create the lock object, you will be created two FM's ENQUEUE<Lock Object Name>
and DEQUEUE<Lock Object Name>
You can use those FM's to lock and unlock your custom tables.
Regards
Gopi
‎2007 Jul 09 6:45 AM
Hi,
*----
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
Refer below link:
https://forums.sdn.sap.com/click.jspa?searchID=3716278&messageID=2354907
<b>Reward points</b>
Regards