This post is part of a series on code snippets. The complete list of posts in the series is available in the document Code Snippets: A Blog Series.
I occasionally need to wait for a lock entry to be dequeued when I have a multi-step scenario where COMMIT WORK AND WAIT is insufficient but waiting a static number of seconds with WAIT UP TO n SECONDS could result in waiting longer than necessary.
With the below code, I reduce wait time to the shortest possible wait--depending on use, even down to one tenth of a second.
DATA lt_enq TYPE STANDARD TABLE OF seqg3.
DATA: BEGIN OF ls_time,
start TYPE timestampl,
now TYPE timestampl,
elapsed TYPE tzntstmpl, " in seconds
limit TYPE tzntstmpl VALUE 3, " in seconds
END OF ls_time.