SAP SET LOCKS ABAP Statements



Get Example source ABAP code based on a different SAP table
  


ID SET-LOCKS
• SET LOCKS ABAP_STATEMENT_EML
• ENTITY SET LOCKS

SET LOCKS

ABAP_SYNTAX_FORMS

SET LOCKS ENTITY, Short Form
1 SET LOCKS ENTITY entity FROM inst $[ response_param$].

SET LOCKS OF, Long Form
2 SET LOCKS OF bdef
ENTITY entity1 FROM inst1
$[ENTITY entity2 FROM inst2$]
$[...$]
$[response_param$].

SET LOCKS lock_tab, Dynamic Form
3 SET LOCKS lock_tab $[response_param $].

What does it do?
Used to set enqueue locks for RAP BO instances to prevent the concurrent modification of instances. The RAP framework implicitly performs the lock for a subsequent modification. However, if the RAP BO consumer requires an exclusive lock so that no other user can modify the same instance in parallel, the statements can be used. The lock remains active until the end of a RAP transaction.
In the BDEF, the RAP BO root entity must always be specified with lock master . All child entities are always lock dependent. Consequently, when child entities are requested to be locked, their corresponding instance of the root entity is locked. See more details on the BDEF prerequisites in the RAP BDL documentation for locking.
The addition response_param is optional. If an instance is already locked in parallel, information with the failure cause IF_ABAP_BHEV-LOCKED (see types contained in the interface IF_ABAP_BEHV) is returned in the FAILED response parameter.
The following variants of the statement SET LOCKS enable the exclusive locking of instances:
SET LOCKS ENTITY, Short Form The short form of the SET LOCKS statement allows instances of a single entity to be locked.
SET LOCKS OF, Long Form The long form of the SET LOCKS statement allows instances of multiple entities to be locked.
SET LOCKS lock_tab, Dynamic Form The dynamic form of the SET LOCKS statement allows multiple instances to be collected and locked in multiple entities in one SET LOCKS statement.



Latest notes:

SET LOCKS statements are only allowed in the FOR LOCK and FOR MODIFY handler methods.