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

Testing of the Lock Object Functionality

ashwani_karn
Explorer
0 Likes
1,295

Hi All,

I have created a Lock object on a database table. Now i am writing the code like below...

CALL FUNCTION 'ENQUEUE_/GMC/EZHIM_TEST'

EXPORTING

MODE_ZRAJ_TEST1 = 'X'

MANDT = SY-MANDT

KUNNR = ' '

  • X_KUNNR = ' '

  • _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.

I put a break point at sy-subrc ne 0. ( return value is 0)

Now i tried to create entries in the respective table through SE11 using another id. Its creating..

Kindly lemme know where exactly the problem is....else lemme know whether my testing is in a wrong way...

Thanks,

5 REPLIES 5
Read only

Former Member
0 Likes
1,076

Whenever you set a lock you just create an entry in the lock table you are not physically locking the table. SE11 does NOT check that lock table. You can see the lock table as an application table and whenever you want to access a database table directly and make sure that you are the only one accessing the table you should try to enqueue the table and only if you can get the lock (create a lock entry in the lock table) you should change the data in that table.

That's why you should always use standard API's to change data in a standard table instead of directly updating it, because the API's check the locks, if you want to update directly you have to take care of the lock check.

e.g.

User 1 requests a lock through ENQUEUE_/GMC/EZHIM_TEST which is granted. The program now makes updates to that table.

If at the same time you run a second program that would like to make changes to that table as well, this WILL BE allowed, unless you check the lock first. To do that just call ENQUEUE_/GMC/EZHIM_TEST again and if the object is already locked from another process you'll get an exception that tells you that you are not supposed to make changes.

Hope that helps,

Michael

Read only

0 Likes
1,076

Hello Michael,

Thanks for responding.

I feel i got my answer. Just to confirm the same...

Lets assume that there are some other programs which are updating the same table but No Locking concept have been taken care inside those programs, then as per my understanding, all of those programs can update the table.

Rectify me if i am wrong.

Thanks,

Read only

0 Likes
1,076

Correct, if another program does not check the locks it will be able to update the table.

Michael

Read only

0 Likes
1,076

Thanks Michael....

Regards,

Read only

ashwani_karn
Explorer
0 Likes
1,076

Confirmation