Saturday 18 October 2014

Need a Table level Lock In SAP ABAP?


Table level lock in SAP by Standard function module.

Step1. Create a report program and call the standard FM 'ENQUEUE_E_TABLE' and pass the table name  to request for a lock and call the FM 'DEQUEUE_E_TABLE' to release the lock.

















Step2. Here another report which want to update the table after lock is granted.



















Step3. Run the first report and an exclusive lock is granted for SCARR table and you can see the lock entry in  SM12 transaction. This report locks table SCARR for 5 mins(300 seconds) and then release the lock.




















Step4. Here the lock table SCARR entry in SM12 transaction.








Step5. Now after the lock is established for 5 mins, this report wants to request a lock for the same table and if lock is granted wants to update the database table entries and then release the lock.


















Step6. The table SCARR is already in lock mode for 5 mins by first program and when this program runs in the same 5 mins of the interval, the lock is not granted ( sy-subrc = 1 )  and just the program quits. In this way the data consistencies can be maintained by the table level lock concept.

















Step7. The report finished with a unsuccessful message.
















-------------------------------------------------------------------------------------------------------------------

No comments:

Comments system

Disqus Shortname