Input parameters for ENQUEUE/DEQUEUE Functions .
- SAP Lock
Mechanism –
A closer look at the lock FM parameters
which is used commonly by transactional
processes.
****************************************************
X_
A further parameter X_ that defines the lock behavior when the initial value is passed exists for every
lock field . If the initial value is assigned to and X_, then a generic lock is initialized with respect to . If
is assigned the initial value and X_ is defined as X, the lock is set with exactly the initial value of .
Well , this means if you need a parameters initial value to lock , you must set X_ = 'X' for this purpose
otherwise it locks entire values.
_SCOPE
1: Locks or lock releases are not passed to the update program. The lock is removed when the
transaction is ended.
2: The lock or lock release is passed to the update program. The update program is responsible for
removing the lock. The interactive program with which the lock was requested no longer has an
influence on the lock behavior. This is the standard setting for the ENQUEUE function module.
3: The lock or lock release is also passed to the update program. The lock must be removed in both the
interactive program and in the update program. This is the standard setting for the DEQUEUE function
module.
Meaning of the _SCOPE Values
Value Description
_SCOPE = 1 The lock belongs only to the dialog owner (owner_1), and
therefore only exists in the dialog transaction.
The DEQUEUE call or the end of the transaction,
not COMMIT WORK or ROLLBACK WORK, cancels the lock.
_SCOPE = 2 The lock belongs to the update owner (owner_2) only.
Therefore, the update inherits the lock when CALL
FUNCTION ‘…‘ IN UPDATE TASK and COMMIT
WORK are called. The lock is released when the update
transaction is complete. You can release the lock before it is
transferred to the update using ROLLBACK
WORK. COMMIT WORK has no effect, unless CALL
FUNCTION ‘…‘ IN UPDATE TASK has been called.
_SCOPE = 3 The lock belongs to both owners (owner_1 and owner_2). In
other words, it combines the behavior of both. This lock is
canceled when the last of the two owners has released it.
MODE_
S (read lock)
E (write lock)
X (extended write lock)
O (optimistic lock)
Locks Modes
Type of Lock Lock mode Description
Shared lock S (Shared) Several users (transactions) can access
locked data at the same time in display mode.
Requests from further shared locks are
accepted, even if they are from different
users. An exclusive lock set on an object that
already has a shared lock will be rejected.
Exclusive lock E (Exclusive) An exclusive lock protects the locked object
against all types of locks from other
transactions. Only the same lock owner can
reset the lock (accumulate).
Exclusive but not X (eXclusive non- Whereas exclusive locks can be requested
cumulative lock cumulative) several times by the same transaction and
released one by one, an exclusive, non-
cumulative lock can only be requested once
by the same transaction. Each further lock
request will be rejected.
Optimistic lock O (Optimistic) Optimistic locks initially behave like shared
locks and can be converted into exclusive
locks. See Optimistic Locks.
_COLLECT
Initial Value: The lock request or lock release is sent directly to the lock server.
X: The lock request or lock release is placed in the local lock container. The lock requests and lock
releases collected in this lock container can then be sent to the lock server at a later time as a group
by calling the function module FLUSH_ENQUEUE.
_WAIT
Initial Value: If a lock attempt fails because there is a competing lock, the exception FOREIGN_LOCK is
triggered.
X: If a lock attempt fails because there is a competing lock, the lock attempt is repeated after waiting
for a certain time. The exception FOREIGN_LOCK is triggered only if a certain time limit has elapsed
since the first lock attempt. The waiting time and the time limit are defined by profile parameters.
_SYNCHRON
If X is passed, the DEQUEUE function waits until the entry has been removed from the lock table.
Otherwise it is deleted asynchronously, that is, if the lock table of the system is read directly after the
lock is removed, the entry in the lock table may still exist.
Exceptions of the ENQUEUE Function
Module
FOREIGN_LOCK: A competing lock already exists. You can find out the name of the user holding the
lock by looking at system variable SY-MSGV1.
SYSTEM_FAILURE: This exception is triggered when the lock server reports that a problem occurred
while setting the lock. In this case, the lock could not be set.
Ref : The SAP Lock Concept
Ref : SAP Documentation LOCK OBJECTS
How to check db locks in SAP?
Tcode DB01 - Used to identify/trace the deadlocks of your tables. Tcode SM12 - Used to check any other
objects or any other user is locking the table or object. Goto SM12 -> put user name = "*" and execute.
Now, check for your table which showing the lock in the
Tcode DB01 - Used to identify/trace the deadlocks of your tables.
Tcode SM12 - Used to check any other objects or any other user is locking the table or object.
Goto SM12 -> put user name = "*" and execute.
Now, check for your table which showing the lock in the entries.
There you can delete the lock entries.
Goto DB01 -> it will show you the exclusively locked objects & status.
Create Lock Object in ABAP, ENQUEUE and DEQUEUE
https://www.youtube.com/watch?v=rFaoKzpu3s8
48 - ABAP Dictionary - Lock Objects – Introduction
https://www.youtube.com/watch?v=IU2NjcDLybU
49 - ABAP Dictionary - Lock Objects - Lock Entries
https://www.youtube.com/watch?v=VG0S2vnZWg4
50 - ABAP Dictionary - Lock Objects - Lock Modes Part1
https://www.youtube.com/watch?v=RVhJcj2fWEM
51 - ABAP Dictionary - Lock Objects - Lock Modes Part2
https://www.youtube.com/watch?v=Qu5K2uA43u4
52 - ABAP Dictionary - Lock Objects - Creation
https://www.youtube.com/watch?v=OxTUUc8Q9LM
EZ or EY
53 - ABAP Dictionary - Lock Objects - Lock Modules
https://www.youtube.com/watch?v=U-46bA6lrAo
54 - ABAP Dictionary - Lock Objects - Use of Lock Object in a Program Part1
https://www.youtube.com/watch?v=fVIIS6dhYz8
55 - ABAP Dictionary - Lock Objects - Use of Lock Object in a Program Part2
https://www.youtube.com/watch?v=EfqiCOAAjMk
56 - ABAP Dictionary - Lock Objects - Use of Lock Object in a Program Part3
https://www.youtube.com/watch?v=bgZoZdCOAI4
57 - ABAP Dictionary - Lock Objects - Use of Lock Object in a Program Part4 (Debug)
https://www.youtube.com/watch?v=VkBUFlj-t14
58 - ABAP Dictionary - Lock Objects - Use of Lock Object in a Program Part5 (Write lock)
https://www.youtube.com/watch?v=xIkbLuGU_Oo
59 - ABAP Dictionary - Lock Objects - Use of Lock Object in a Program Part6
https://www.youtube.com/watch?v=0s0gqbpxpcg
SY-MSGV1 is the user who have locked the record
60 - ABAP Dictionary - Lock Objects - Use of Lock Object in a Program Part7
https://www.youtube.com/watch?v=BcZBSRHhtVw
61 - ABAP Dictionary - Lock Objects - Practical Difference of Write Lock and Enhanced Write Lock
https://www.youtube.com/watch?v=bu1IbkPPuyg
difference between E and X
62 - ABAP Dictionary - Lock Objects - Allow RFC
https://www.youtube.com/watch?v=VpiOag_ICFI
lock object creation
https://www.youtube.com/watch?v=PEyci4WmUgU
SAP Lock and Database Lock ( SAP Lock Object )
https://www.youtube.com/watch?v=TIfhRnL5GJI
Enqueue and Dequeue Function Module ( SAP Lock Object )
https://www.youtube.com/watch?v=pB7y8D4H4K4
32:12
SM12