Application Development 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: 

Using lock objects

Former Member
0 Kudos

Hi,

I have a table T and two programs P1 and P2. P1 sets a lock on table T and P2 has a simple MODIFY statement to insert/update data in T (no locking).

I executed P1 till the call to the enqueue function module and then had the program wait in debug mode. In another session, I executed P2. What I saw was that P2 had updated T inspite of the lock issued by P1.

On the other hand, when I tried to issue a lock on T from within P2, it failed (since P1 had already locked the table).

Is this normal behaviour?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Assuming that you called some ENQUEUE* function module the answer is, yes, this is normal behavior. I strongly recommend reading up on the [SAP lock concept|http://help.sap.com/saphelp_nw70ehp2/helpdata/en/41/7af4c5a79e11d1950f0000e82de14a/frameset.htm] (that's the short version for ABAP programmers, but I'd also recommend the long version of [SAP lock concepts|http://help.sap.com/saphelp_nw70ehp2/helpdata/en/47/df116e6abf296fe10000000a42189b/frameset.htm]). SAP locks are logical locks and as such rely on the application that a lock is set.

4 REPLIES 4

ravi_lanjewar
Contributor
0 Kudos

Hi,

There is table T having p1 and p2 2 lock object.

When any one of ther put lock for modification other should not modify data but he can read data using that lock object.

I think your program you should check before modify table check it is locked or not .

Generally you create one lock object per table table .

Rgds

Ravi Lanjewar

Former Member
0 Kudos

I might be completely wrong here... But it could also be that being in debug mode allows the update. Sometimes in debug mode things work, that don't work when not debugging... Try it with a wait (for 600 seconds) in the first program. And see if program 2 still updates the table.

It could also be the extent of the locking. Do you lock the complete table or the record that will be modified (or is it a new record)? If the complete table is locked, then an update/insert/modify should not be possible.

Former Member
0 Kudos

Assuming that you called some ENQUEUE* function module the answer is, yes, this is normal behavior. I strongly recommend reading up on the [SAP lock concept|http://help.sap.com/saphelp_nw70ehp2/helpdata/en/41/7af4c5a79e11d1950f0000e82de14a/frameset.htm] (that's the short version for ABAP programmers, but I'd also recommend the long version of [SAP lock concepts|http://help.sap.com/saphelp_nw70ehp2/helpdata/en/47/df116e6abf296fe10000000a42189b/frameset.htm]). SAP locks are logical locks and as such rely on the application that a lock is set.

matt
Active Contributor
0 Kudos

What Harald said. You have to check in P2 with an ENQUEUE call, whether a lock has been set or not.