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: 

Lock Object. Want to see if it's locked.

Former Member
0 Kudos

Hello to everyone.

I have got a question about lock objects.

There is a Z-table in abap dictionary. During the processing of my report some strings from this Z-table are selected. To select strings i use the SELECT statement. But there can appear the situation when two users ( or more) run my transaction, so the same strings can be selected and then processed. To avoid this situation i've created the lock object with cumulative lock mode ( 'X' ) for this Z-table and put the calling of ENQUEUE function into the code. To test the locking i' ve run my report under two different accounts in the debugging mode. And found that when the enqueue function is finished , and the current string should be locked in theory, this string can be easily selected with help of select-statement under another account. (Even when the transactions start with delay.)

How can i lock the string in the Z-table so that it could be selected only once during the earlier launched transaction?

Regards,

alex karpo.

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos

Ho alex,

SAP locking is a cooperative locking model. That means that you have to care for what is possible and what is not possible. You may use enqeue module to set lock for key of every object selected.

If there is already a foreign lock, you should delete the entry from the list or table of selected objects (in memory, not in database).

Or do it as SAP does: If there is a foreign lock, the user is informed and the data can be displayed, not changed.

You can always check the lock by trying to set a lock.

Regards,

Clemens

2 REPLIES 2

Clemenss
Active Contributor
0 Kudos

Ho alex,

SAP locking is a cooperative locking model. That means that you have to care for what is possible and what is not possible. You may use enqeue module to set lock for key of every object selected.

If there is already a foreign lock, you should delete the entry from the list or table of selected objects (in memory, not in database).

Or do it as SAP does: If there is a foreign lock, the user is informed and the data can be displayed, not changed.

You can always check the lock by trying to set a lock.

Regards,

Clemens

Former Member
0 Kudos

Thanks Clemens, It 's a good idea to check the lock by trying to set a lock. I'm going to use this solution, and i sure it will work.

Regards,

alex karpo.