2014 Apr 23 7:31 AM
Hi,
I have a report used by several users and in this record there is a sentence to insert in a z table. My question is, what happens whether two or more users are inserting records in that table at the same time? There is a concurrency problem, isn't there?
How does SAP manage this issue? or, what must I do in this case?
Thanks in advance.
Regards.
2014 Apr 23 7:37 AM
Hi David,
Please search about Enqueue and Dequeue funtion modules.
There is a Lock Mechanism that you can put in place to avoid data inconsistency issues.
There is a lot of information on SCN/web.
Please get back for specific doubts.
Regards,
DN.
2014 Apr 23 7:52 AM
Thanks for your reply and your help.
Each time that a user run the report only one record is inserted in the z table. My doubt is what could happen if two users try to insert at the same time? Have I to manage this one or not?
Regards.
2014 Apr 23 7:57 AM
2014 Apr 23 9:04 AM
David,
Place a lock before inserting data into table with specified key. Do, insert operation and then release the lock on the specified key table.
In case, more than one user tries to insert same data with same key, then only one user able to insert data and another will get lock.
2014 Apr 23 9:28 AM
Hi David,
As SAP applications are accessed by many end users at same time, SAP has concept called LOCKING of particular tables involved in the transaction.
You can achieve your requirement as below
- Go to t-code SE11, and create a lock object for your Ztable
- Now, system create 2 function modules - 1 for locking ENQUEUE_* & other for un-locking DEQUEUE_* ( search for function module in SE37 )
- Before saving data to ZTABLE, call function module ENQUEUE_* to lock the table for writing data, if locking fails, means there is somebody already working on it, hence you can display error message
- After Save action, you can unlock the table by using FM ... DEQUEUE_*
Note: you can lock and unlock event during DISPLAY/CHANGE mode if your requirement requires.
Hope this helps you.
Regards,
Rama