‎2013 Jun 05 3:50 PM
This topic has been discussed over and over however I can't seem to lock down my table.
Here is the code:
CALL FUNCTION 'ENQUEUE_EZZTESTTABLE'
EXPORTING
mode_zsss_obs_3 = 'X'
* MANDT = SY-MANDT
node_no = '0000000342'
* X_NODE_NO = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
So I locked down entry 0000000342 of my table. Looked in SM12 and sure enough the lock is there. However thru SM30 I can still change that entry and also I run a different program to update that table entry and it updated it just fine. I did also try different modes but no luck.
So why does the lock not lock?
J
‎2013 Jun 05 4:59 PM
SM30 table maintenance is very generic program and it doesn't use table specific lock modules generated by lock object. Instead it uses generic function module ENQUEUE_E_TABLE with table name and generic key using SY-MANDT.
If you run your program with ENQUEUE_EZZTESTTABLE fm call and SM30 at the same time and then go to SM12 you will see different table name and parameters. You have understand that SAP lock mechanism is logical system which depends on table name key used to set lock. If table name and key doesn't match then SAP think its different table.
Use ENQUEUE_E_TABLE in your program instead of ENQUEUE_EZZTESTTABLE and issue will be resolved.
Regards,
Pawan.
‎2013 Jun 05 4:26 PM
SM30 does not respect locks. Even if you write your own code, you must attempt to lock the table before attempting to write. If your program can't lock, then your program must choose not to write.
Neal
‎2013 Jun 05 4:26 PM
Hi,
This is because SAP depended on each application to do the locking and is not utilizing native
data base lock.(I am not sure why but I suspect historical reasons).
Coming from AS/400 background I was ( like you) VERY surprised.....
Regards.
‎2013 Jun 05 4:59 PM
SM30 table maintenance is very generic program and it doesn't use table specific lock modules generated by lock object. Instead it uses generic function module ENQUEUE_E_TABLE with table name and generic key using SY-MANDT.
If you run your program with ENQUEUE_EZZTESTTABLE fm call and SM30 at the same time and then go to SM12 you will see different table name and parameters. You have understand that SAP lock mechanism is logical system which depends on table name key used to set lock. If table name and key doesn't match then SAP think its different table.
Use ENQUEUE_E_TABLE in your program instead of ENQUEUE_EZZTESTTABLE and issue will be resolved.
Regards,
Pawan.
‎2013 Jun 05 7:34 PM
Thanks Pawan, your correct SM30 can not be used if you lock using ENQUEUE_E_TABLE.
Thanks all for your answers.
J
‎2013 Jun 05 6:35 PM
This will happen . Even if you set the _scope parameter to 2 or 3 , the lock will be released only when the COMMIT WORK statement is reached . The database lock comes into play only when the SAVE button is pressed (INSERT,UPDATE,MODIFY, DELETE Statements) . So if two users are running two different programs to update the same table they will be able to update the record even if they are the update owners of the lock . This is because they are the update owner for the SAP Lock not the database lock . One solution can be to use the function module ENQUEUE_READ , which reads the locked content in the system . Implement this FM in a suitable event of the TMG and then try to make the row uneditable of the TMG for the locked data , check if this way its possible . Suvendu Chakraborty |