Skip to Content
author's profile photo
Former Member

How we can lock No more than one user can use the table at a single time

Hi Abapers,

0) which function modules to lock & unlock a table.

1) When you execute the program, we can check if there is any lock on this table. If yes, the user should be able to only view the table contents and not modify.

2) If there is no lock, then lock the table and go into change mode.

3) On exiting from the program, unlock the table using the function module.

4) more than one user can't modify the table just display.

Note: If there is any lock, display message saying table is locked.

Plz help me for this requirement.



Add comment
10|10000 characters needed characters exceeded

3 Answers

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 03:09 AM

    Hello Nani

    Have a look at the lock object EMMARAE (<i>Lock MARA and MARM/MAKT exclusively</i>) in transaction SE11.

    Inspect the F1 help for field <b>Lock mode</b>:

     Short Text
         Lock mode
         Defines how to synchronize table record access by several users.
     The following modes exist:
         Exclusive lock
             The locked data can be read or processed by one user only. A request
             for another exclusive lock or for a shared lock is rejected.
         Shared lock
             Several users can read the same data at the same time, but as soon
             as a user edits the data, a second user can no longer access this
             data. Requests for further shared locks are accepted, even if they
             are issued by different users, but exclusive locks are rejected.
         Exclusive but not cumulative lock
             Exclusive locks can be requested by the same transaction more than
             once and handled successively, but an exclusive but not cumulative
             lock can only be requested once by a given transaction. All other
             lock requests are rejected.

    If you want to lock a standard table search whether the table is used in lock objects (<i>Where-Used-List</i>). If it is a customer table you have to create your own lock object (including two function modules: one for enqueuing and the other for dequeuing).

    The lock modules can be found in menu <b>GoTo -> Lock Modules</b>.

    Given these lock modules the logic should be quite clear after starting the program:

    1. Request lock -> if successful, continue in Change mode; -> if failed, continue in Display mode

    2. Before leaving the report remove lock (note: no problem if no lock has been set in the beginning).



    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 23, 2007 at 03:35 AM


    If you have a table maintenance for the table, SAP takes care of the locking.



    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 03:46 AM

    u need to create lock objects on that table using SE11, two FM's are generated one to enqueue and one to dequeue. enqueue is to lock the table and dequeue to unlock. Supp if the lock ojb is EZ_ABC, enq FM will be ENQUEUE_EZ_ABC and dequeue FM will DEQUEUE_EZ_ABC , when ever u enqueue the table may be write mode, the other user cant write at the same time..

    Hope this would be useful.

    Add comment
    10|10000 characters needed characters exceeded