WDP Logical Lock
Hi,
I'd like to know if anyone have something up to this topic. I've got so far some docs (http://help.sap.com/saphelp_nw04/helpdata/en/a3/df5b1ee1bed348b198719e50af835d/frameset.htm) - but I'm more concerned about the implementation general design.
Did someone use this API already? - Also, is this the best method available?
Regards,
Daniel
Hi Daniel,
Some thoughts:
Case 1:if u use J2ee engine locking then probably it will minimize the efforts for developing your own Lock Manager although i have not used this apis before but in this case either at Business logic layer u have to call the Apis in a stateless session bean and then consume it in WDP java via Java beans or Webservice,But in the above case you have to do some more reasearch from implementation and design Point of view.
Case 2:If you go for your own Lock manager then calling the custom lock manager methods from WDP will be the same as mentioned in the first case as per my understanding.
I guess the design will follow the Monitor or semaphore concept of OS ,and a single instance of the Lock manger will run throughout the application life cycle to carry out the locking and unlocking process.
this case will require more brainstorming,Design and testing.
Siddharth
Similar Messages
-
Creating logical locks generates two fm
Hi Expert!,
AS far I know, When we create logical locks in se11 transaction, two Function modules get generated by the the system.
My Question is , is there any other Function module which gets generated by system?
3rd FM?Hii Mithilesh,
When u create a lock object In SE11 only 2 FMs are generated by the system that is "ENQUE" and "DEQUE" .as par i know no third FM is generated automatically.
regards,
Archana -
Our system consists of ABAP and java stack. There are two server processes running on the system. We have a web application that is deployed. We want to lock an object in the init method of the servlet. We are using logicallocking to do that.
We want it so that when the application is deploying and running the init method on one server it obtains the lock. The other server process should wait till it obtains the lock.
This is the code I have
try {
lockOmscb();
_omscb.start();
} catch (LockException e1) {
_logger.logInfoExt("Omscb instance already running, cannot access lock on object.");
// TODO Auto-generated catch block
e1.printStackTrace();
private void lockOmscb() throws NamingException, LockException, TechnicalLockException, IllegalArgumentException {
Context initialContext = new InitialContext();
LogicalLockingFactory factory = (LogicalLockingFactory) initialContext.lookup(LogicalLockingFactory.JNDI_NAME);
_logger.logInfoExt("Got intial context lookup");
_lock = factory.createLogicalLocking("NWCPM", "NWCPM workspace" );
_logger.logInfoExt("created logical locking");
lock.lock(LogicalLocking.LIFETIMEUSERSESSION, "NWCPM/OMSCB", cfg.toString(), LogicalLocking. MODEEXCLUSIVE_NONCUMULATIVE);
_logger.logInfoExt("Got lock");
In the locking adapter I can see two locks being obtained at the same time. They are not getting it one after the other.
If I try to obtain the lock twice in the same method then it is throwing the lockException.
But this is not happening when the web application is being initialized in the two server processes.
Logicallocking is supposed to be access the lock between applications.
Is there a way I can acheive this ? If so how?
Can you please let me know.
thanks
PadmajaHi Padmaja,
the argument you are trying to lock is _cfg. As you do not deliver the code that defines this I cannot say what it contains, but it is easily predictable that this value is different in two different servers.
Make it a hard coded string with a value like "Humble" and then you are sure all instances will try to save exactly same value, which will make it work as expected.
Regards,
Benny -
WCMException logical locking error
I am recieveing the error
Failed to perform job: com.sapportals.wcm.WcmException: Error when acquiring logical locking
at com.sapportals.wcm.service.taskqueue.TaskQueue$Lock.getLocking(TaskQueue.java:421)
at com.sapportals.wcm.service.taskqueue.TaskQueue$Lock.lock(TaskQueue.java:316)
at com.sapportals.wcm.service.taskqueue.TaskQueue$Lock.writeLock(TaskQueue.java:293)
at com.sapportals.wcm.service.taskqueue.TaskQueue.writeLock(TaskQueue.java:467)
at com.sapportals.wcm.service.taskqueue.TaskQueue.get(TaskQueue.java:122)
at com.sapportals.wcm.service.taskqueue.TaskQueueReader.get(TaskQueueReader.java:68)
at com.sapportals.wcm.service.taskqueue.TaskQueueReader.get(TaskQueueReader.java:58)
at com.sapportals.wcm.service.jobprocessor.LocalDispatcher.stopJobs(LocalDispatcher.java:161)
at com.sapportals.wcm.service.jobprocessor.LocalDispatcher.run(LocalDispatcher.java:101)
at java.lang.Thread.run(Thread.java:761)
Error when acquiring logical locking java.lang.ClassCastException: com.sap.engine.services.jndi.persistent.UnsatisfiedReferenceImpl incompatible with com.sap.engine.services.applocking.LogicalLockingFactory
at com.sapportals.wcm.service.taskqueue.TaskQueue$Lock.getLocking(TaskQueue.java:412)
at com.sapportals.wcm.service.taskqueue.TaskQueue$Lock.lock(TaskQueue.java:316)
at com.sapportals.wcm.service.taskqueue.TaskQueue$Lock.writeLock(TaskQueue.java:293)
at com.sapportals.wcm.service.taskqueue.TaskQueue.writeLock(TaskQueue.java:467)
at com.sapportals.wcm.service.taskqueue.TaskQueue.get(TaskQueue.java:122)
at com.sapportals.wcm.service.taskqueue.TaskQueueReader.get(TaskQueueReader.java:68)
at com.sapportals.wcm.service.taskqueue.TaskQueueReader.get(TaskQueueReader.java:58)
at com.sapportals.wcm.service.jobprocessor.LocalDispatcher.stopJobs(LocalDispatcher.java:161)
at com.sapportals.wcm.service.jobprocessor.LocalDispatcher.run(LocalDispatcher.java:101)
at java.lang.Thread.run(Thread.java:761)
error when acquiring logical locking (com.sap.engine.services.jndi.persistent.UnsatisfiedReferenceImpl incompatible with com.sap.engine.services.applocking.LogicalLockingFactory)
This is occuring on the Dialog node. I know it has something to do with KM but it is occuring so rapidly that the logs fillup 2 gig in minutes and I am unable to even login to the node. This is an SP12 system. Any ideas would be greatly appreciated.
Thanks
PaulWe are experiencing the same problem with SP17. Nothing in the SAP Notes about LogicalLockingFactory.
Anyone, any idea?
Thank you in advance,
Todor -
Lock(Enque/Deque) is a logical lock & database lock
Hi All,
I have gone through various portals and SDN too, and found that locks are the logical locks and sometimes database locks too but still have some confusion.
1) If these are the logical locks then why they are created by SE11 and once created then FM has been generated. All FM are stored somewhere right? So they would be in database.
2) If these are the database locks then why they are at the application server level and few more things.
Can anybody explain with the valid reasons? In which queue they fall and why?
Thanks.
AnHi Anurag,
The SAP locks are created with naming standard EZ. They are not connected with the DB. It work like this
You create Lock -> FM is automaically generated as follow EXample: CALL FUNCTION 'DEQUEUE_EZARS_TRHDR_T'
EXPORTING
generated In your program you add CALL FUNCTION <name of your new lock enqueue FM>
3. if object is not locked you can modify it.
4. unlock it with second (dequeue) FM
Information about these locks are stored in queue on specific application server (usually central instance) - in SM51 you can see it with description "Enqueue".
So this is kind of mechanism that works if everybody goes according to rules. If someone will write it's own report were he access your objects, but he will ommitt this FM call (or ignore it's results), then he will be free to change it as he likes even if someone has already locked it.
To use DB lockes other technices are used like SELECT SINGLE * FOR UPDATE -
Check Mate? Logic locks when I save
I've been using Logic for two years without a major problem. One day last week logic decided to freeze whenever I save, nothing to do but to force quit. Every song every possible combination of saving also to different drives. i rushed into the Apple store with my mac and paid the experts to give it a thorough going over, hardware test etc. The verdict, perfect health. So my puter is OK but what about the system software? Reinstalled! Same problem. So i went and bought logic pro cross grade from 7 to 7.2 uninstalled logic properly and did a fresh install of logic, ran setup assistant and same problem, Logic lock when i try to save.
Any Ideas anyone because apple stores can't help and neither can Pro tech support.
Anyone?
Cheers
jamieI would do what I used to have to do in Windows every couple of dang months: wipe the HD totally and reinstall everything from scratch.
Lot of work, but pretty much eliminates the software variable. -
hii all,
I want to keep locks(logically) to the existing database records as my ztables(3 tables with 1 parent table,containing header data and 2 line item tables having the foreign key relationships with header table) are accessed at time by many users(different users might try to change the same record).what is the best way to go ahead.
with regards,
sandeep akella.Hi,
check the following link
http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4c5a79e11d1950f0000e82de14a/content.htm
Regards,
Madhu -
Logical Locking for User and Session ID possible?
Hi colleagues!
We are developing on NetWeaver CE 7.10 SP6
Currently it is possible for a user to access the same business object (like a specific order number for example) in two separate browser tabs in parallel. This leads to many strange and unwanted side-effects.
One option would be to use a non cumulative exclusive locking. However we would like to avoid that as we use the lock life time "user session". And in this case we would need to set the lock only at one place and could not assure the setting of the lock again at different places (lock() may only be called once in this case).
It would be nice if the com.sap.engine.services.applocking.LogicalLocking class would support support a session based exclusive locking where the same lock can be applied multiple times but only for the same session. But this does not seem to be possible.
Does anybody know a nice solution for this issue? How to avoid that the same user opens the same business object in multiple sessions? Ideally this should be callable from a CAF application service.
Thanks and kind regards,
Gunnar
Edited by: Gunnar Goerke on Jul 6, 2009 4:07 PM
Edited by: Gunnar Goerke on Jul 6, 2009 4:09 PMFor analyze, we have synchronized 15 LDAP Users to Notes
FirstName, Lastname and login attributes are from 1 to 15 characters lenght as following :
givenname, lastname, UID
1,1,1
F2,L2,ID
F33,L33,ID3
F444,L444,ID44
F5555,L5555,ID555
F66666,L66666,ID6666
F777777,L777777,ID77777
F8888888,L8888888,ID888888
F99999999,L99999999,ID9999999
Faaaaaaaaa,Laaaaaaaaa,IDaaaaaaaa
Fbbbbbbbbbb,Lbbbbbbbbbb,IDbbbbbbbbb
Fccccccccccc,Lccccccccccc,IDcccccccccc
Fdddddddddddd,Ldddddddddddd,IDddddddddddd
Feeeeeeeeeeeee,Leeeeeeeeeeeee,IDeeeeeeeeeeee
Fffffffffffffff,Lffffffffffffff,IDfffffffffffff
Between 6 and 8 characters, le logical Name of the user is correct
He is constructed as %fistname% %lastname%/DOMAIN
Less than 6 or more than 8 characters, the logical name is not correct
We can show the partial path of the lotus's data directory.
I can send screenshot to an email Adress if you want
Why this ? It's not usable
PS : All certificates can be viewed without provide password !
Why the LDAP password of the user's entry is not used to open the ID ?
Thanks for your help.
BRs
Vincent -
Business logic locks and CMP.
I’m trying to implement the following:
If a raw in the database (a CMP bean instance) was changed by a user then this
raw is “locked” for all other users (write lock) until the user decides to release
the lock.
The database raw has three fields: ID, UserLockID, and Data
The code in my stateless session bean façade that wraps the CMP will be:
ResourceHome home = (ResourceHome)EJBHomeFactory.getInstance().lookUpLocalHome(
“Resource” , ResourceHome.class );
Resource rsc = home.findByPrimaryKey(id);
If (rsc.getUserLockId() == null || rsc.getUserLockId() == user ){
rsc.setUserLockId(user);
rsc.setData(data);
} else{
throw new LockException(“This raw is locked by another user”);
My questions are:
1) Do I need to worry about race conditions, for example two user accessing the
same raw at the same time and then overwriting each other changes (where the
last one wins)?
2) If the answer for 1. is Yes, should I use TransactionReadCommittedForUpdate
3) If the answer for 2 is Yes, on which methods should I define this isolation
level? The session bean method? The CMP method, which once ejbLoad? Getters and
setters?.
4) Last Question: Can I use TransactionReadCommittedForUpdate and an optimistic
concurrency strategy for the same bean?
Thanks in advance.Why would not you just use database concurrency strategy and use dummy
update (or select for update) right before you are going to change the data?
If no one else have changed it, then the update will be successful and you
can continue with changing and committing. If someone else changed the data
(and committed it to database), you will get an exception. Looks pretty
simple and easy.
Or you can use exclusive concurrency strategy, but in this case you will not
be able to read field values from another transaction. I am not sure will
you be able even to find the bean or not. If I recall correctly, you will.
Michael Jouravlev.
"M.A." <[email protected]> wrote in message
news:3e95ca33$[email protected]..
>
I’m trying to implement the following:
If a raw in the database (a CMP bean instance) was changed by a user thenthis
raw is “locked” for all other users (write lock) until the user decides
to release
the lock.
The database raw has three fields: ID, UserLockID, and Data
The code in my stateless session bean façade that wraps the CMP will be:
ResourceHome home =(ResourceHome)EJBHomeFactory.getInstance().lookUpLocalHome(
“Resource” , ResourceHome.class );
Resource rsc = home.findByPrimaryKey(id);
If (rsc.getUserLockId() == null || rsc.getUserLockId() == user ){
rsc.setUserLockId(user);
rsc.setData(data);
} else{
throw new LockException(“This raw is locked by another user”);
My questions are:
1) Do I need to worry about race conditions, for example two useraccessing the
same raw at the same time and then overwriting each other changes (wherethe
last one wins)?
2) If the answer for 1. is Yes, should I useTransactionReadCommittedForUpdate
3) If the answer for 2 is Yes, on which methods should I define thisisolation
level? The session bean method? The CMP method, which once ejbLoad?Getters and
setters?.
4) Last Question: Can I use TransactionReadCommittedForUpdate and anoptimistic
concurrency strategy for the same bean?
Thanks in advance. -
How to find out in which order locks are aquired by one or more sessions.
hi,
i am using following query to find locking of two sessions .
SELECT resource_database_id, t.resource_type , t.resource_associated_entity_id,partitions.index_id,blocking_session_id,
indexes.name as index_name,o.name,
t.request_status, t.request_mode,t.request_session_id,
t.resource_description
,s.total_elapsed_time,s.start_time, convert(varchar ,getdate() - s.start_time, 114)
,s.wait_type,s.wait_time
,s.last_wait_type,s.lock_timeout,s.row_count
,s.*,o.*,t.*
FROM sys.dm_tran_locks t
LEFT JOIN sys.objects o on t.resource_associated_entity_id=o.object_id
LEFT JOIN sys.dm_exec_requests s ON s.session_id=t.request_session_id
left join sys.partitions on partitions.hobt_id = t.resource_associated_entity_id
left join sys.indexes on indexes.object_id = partitions.object_id and indexes.index_id = partitions.index_id
WHERE s.session_id in (51,52) ORDER BY s.start_time,s.total_elapsed_time
resource_type resource_associated_entity_id request_session_id request_mode index_name name resource_description
DATABASE 0 51 S NULL NULL
OBJECT 2094278866 51 Sch-S NULL wt
OBJECT 2094278866 52 IX NULL wt
PAGE 72057597150887936 52 IX PK_wt NULL 1:204815
KEY 72057597150887936 52 X PK_wt NULL (4fb98fd9bfad)
DATABASE 0 52 S NULL NULL
Q1)i wanted to know session id 52 acquired object,page,key and database locks in same order or it was opposite
how can i find the order of aquisition of locks by (one or two session).
Q2)i have express edition advance of sqlserver 2008 r2 , it possible to trace every event with out using profiler as u know it
does not ship with it
yours sincerleyhttp://blogs.conchango.com/jamesrowlandjones/archive/2009/05/28/the-curious-case-of-the-dubious-deadlock-and-the-not-so-logical-lock.aspx
select *,%%lockres%%
from dbo.Table(nolock)
where %%lockres%% IN('(4fb98fd9bfad)')
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Where we use lock objects in our coding like report
what is the purpose of lock objects s? how we use them in real time? like in devoloping reports?
Hi,,.
Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.
SAP Provide three type of Lock objects.
- Read Lock(Shared Locked)
protects read access to an object. The read lock allows other transactions read access but not write access to
the locked area of the table
- Write Lock(exclusive lock)
protects write access to an object. The write lock allows other transactions neither read nor write access to
the locked area of the table.
- Enhanced write lock (exclusive lock without cumulating)
works like a write lock except that the enhanced write lock also protects from further accesses from the
same transaction.
You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.
Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
Technicaly:
When you create a lock object System automatically creat two function module.
1. ENQUEUE_<Lockobject name>. to insert the object in a queue.
2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.
Check these links
Re: Lock Objects
http://help.sap.com/saphelp_47x200/helpdata/en/ce/931bb5c79911d5993e00508b6b8b11/frameset.htm
http://help.sap.com/saphelp_47x200/helpdata/en/e1/8e51341a06084de10000009b38f83b/frameset.htm
http://www.sapdevelopment.co.uk/dictionary/lock_enqueue.htm
http://help.sap.com/saphelp_nw04/helpdata/en/a2/3547360f2ea61fe10000009b38f839/frameset.htm
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.
SAP Provide three type of Lock objects.
- Read Lock(Shared Locked)
protects read access to an object. The read lock allows other transactions read access but not write access to
the locked area of the table
- Write Lock(exclusive lock)
protects write access to an object. The write lock allows other transactions neither read nor write access to
the locked area of the table.
- Enhanced write lock (exclusive lock without cumulating)
works like a write lock except that the enhanced write lock also protects from further accesses from the
same transaction.
You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.
Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
Technicaly:
When you create a lock object System automatically creat two function module.
1. ENQUEUE_<Lockobject name>. to insert the object in a queue.
2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.
Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.
SAP Provide three type of Lock objects.
- Read Lock(Shared Locked)
protects read access to an object. The read lock allows other transactions read access but not write access to
the locked area of the table
- Write Lock(exclusive lock)
protects write access to an object. The write lock allows other transactions neither read nor write access to
the locked area of the table.
- Enhanced write lock (exclusive lock without cumulating)
works like a write lock except that the enhanced write lock also protects from further accesses from the
same transaction.
You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.
Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
Technicaly:
When you create a lock object System automatically creat two function module.
1. ENQUEUE_<Lockobject name>. to insert the object in a queue.
2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.
http://help.sap.com/saphelp_nw04/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
GO TO SE11
Select the radio button "Lock object"..
Give the name starts with EZ or EY..
Example: EYTEST
Press Create button..
Give the short description..
Example: Lock object for table ZTABLE..
In the tables tab..Give the table name..
Example: ZTABLE
Save and generate..
Your lock object is now created..You can see the LOCK MODULES..
In the menu ..GOTO -> LOCK MODULES..There you can see the ENQUEUE and DEQUEUE function
Lock objects:
http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
Match Code Objects:
http://help.sap.com/saphelp_nw2004s/helpdata/en/41/f6b237fec48c67e10000009b38f8cf/content.htm
http://searchsap.techtarget.com/tip/0,289483,sid21_gci553386,00.html
See this link:
http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
Lock objects are used to synchronize access to the same data by more than one program.
General information about the lock mechanism.
You can synchronize access by several programs to the same data with a logical lock mechanism. This lock mechanism fulfills two main functions:
A program can tell other programs which data records it is just reading or changing.
A program can prevent itself from reading data that is just being changed by another program.
When accessing data records, the records just being edited by other programs can be identified by the entry in the lock table. Such an entry for the lock must define a number of fully specified key fields, that is either a value is passed for the key field or this field is locked generically.
To set locks, a lock object must be defined in the ABAP Dictionary. When this lock object is activated, two function modules (see Function Modules for Lock Requests) are generated with the names ENQUEUE_<lockobjectname> and DEQUEUE_<lockobjectname>.
If data records are to be locked, you must call function module ENQUEUE_<lockobjectname>. The values of the key fields that specify the records to be locked are passed for all the tables contained in the lock object when the function module is called. There is a generic lock if a value is not passed for all the key fields. The function module writes the appropriate lock entry (see Example for Lock Objects). If another program also requests a lock, it will be accepted or rejected depending on the lock mode (see Lock Collisions). The program can then react to this situation.
Locked data records can be unlocked by calling function module DEQUEUE_<lockobjectname>. The key values and the lock mode used to set the lock must be passed to the function module.
Creating Lock Objects
Procedure
Select object type Lock object in the initial screen of the ABAP Dictionary, enter an object name and choose Create. The name of a lock object should begin with an E (Enqueue).
The maintenance screen for lock objects is displayed.
Enter an explanatory short text in the field Short text.
You can then use the short text to find the lock object at a later time, for example with the R/3 Repository Information System.
Enter the name of the primary table of the lock object.
All other tables in the lock object must be linked with the primary table using foreign keys. There are also some restrictions on the valid foreign key relationships.
Select the lock mode of the primary table in the field below it.
The lock mode is used as the default value for the corresponding parameters of the function modules generated from the lock object.
Choose Add if you want to lock records in more than one table with the lock object.
A list of all the tables linked with the primary table using valid foreign keys is displayed. Select the appropriate table. The lock mode of the primary table is copied as lock mode. You can change this setting as required, for example you can assign the lock mode separately for each table.
Similarly, you can add a table linked with the secondary table just added with foreign keys. To do this, place the cursor on the name of the secondary table and choose Add.
If no lock mode is assigned to a table, no lock is set for the entries in this table when the generated function modules are called. You should not assign a lock mode if a secondary table was only used to define a path between the primary table and another secondary table with foreign keys.
Save your entries.
A dialog box appears in which you have to assign the lock object a development class.
You can (optionally) exclude lock parameters (see lock objects) from the function module generation on the Lock parameter tab page. This makes sense for example if you always want to lock a parameter generically.
To do this, simply deselect the Weight flag for the parameter. The parameter is not taken into consideration in the generated function modules. This parameter is then always locked generically.
The name of a lock parameter is usually the name of the corresponding table field. If two fields with the same name are used as lock parameters in the lock object from different tables, you must choose a new name for one of the fields in field Lock parameter.
You can define whether the function modules generated from the lock object should be RFC-enabled on the Attributes tab page.
If you set the Allow RFC flag, the generated function modules can be called from within another system with Remote Function Call.
If you permit Remote Function Calls for an existing lock object, you must ensure that the generated function modules are called from within an ABAP program with parameters appropriate for the type. You should therefore check all programs that use the associated function modules before activating the lock object with the new option.
Choose .
Result
When you activate the lock object, the two function modules ENQUEUE_<lockobjectname> and DEQUEUE_<lockobjectname> are generated from its definition to set and release locks.
Regards
Vasu -
Custom Lock objects few question issues
Hello guys , i create a custom lock object for my z tables ( ZFISGC_MCFG ) which have 3 key field
MANDT
ID_EMPRESA
CL_MVTOSGC
now in my program doing testing i put a break point after the ENQUEUE_ of the lock object
then when i go to the sm30 and try modif the value of the entry using the same key i pass to the ENQUEUE_ fm i can modif and save the entry now i am now if that is the right workflow in custom object lock or if i am doing something wrong , this is how i can the enqueue FM:
call function 'ENQUEUE_EZFISGCOBJECT'
EXPORTING
MODE_ZFISGC_MCFG = 'E'
MANDT = SY-MANDT
ID_EMPRESA = p_bukrs
* X_ID_EMPRESA = ' '
* _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.
ThanksYou have to remember that SAP locks are logical locks, not physical. This means that whatever you enqueue is not physically locked from changes. You have to ensure that any program that tries to update your table, first checks these locks and stops the update if it finds that it is already locked.
Rob -
Lock objet failure in enhacement
Hi
We have a problem with the concurrence in the legal number invoices. We realize that the lock object used works fine for the Quality environment test: different sessions; and different sessions and users.
The lock is not working on Productive environment; we could not reproduce the error, but believe that the problem is because the restrictions for the lock object.
CODE:
CALL FUNCTION 'ENQUEUE_EZTV_SD_EXP'
EXPORTING
mode_ztv_sd_exp = 'E'
mandt = sy-mandt
tipo_doc = 'F'
planta = v_werks
x_tipo_doc = space
x_planta = space
_scope = 2
_wait = 3
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.
SELECT SINGLE
FOR UPDATE
FROM ztv_sd_exp
INTO st_ztv_sd_exp
WHERE tipo_doc EQ 'F'
AND planta EQ v_werks.
CASE sy-subrc.
WHEN 0.
st_ztv_sd_exp-status = st_ztv_sd_exp-status + 1.
UNPACK st_ztv_sd_exp-status TO st_ztv_sd_exp-status.
MOVE: st_ztv_sd_exp-status TO st_vbrk-xblnr.
MOVE: st_ztv_sd_exp-status TO xvbrk-xblnr.
MODIFY xvbrk INDEX 1 FROM st_vbrk.
CASE sy-subrc.
WHEN 0.
MODIFY ztv_sd_exp FROM st_ztv_sd_exp.
CASE sy-subrc.
WHEN 0.
WHEN OTHERS.
MESSAGE e398(00) WITH 'Imposible Actualizar Tabla'.
ENDCASE.
CALL FUNCTION 'DEQUEUE_EZTV_SD_EXP'
EXPORTING
mode_ztv_sd_exp = 'S'
mandt = sy-mandt
tipo_doc = 'F'
planta = v_werks.
WHEN OTHERS.
MESSAGE e398(00) WITH 'Imposible Actualizar Memoria'.
ENDCASE.
WHEN OTHERS.
MESSAGE e398(00) WITH 'Imposible Bloquear Tabla'.
ENDCASE.
ENDIF.
Any help would be helpful
thanksActually I was refering to what was the error that you were seeing in production, but I'm assuming that what you're seeing is a combination of contention and the numbers getting out of sequence, so I'll give it a shot in answering.
A couple of general comments:
- You don't need to use both an enqueue object and a Select For Update. A Select For Update does an actual explicit DB lock as opposed to an enqueue logic uses a logic lock via the application server and is a better approach. I usually recommend the use of an enqueu object.
- Your check after the Enqueue object done checks sy-Subrc but unless a system message is raised that has a type that will cause the transaction to abort then it will continue on and attempt the update
- If you are just trying to keep an ongoing counter, I suggest using a Number Range Object. The object can be created in transaction SNRO and then you use the function "Number_Get_Next" to get the next number in the series. It is important though to ensure that you set up the Number Range Object according to it's purpose, for example if it is set with buffering turned on and a number higher then zero for the number of numbers to keep in memory then there is the possibility that you may end up with gaps in the assigned numbers. If you do not set buffering turned on then there will be no gaps in the numbers assigned but only one concurent program can access at a time (the number range object is help until the transaction is commited).
With regards to what you are attempting to do, if you can not use a number range object then I would suggest staying with the enqueue object but removing the Select For Update. The problem though that you will encounter and is most likely causing some issues is that you shouldn't be doing an explicit Dequeue prior to the transaction being commited becuase this will mean that another transaction can get the enqueue object prior to the first transaction being commited. You need to hold onto the lock until the transaction is complete.
In the end, I would say that there are these issues with the logic in your program but my primary recomendation is that you implimnet number ranges instead of trying to reinvent the wheel on this one.
~Ian -
What is the use for lock object and how to use the lock objects
Hi Guru's,
I am new to ABAP .Can you please clarify the that what is the use of lock object and how to use the loct object .what is use of the Deque & Enque function modules .hi ,
below are some minfo about lock objects :
Lock Objects
These types of objects are used for locking the access to database records in table. This mechanism is used to enforce data integrity that is two users cannot update the same data at the same time. With lock objects you can lock table-field or whole table.
In a system where many users can access the same data, it becomes necessary to control the access to the data. In R/3 system this access control is built-in on database tables. Developers can also lock objects over table records.
To lock an object you need to call standard functions, which are automatically generated while defining the lock object in ABAP/4 dictionary. This locking system is independent of the locking mechanism used by the R/3 system. This mechanism also defines LUW i.e. Logical Unit of Work. Whenever an object is locked, either by in built locking mechanism or by function modules, it creates corresponding entry in global system table i.e. table is locked. The system automatically releases the lock at the end of transaction. The LUW starts when a lock entry is created in the system table and ends when the lock is released.
Creating Lock Objects
Lock object is an aggregated dictionary object and can be defined by using the following steps:
o From initial data dictionary screen, enter the name for the object, Click Lock object radiobutton and then click on Create. The system displays a dialog box for Maintain Lock Objects screen
o Enter short text as usual and the name for primary table.
-Save
-Select Tables option
From this screen you can:
Select secondary tables, if any, linked by foreign key relationship.
Fields for the lock objects. This option allows you to select fields for objects (R/3 system allows locking up to record level). Lock object argument are not selected by user but are imposed by the system and includes all the primary keys for the table.
1) Exclusive lock: The locked data can only be displayed or edited by a single user. A request for another exclusive lock or for a shared lock is rejected.
2) Shared lock: More than one user can access the locked data at the same time in display mode. A request for another shared lock is accepted, even if it comes from another user. An exclusive lock is rejected.
3) Exclusive but not cumulative: Exclusive locks can be requested several times from the same transaction and are processed successively. In contrast, exclusive but not cumulative locks can be called only once from the same transaction. All other lock requests are rejected.
Also, last but not the least, locking the object is logical (locking with any enqueue ) .so, you have to use the lock object while trying to access from second program .
reward if helpful ,
Regards,
Ranjita -
Query in Lock Transaction!!!!
Hi all,
One of the user used the transaction CRMD_ORDER_PA and he has got 4900 Lock Entries.
Can anyone please tell me the reason for the same and how such conditinos can be avoided in future.
Kindly reply immediately as this is bit urgent.
Regards,
VijayThe number of locks acquired by each transaction (it is important to have this concept in mind when dealing with logical locks) differs largely among both tests. This is due to three reasons:
1. Since you are using the default transaction isolation level (read commited), locks are acquired and released at the start and end of each statement. When you issue an update command, assuming no lock escalation, an exclusive lock will be acquired on eacg
row that is to be updated, an intent exclusive lock will be acquired on the table (preventing schema changes during the update) and another intent exclusive lock will be placed on the entire database, preventing it from being modified (taken offline, for example).
This means the number of locks generated by the first test is the number of rows updated times three.
2. Lock escalation is intended to reduce the number of locks that need to be managed in memory by the database engine, reducing resource usage. It wouldnt make any sense if, despite locks being escalated, the second test generated a number of locks equal
to the number of rows updated. Past the 5k lock threshold, locks will start being acquired on the whole page in which an accessed row is stored. If the number of page locks goes beyond 5k, the locks are again escalated to the whole object.
3. Even if you disabled lock escalation on the second test, it would still acquire much less locks because the intent exclusive locks on both object and database would only be acquired once, therefore the number of locks generated would be N+2.
Just because there are clouds in the sky it doesn't mean it isn't blue. But someone will come and argue that in addition to clouds, birds, airplanes, pollution, sunsets, daltonism and nuclear bombs, all adding different colours to the sky, this is an undocumented
behavior and should not be relied upon.
Maybe you are looking for
-
Hi there, I have a new laptop. I have music on my laptop that I have not purchased through iTunes (ie, uploaded CD's, copied to my laptop from my old computer, etc). For some reason, iTunes will not allow me to transfer this music to my iPhone. I get
-
Error message while loading XML parser into db
I get the following error message while loading xmlparserv2.jar ORA-29534 referenced object SYSTEM.oracle/xml/parser/v2/XMLNOde could not be resolved ORA-29545: badly formed class: java.lang.NullPointerException using XSU111 package
-
Upgrading Struts in JDeveloper 10.1.3.5
Hi everyone, Is it even recommended or prudent to upgrade the struts libs in Jdeveloper? 10g ships with struts 1.1, and we're looking at upgrading to 1.3.10 (I've read struts 2 is too much of a jump)... I've read the following article from Duncan Mil
-
I just bought this laptop and I want to wipe the drive clean. It is an HP dv7-1132 NR with Vista home premium 64 bit but still on Service Pack 1. It came with no system restore disks so I made my own through the System Recovery Manager. Apparently th
-
Inserting graphics in MS Office Mac 2004
Hi MacFriends! When in Word and I select "Insert" then "Picture" and navigate to a folder of pictures, all I see ans are icons. I find it difficult to know what to select. How can I set Word to display thumbnails of the pictures/graphics so I can see