2023 May 25 12:05 PM
I tried creating a lock object for particular table in SAP ABAP, Is it possible to create entries in that table. If yes then what is the function of lock object. Already existing entries also taking except ID. Then what will be the special thing in lock object?
2023 May 25 5:47 PM
Hi,
When you create a Lock Object, it generates two Function Modules. If for instance your lock object is called EZTEST, you will have Function Modules ENQUEUE_EZTEST and DEQUEUE_EZTEST. You will need to call the first one to lock the table and the second one to unlock it. When you call ENQUEUE, a lock entry is created, which you can see in transaction SM12. If another program tries to do the ENQUEUE for the same key, it will return an error. This is a tool you can use to prevent two processes from doing simultaneous conflicting operations.
Do note though that this is not an actual lock on the database. If you don't check if there is a lock, it will not prevent you from doing database changes. Also, a lock for an entire table and a lock for a specific key of this table are two different lock entries that do not see each other. So you can lock the entire table in one program, but only lock a specific key in another and both will be allowed. You need to take this into account when using lock objects.
I hope this helps.
Patrice Poirier
2023 May 25 3:59 PM
This is a basic question. Use the search button or even the SAP documentation about it. You've created an object that allows programs to lock a table, not locked the table.
2023 May 25 5:47 PM
Hi,
When you create a Lock Object, it generates two Function Modules. If for instance your lock object is called EZTEST, you will have Function Modules ENQUEUE_EZTEST and DEQUEUE_EZTEST. You will need to call the first one to lock the table and the second one to unlock it. When you call ENQUEUE, a lock entry is created, which you can see in transaction SM12. If another program tries to do the ENQUEUE for the same key, it will return an error. This is a tool you can use to prevent two processes from doing simultaneous conflicting operations.
Do note though that this is not an actual lock on the database. If you don't check if there is a lock, it will not prevent you from doing database changes. Also, a lock for an entire table and a lock for a specific key of this table are two different lock entries that do not see each other. So you can lock the entire table in one program, but only lock a specific key in another and both will be allowed. You need to take this into account when using lock objects.
I hope this helps.
Patrice Poirier