Skip to Content
avatar image
Former Member

Lock Objects

Hi ,

What is lock objects , What are its uses , How to create lock objects ( Steps )

Kannan

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Jan 07, 2007 at 10:08 AM

    Dear Kannan,

    Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.

    SAP Provide three type of Lock objects.

    - Read Lock(Shared Locked)

    protects read access to an object. The read lock allows other transactions read access but not write access to

    the locked area of the table

    - Write Lock(exclusive lock)

    protects write access to an object. The write lock allows other transactions neither read nor write access to

    the locked area of the table.

    - Enhanced write lock (exclusive lock without cumulating)

    works like a write lock except that the enhanced write lock also protects from further accesses from the

    same transaction.

    You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.

    Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.

    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.

    Regards,

    Abir

    ************************************

    • Don't forget to award Points *

                                                                        Add comment
                                                                        10|10000 characters needed characters exceeded

                                                                      • avatar image
                                                                        Former Member
                                                                        Jan 07, 2007 at 10:24 AM

                                                                        Hello Kannan,

                                                                        Lock objects are used to synchronize access to the same data by more than one program.

                                                                        General information about the lock mechanism.

                                                                        You can synchronize access by several programs to the same data with a logical lock mechanism. This lock mechanism fulfills two main functions:

                                                                        A program can tell other programs which data records it is just reading or changing.

                                                                        A program can prevent itself from reading data that is just being changed by another program.

                                                                        When accessing data records, the records just being edited by other programs can be identified by the entry in the lock table. Such an entry for the lock must define a number of fully specified key fields, that is either a value is passed for the key field or this field is locked generically.

                                                                        To set locks, a lock object must be defined in the ABAP Dictionary. When this lock object is activated, two function modules (see Function Modules for Lock Requests) are generated with the names ENQUEUE_ are generated from its definition to set and release locks.

                                                                        You can find information about the activation flow in the activation log, which you can display with Utilities ® Activation log. If errors occurred during activation, the activation log is displayed immediately.

                                                                        If useful reward.

                                                                        Vasanth

                                                                        Add comment
                                                                        10|10000 characters needed characters exceeded

                                                                      • avatar image
                                                                        Former Member
                                                                        Jan 07, 2007 at 10:32 AM

                                                                        Hi,

                                                                        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 is also sent to the update program. The lock must be removed in both the dialog program and by the update program. This is the standard setting for the ENQUEUE function module.

                                                                        Regards

                                                                        anver

                                                                        Add comment
                                                                        10|10000 characters needed characters exceeded