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: 

SAP tables for lock entries and sessions.

SantiMoreno
Participant
0 Kudos
11,297

Hi ABAPers.

I've created a Lock Object over a Z table. I want to know whether it's possible to check (querying at any table) if there's a lock entry and an open session of a certain user.That is, I want to know which tables I should access to know such info.

Kind Regards.

Santiago.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
2,753

You can determine this yourself by running transaction ST05 in parallel with the transaction you are interested in.

Rob

7 REPLIES 7

Former Member
0 Kudos
2,754

You can determine this yourself by running transaction ST05 in parallel with the transaction you are interested in.

Rob

uwe_schieferstein
Active Contributor
0 Kudos
2,753

Hello Santiago

A more straightforward approach is to look at transaction SM12 which lists current locks and allows to delete them.

Regards

Uwe

Former Member
0 Kudos
2,753

Hi Santiago,

You can use function ENQUEUE_READ to determine if your custom table is locked.

Call the function as follows:

 
call function 'ENQUEUE_READ'  
     exporting                
          gclient     = <client_id>   
          guname  = RSTABLE 
          gname    = 
          garg       =       
     importing                
          subrc   = subrc     
     tables                   
          enq     = enq       
     exceptions               
          others  = 1.        

Read the table ENQ to determine if there is an entry in the field GTARG with your custom table. The field GUNAME will hold the user whom has it locked.

Good luck,

Robert

0 Kudos
2,753

Thanks for the info, Robert.

Would it possible to know info about a open session (without using FM) via SAP Tables? I cannot use such function modules 'cause no permissions for session management has been assigned.

Kind Regards.

Santiago.

0 Kudos
2,753

Hello Santiago,

I don't think that the lock data is stored in some database table, it is held in shared memory at runtime as long as the application server is running. I am not sure if SAP provides a ready-made solution for that, but you can definitely create a custom ABAP program where you can use the FM provided by SAP to read the lock data

Go to this link in the SAP Documentation. It contains the detailed and easy-to-understand explanation of the SAP Lock Concept. It also tells you why some of the most common problems with locks occur and how they can be tackled.

http://help.sap.com/saphelp_erp2004/helpdata/en/37/a2e3ae344411d3acb00000e83539c3/frameset.htm

0 Kudos
2,753

Hi Santiago,

I checked transaction VA42 and locked it myself in one session and opened it in another. It shows my name in the message as the user having it locked after it was unable to lock the contract using ENQUEUE_EVVBAKE.

The documentation confirms this:

"To determine in a program which user is currently holding a lock, use the ENQUEUE_ function module. This function module puts the name of the owner into SY-MSGV1. "

So create your own lock object for the custom table and add it the ENQUEUE_<custom table> to your program.

Kind regards,

Robert

Former Member
0 Kudos
2,753

Hi,

.But it uses VIEW_ENQUEUE to check the locks.

So SAP does tracks locks by sessions.

or

SM12 gives a list of all LOCKS at an instant for each user and session names also.

and use fm ENQUEUE_READ. it is giving all locked entries including current sesstion.