‎2008 Apr 04 5:48 PM
We have a function which is called at the beginning of most of our report programs. It performs 'select single for update' on a custom table to track execution date/times. We are seeing a lot of locking conflicts on this table.
I think it is because no 'commit work' is performed and so the table is being held until the report finishes execution.
Any opinions or other ideas?
‎2008 Apr 04 6:05 PM
yes..
Select single for update will get a lock on table until you update that table..
An exclusive lock can be set for this line using the FOR UPDATE addition when a single line is being read with SINGLE. The SELECT command is used in this case only if all primary key fields in logical expressions linked by AND are checked to make sure they are the same in the WHERE condition. Otherwise, the resulting set is empty and sy-subrc is set to 8. If the lock causes a deadlock, an exception occurs. If the FOR UPDATE addition is used, the SELECT command circumvents SAP buffering.
G@urav.
‎2008 Apr 04 11:13 PM
Hi,
A good way of dealing with such lock problem is to create a lock object for your custom table... and then lock it before updating... and when you update, check if update is successful... if so, commit work else rollback... finally unlock it.
Let me know if this is fine... or you need a more detailed code help for it.
Regards, Tapas
<Pls reward if useful or answered>