‎2006 Sep 21 9:53 AM
Hi All,
I have created a lock object(EZ_lock) in SE11 using table MARA.
in user 1 i coded
Tables Mara.
CALL FUNCTION 'ENQUEUE_EZ_LOCK'
EXPORTING
MODE_MARA = 'E'
MANDT = SY-MANDT
MATNR =
X_MATNR = ' '
_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.
write 😕 'table locked'.
---
and executed it.
In User 2.
i coded like this.
mara-matnr = '000000000000000025'.
modify mara.
if sy-subrc = 0.
write 😕 'updated'.
else.
write 😕 'table locked'.
endif.
-
and executed it.
As per the concept it should not update the mara table. However im getting the record in the mara table and the program output as updated.
Kindly clarify this.
Regards,
Senthil
‎2006 Sep 21 9:56 AM
Hi,
In func module, in import parameters u have to pass '000000000000000025'. to MATNR field.. u have to pass all the key values in MARA table to this func module.
Plz mark if useful
Regards
Divakar
‎2006 Sep 21 9:58 AM
Hi Divakar,
Have tried that also, it has not worked. Any other solution. For both Entire table lock and record level locking??
Moreover how do i know the user2 is entering this record '000000000000000025'.
Regards,
Senthil
Message was edited by: senthil kumar
‎2006 Sep 21 9:58 AM
‎2006 Sep 21 10:06 AM
Hi Senthil,
According to my observation, u r not releasing the lock manually. There is one more way to release the lock,in user1 u could have executed the program and u might have come back(F3), this will also release(Dequeue) the lock, so the user2 is able to update the lock, one thing u can try is execute the program in user1 and in user2 goto tcode SM12, check whether the Lock is there on Mara, if it is there, try to execute ur program, it will surely give Table locked by user user1.
Hope this will solve ur issue.
Regards:-
<b>Santosh.D</b>
‎2006 Sep 21 10:21 AM
Hi Santosh,
The program for user 1 is in output mode only. In sm12 of user 1, it displays table MARA with lock argument, so table locked.
However in SM12 of user 2 , iam not able to the lock for mara. What is the reason behind this.
Regards,
Senthil
‎2006 Sep 21 10:20 AM
hey,
u created lock object. very good. u tried to update MARA in program fine. it will be done successfully.
but where is the problem. if the intention is to see how locking works, u should keep the material open in change mode MM02 and then u should try updating it. then system will say, the material is currently being edited by user XXX.
correct if i am not right.
reward if useful...
‎2006 Sep 21 10:41 AM
Hi Pawan,
Good, it works as per u said. Im getting 'locked by user1' when i try to change any material in MM02 in user 2.
What is the concept exactly????
But i can able to modify or add a row to the mara table the programming (code) in user 2.
What is the concept exactly????
Somebody clear this, so that i can contribute points and close the thread.
Regards,
Senthil
Message was edited by: senthil kumar
Message was edited by: senthil kumar
Message was edited by: senthil kumar
‎2006 Sep 21 11:13 AM
Hi Senthil!
One remark might be missing in the discussion: SAP's lock concept is NOT implicit. If there is an existing lock for a table, this does not prevent updates (as in your example). Only if (every!) DB access checks first for existing locks (and stops execution), locks make sense.
So you should rather use standard lock objects in case you plan to change standard tables - if you have independent lock objects, standard might still change the table, too.
Regards,
Christian
‎2006 Sep 21 10:28 AM
Senthil,
Already there are some standard lock objects for MARA table. Use the same.
EMMARAE - Lock MARA and MARM/MAKT exclusively
EMMARAS - Lock MARA and MARM/MAKT: shared
Regards,
Prakash.
‎2006 Sep 21 10:53 AM
Hi Senthil,
Well the concept is that, the someone is in change mode, that means he is editing that particular material number. So the lock would be set. Now if some other user tries to access the same material, he will get table lock error.
If user is in display mode, then the table lock is not set and hence another user can access it without getting any table lock error.
Best regards,
Prashant