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

Lock objects

Former Member
0 Likes
809

Hello everyone,

Lock objects once again. I use functions ENQUEUE and DEQUEUE ,and they work great when user works with transaction without any errors and problems. He has the button that release all locks. But when something happens, some error occurs or session was terminated, all locks that was made, they remain. How can I check, which active locks have remain after the system(session) down?

Greetings

5 REPLIES 5
Read only

Former Member
0 Likes
713

check in SM12 .

regards

prabhu

Read only

Former Member
0 Likes
713

Hi

Goto SM12 Tcode and check the lock entries and delete them

If you don't have access to SM12 ask the basis person for the access

see the doc for lock entries

Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.

SAP Provide three type of Lock objects.

- Read Lock(Shared Locked)

protects read access to an object. The read lock allows other transactions read access but not write access to

the locked area of the table

- Write Lock(exclusive lock)

protects write access to an object. The write lock allows other transactions neither read nor write access to

the locked area of the table.

- Enhanced write lock (exclusive lock without cumulating)

works like a write lock except that the enhanced write lock also protects from further accesses from the

same transaction.

You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.

Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.

Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.

Technicaly:

When you create a lock object System automatically creat two function module.

1. ENQUEUE_<Lockobject name>. to insert the object in a queue.

2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.

You have to use these function module in your program.

check this link for example.

http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm

tables:vbak.

call function 'ENQUEUE_EZLOCK3'

exporting

mode_vbak = 'E'

mandt = sy-mandt

vbeln = vbak-vbeln

  • X_VBELN = ' '

  • _SCOPE = '2'

  • _WAIT = ' '

  • _COLLECT = ' '

  • EXCEPTIONS

  • FOREIGN_LOCK = 1

  • SYSTEM_FAILURE = 2

  • OTHERS = 3

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

Reward points for useful Answers

Regards

Anji

Read only

Former Member
0 Likes
713

Yes of course, transaction sm12 is very usefull, but I need to do that in ABAP code, for example in PBO module before user calls screen. Moreover, I want to know which exactly lock is has left after system down.

Message was edited by:

Katarzyna Orlowska

Read only

0 Likes
713

To check if the object is already locked, you could just use the ENQUEUE function again - if it returns a sy-subrc eq 1, it means that the object is already locked. You should be able to get the sy-msgv1 to send the name of the user who has it locked as well.

If you want to unlock the existing lock, use DEQUEUE.

Hope this helps.

Sudha

Read only

Former Member
0 Likes
713

My point is - I don't want information about all locks which are impose on objects, but I want information about which of this locks have remain after transaction' s error or something like this. I know the structure SEQG3. Can any of fields from it be usefull ?.