Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Select Single for Update

Former Member
0 Likes
1,634

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?

2 REPLIES 2
Read only

Former Member
0 Likes
730

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.

Read only

Former Member
0 Likes
730

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>