‎2011 Aug 09 8:30 AM
Dear Experts,
I have a z-table. A z-program selects data from SAP tables and updates this table via batch jobs with selection criteria.
If i run 2 or more such batch jobs with different or overlapping selections, what happens if
the z-program uses a simple "Update" command without FM ENQUEUE_E_TABLEE to lock the table and FM DEQUEUE_E_TABLEE to unlock table?
By default, when abap command updates a table with "update" , without the above 2 FMs, does it lock the z-table?
If not, how is data being updated in the table :
1. overlapping data selection.
2. disjoint data selection.
I cannot understand how can the server update concurrently when everything is sequential?
So, when there are 2 updates at the same time, is it not sequentially done , 1 after the other ? How can both updates be updated at exactly the same time when there is assuming a single disk written using a single write mechanism at any point in time?
regards
Bass
‎2011 Aug 09 8:47 AM
Hi
The fm ENQUEUE_E_TABLEE and FM DEQUEUE_E_TABLEE manages a logical lock only, this lock can be used to avoid several processes use the same object together.
That means the lock above has to be managed programmatically only: after checking the result of these function you need to decide if to update or not to update the table. (or to abort the process).
If nobody prevents several processes update the same table: the database places all processes in a queue and the last one overwrites all prevoius modifications (for the records with same key of course).
Max
‎2011 Aug 09 8:47 AM
Hi
The fm ENQUEUE_E_TABLEE and FM DEQUEUE_E_TABLEE manages a logical lock only, this lock can be used to avoid several processes use the same object together.
That means the lock above has to be managed programmatically only: after checking the result of these function you need to decide if to update or not to update the table. (or to abort the process).
If nobody prevents several processes update the same table: the database places all processes in a queue and the last one overwrites all prevoius modifications (for the records with same key of course).
Max
‎2011 Aug 09 10:18 AM
SAP database will automatically lock the table for you. So whichever batch hits the database first this will update the table then when that batch finishes the next will be allowed to write to the table.
‎2011 Aug 09 10:39 AM
Seeing two different answers here i want to point you to Max´s Answer as it is the correct one.
‎2011 Sep 04 5:19 AM
Thank you very much Florian,
I am also confused by the 2 types of answers.
Both to me sounds right.
I have also asked some colleagues who said the database handles this sort of thing by default.
If so, why the Enqueue and DeQueue functions exist?
So, I have to go with you and adopt Max's advise while also considering Gemini's .
regards
Bass
‎2011 Sep 05 5:51 AM
Gemini's answer is wrong and shows a complete lack of understanding of how locking is to be applied in SAP. Your colleagues who agree with Gemini are also wrong.
The database does have its own locking mechanism, but it must not be relied on or utilised for ABAP applications.
Edited by: Matt on Sep 5, 2011 6:55 AM