‎2006 Feb 16 7:42 PM - last edited on ‎2024 Feb 04 3:48 AM by postmig_api_4
Hi all,
I created a lock object for a ztable. In a se38 program I just called enqueue_ezlock FM and locked the record where lifnr = 234567. I still did not call the dequeue_ezlock Fm. But in a different se 38 program when I tried to modify the same record a new record was inserted with the modified value. I am just confused Like how this lock object concept works ? So, I hope people with exerience can help me with this.
Regards,
Varun.
‎2006 Feb 16 7:52 PM
Hi Varun,
You may set Lock Mode as "E".
CALL FUNCTION 'ENQUEUE_EZDISPATCH'
EXPORTING
<u>MODE_ZDISPATCH = 'E'</u>
<u>Exclusive lock</u>
E (Exclusive)
An exclusive lock protects the locked object against all types of locks from other transactions. Only the same lock owner can reset the lock (accumulate)
You are the same user trying to create another record then system allowing because you initiated the lock.
Lanka
‎2006 Feb 16 7:44 PM
Even after locking object in one session, when you try to insert data in another session it will work. The reason is it is the same userid who has locked this. Try with some other user id. And you will see the difference.
‎2006 Feb 16 7:51 PM
Hi,
in the second program, are you calling the enqueue...??
that has to be done...if the lock is successful only then you should procedd with updation...
this is because the the locking in the first program is only logical (locking with any enqueue)...
Thanks,
Renjith
‎2006 Feb 16 7:52 PM
Hi Varun,
You may set Lock Mode as "E".
CALL FUNCTION 'ENQUEUE_EZDISPATCH'
EXPORTING
<u>MODE_ZDISPATCH = 'E'</u>
<u>Exclusive lock</u>
E (Exclusive)
An exclusive lock protects the locked object against all types of locks from other transactions. Only the same lock owner can reset the lock (accumulate)
You are the same user trying to create another record then system allowing because you initiated the lock.
Lanka
‎2006 Feb 17 5:45 AM
Hi varun,
1. Like how this lock object concept works
I think u have misunderstood the lock concept.
2. LOCK Object
does not lock the record
so that other session cannot update it.
3. It simply stores the lock information
and makes it available (if required)
4. So it is OUR DUTY
that we FIRST CHECK if a particular
record is locked or not.
5. IF the FM (for locking)
returns sy-subrc <> 0,
then it means, someone else
has locked the record,
and accordingly we have to wrtie IF condition,
so that further process of EDIT/INSERT is not alllowed.
6. If we don't take care of this IF - ENDIF
in our program, then lock object is of nouse.
7. WE HAVE TO DETECT (Using the enqueu fm)
and then only we have to ALLOW
further action.
regards,
amit m.
‎2006 Feb 17 6:01 AM
though u didnt call dequeue_<> fn module, when the program end is reached, automatically it gets unlocked.
‎2006 Feb 17 6:20 AM
hi ,
see locking concept is ,
for a salesorder/delivery number say ex:310635 in vbak table if im using it then other user say u r trying to acces the same number(310635)at the same time or instance then u cannot do it as the number with my id is locked .
u can check the lock entry on the same table by checking the same in transaction SM12.
this is concept of locking on a table.
in ur case the lock is not brought on to the table just check it in sm12.
if the lock is there then u should not get the table modified okay.
first try to get a lock and then u 'll understand the enqueue,dequeue functionality.
the other developers have given u valuable information.
‎2006 Feb 17 6:25 AM
Hello Varun,
The lock concept is as follows....
When u set up lock using the FM as u have described, it is locking at record level and not at table level. Now in different se38 session, still the user is same and it will allow to change the record. However if u log again keeping this previous session and try again then it will give error in the FM indicating a foreign lock.
As these locks are logical if u use another program in the same login screen and this program doesn't check for the logical lock then it can go ahead and update the datebase.
However u can use lock type to block this. You should use E (exclusive) which will not allow any other program to change the database.