+ -

Pages

Saturday, July 26, 2014

Lock objects

Lock objects are created in SE11. The name must start with E. 

E. g.: EZHRACTIVITY_DEL

When the lock object is activated 2 function modules are created for enqueueing and dequeueing the object. They re named ENQUEUE<name> and DEQUEUE<name>

Example:

ENQUEUE_EZHRACTIVITY_DEL
DEQUEUE_EZHRACTIVITY_DEL
 

CALL FUNCTION 'ENQUEUE_EZHRACTIVITY_DEL'
 EXPORTING
   mode_zhr_activity_del       = 'E'
   mandt                       = sy-mandt
   pernr                       = l_zhr_activity_del-pernr
   ldate                       = l_zhr_activity_del-ldate
*   X_PERNR                     = ' '
*   X_LDATE                     = ' '
*   _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.

Parameters

The keys to be locked must be passed here.

Parameter X_<field> that defines the lock behavior when the initial value is passed exists for every lock field <field>. If the initial value is assigned to <field> and X_<field>, then a generic lock is initialized with respect to <field>. If <field> is assigned the initial value and X_<field> is defined as X, the lock is set with exactly the initial value of <field>.


Parameter _SCOPE controls how the lock or lock release is passed to the update program You have the following options:
•        _SCOPE = 1: Locks or lock releases are not passed to the update program. The lock is removed when the transaction is ended.
•        _SCOPE = 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.
•        _SCOPE = 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.

Parameter _COLLECT controls whether the lock request or lock release should be performed directly or whether it should first be written to the local lock container. This parameter can have the following values:
•        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.
Whenever you have lock mode X (extended write lock), locks should not be written to the local lock container if very many locks refer to the same lock table. In this case, there will be a considerable loss in performance in comparison with direct transmission of locks.


parameter _WAIT. This parameter determines the lock behavior when there is a  lock conflict.
You have the following options:
•        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.




CALL FUNCTION 'DEQUEUE_EZHRACTIVITY_DEL'
* EXPORTING
*   MODE_ZHR_ACTIVITY_DEL       = 'E'
*   MANDT                       = SY-MANDT
*   PERNR                       =
*   LDATE                       =
*   X_PERNR                     = ' '
*   X_LDATE                     = ' '
*   _SCOPE                      = '3'
*   _SYNCHRON                   = ' '
*   _COLLECT                    = ' '
              .

 
5 ABAP Tips: Lock objects Lock objects are created in SE11. The name must start with E. E. g.: EZHRACTIVITY_DEL When the lock object is activated 2 function module...

No comments:

Post a Comment

< >