‎2008 Jan 22 12:13 PM
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,
‎2008 Jan 22 1:07 PM
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
‎2008 Jan 22 1:18 PM
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,
‎2008 Jan 22 2:10 PM
Correct, if another program does not check the locks it will be able to update the table.
Michael
‎2008 Jan 22 2:20 PM
‎2008 Jan 22 1:19 PM