2016 Sep 13 12:17 PM
Hi,
I am using this BAPI to assign characteristics in side a sales order loop.
it is working for 1st item, but getting lock error for rest all records(sales items/orders).
How to remove the lock entries, how can we use any enque / deque function modules.
I tried using DESTINATION NONE, but after that COMMIT is not working so records are not updating.
Thanks in advance.
chandra.
Instead of using your own wait logic, you can also use ENQUEUE_xxxxx with the mode U or V and the _wait parameter = 'X'. The wait logic progressive increases in duration and does a better job of preventing deadlocks than a static wait of 1 second.
2016 Sep 13 12:25 PM
Forcing dequeue of locks is always a bad idea because you cannot know what's going on under the hood.
My suggestion is to put in a DO...ENDO FM ENQUEUE_READ: if no locks found then exit, else wait 1 second.
Exit anyway after 100 times so you avoid endless loops.
2016 Sep 13 2:00 PM
Instead of using your own wait logic, you can also use ENQUEUE_xxxxx with the mode U or V and the _wait parameter = 'X'. The wait logic progressive increases in duration and does a better job of preventing deadlocks than a static wait of 1 second.
2016 Sep 13 3:34 PM
And today i learned something new, thanks!
I always used ENQUEUE_READ since i'm a bit lazy to check every lock object
2016 Sep 13 4:53 PM
You are welcome. I am lazy too ... Here is my argument for laziness - and more reading if you feel like it.
I use SM12 (same data as ENQUEUE_READ) to figure out which ENQUEUE_xxx function module to use... and if there are multiple, I usually pick the most obvious one. In Chandra Sekar's example I would pick the sales order one, even though there may be locks on the batch. And then...
CALL FUNCTION 'ENQUEUE_EVVBAKE'
EXPORTING
mode_vbak = 'V' " Lock mode for table VBAK
vbeln = l_sales_order " 02th enqueue argument
_wait = abap_true
EXCEPTIONS
foreign_lock = 1
system_failure = 2
others = 3.
I have complete control over the exact sales order too... that way no need to filter the return of ENQUEUE_READ in case the user has another sales order open in a different window, etc.... and no need to implement your own wait logic either.
Another trick that I use... the wait does time out - default is 5 seconds (more about this in a second)... I might check for another possible object next. For instance if I am working with a delivery too, I might check the delivery and sales order in sequence to get me a total wait of 10 seconds.
A little upfront work finding the correct lock object, but then much less after that.
Now about that wait time... You can change it by changing the system parameter enque/delay_max in RZ11. And while you are at it, read the documentation on enque/delay_jitter, it gives you an idea of how it prevents deadlocks. Something I had to do in my old VB & SQL-Server days. Ahh the memories
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |