0% found this document useful (0 votes)
185 views4 pages

Database Locking Using Enque and Deque

SAP provides database locking using ENQUEUE and DEQUEUE functions to restrict access to data during updates. The document outlines steps to create a lock object in SE11, call ENQUEUE_EZ to lock table entries with specified key fields before updates, and call DEQUEUE_EZ to remove the lock after updates. It also provides optional code to read existing lock details using ENQUEUE_READ.

Uploaded by

Kishore Reddy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
185 views4 pages

Database Locking Using Enque and Deque

SAP provides database locking using ENQUEUE and DEQUEUE functions to restrict access to data during updates. The document outlines steps to create a lock object in SE11, call ENQUEUE_EZ to lock table entries with specified key fields before updates, and call DEQUEUE_EZ to remove the lock after updates. It also provides optional code to read existing lock details using ENQUEUE_READ.

Uploaded by

Kishore Reddy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

http://www.architectsap.com/blog/sap/sap-abap-webservices-creation-options/ http://www.sapdev.co.uk/dictionary/lock_enqueue.

htm
SAP Database locking using ENQUEUE and DEQUEUE

SAP provides you with the ability to restrict access to data while the table is being updated. This is fairly simple to implement via the use of a lock object (Created in SE11). Step 1 - Create Lock object (SE11)

Step 2 - ABAP code to lock table entries Add the following code in-order to create the table lock. This function module must be called before any update takes place. If a lock has already been taken out it will display the appropriate message.
CALL FUNCTION 'ENQUEUE_EZ_ZTABLENAME' EXPORTING mode_ZTABLENAME = 'E' "E = Write Lock, S = Read Lock, X = Exclusive not cumulative mandt = sy-mandt KEYFIELD1 = "Value KEYFIELD2 = "Value KEYFIELD3 = "Value ... * X_KEYFIELD1 = ' ' * X_KEYFIELD2 = ' ' * X_KEYFIELD3 = ' ' ... * _SCOPE = '2' * _WAIT = ' ' * _COLLECT = ' ' * If exceptions are not used, message is displayed within FM EXCEPTIONS FOREIGN_LOCK = 1 SYSTEM_FAILURE = 2 OTHERS = 3. * IF sy-subrc <> 0. Retrieve message displayed within Function Module

message id

sy-msgid type 'I' number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

***************OPTIONAL - Get more details of existing lock * Also within here you can also use ENQUEUE_READ to find out more details about the existing lock data: it_enq type STANDARD TABLE OF SEQG3, wa_enq like line of it_enq, ld_gname type SEQG3-GNAME, ld_garg type SEQG3-GARG, ld_gname = 'ZTABLENAME'. "This is the name of the lock object as shown in tcode SM12 CALL FUNCTION 'ENQUEUE_READ' EXPORTING GCLIENT = SY-MANDT GNAME = ld_gname "Lock opject name GUNAME = '*' "User name, default is SY-UNAME but need to use * to return locks for all users TABLES ENQ = it_enq EXCEPTIONS COMMUNICATION_FAILURE = 1 SYSTEM_FAILURE = 2 OTHERS = 3. "will need to check values returned by FM to check what values are needed to build ld_garg value concatenate sy-mandt KEYFIELD1 KEYFIELD2 KEYFIELD3 into ld_garg . loop at it_enq into wa_enq where garg cs ld_garg. exit. endloop. check sy-subrc eq 0. if wa_enq-guname eq sy-uname. "Entry already being updated by you else. "Entry already being updated by someone else endif. ***************OPTIONAL EXIT. ENDIF.

Step 3 - ABAP code to Remove table lock(s) The following code will remove the lock for the specific table entries.
CALL FUNCTION 'DEQUEUE_EZ_ZTABLENAME' EXPORTING MODE_ZTABLENAME = 'E' MANDT = SY-MANDT mandt = sy-mandt KEYFIELD1 = "Value KEYFIELD2 = "Value KEYFIELD3 = "Value ...

* * * * * *

X_KEYFIELD1 X_KEYFIELD2 X_KEYFIELD3 ... _SCOPE _SYNCHRON _COLLECT .

= ' ' = ' ' = ' ' = '3' = ' ' = ' '

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy