2022 Oct 29 3:27 PM
Hi experts,
I have a use case to update multi tables with enqueue and dequeue lock object.
Usually, the code sequence is like Enqueue->Update->Dequeue, but if the exception should be taken into consideration, for example, the code was like below:
CALL FUNCTION 'ENQUEUE'.
TRY.
CALL METHOD zcl_aaa=>maint_mult( ).
CATCH /cx/excp.
RAISE error_update.
ENDTRY.
CALL FUNCTION 'DEQUEUE'.
I think if "error_update" was raised, the Dequeue function could be missed, so I think may be "DEQUEUE" function also needs to be called before "error_update" was raised.
I am wondering if there is a better way.
Regards,
Eric
2022 Oct 30 10:03 AM
It's not that difficult to dequeue the locks whatever happens. You may use one method to dequeue, you have CLEANUP, etc.
If you use ROLLBACK WORK, it dequeues all scope 2 locks.
COMMIT WORK also takes care of the locks.
In other cases, you may either dequeue explicitly, or dequeue all with function module DEQUEUE_ALL.
See the ABAP documentation for more information.
NB: you should use the old form of RAISE only if you're implementing code inside existing code which requires the use of the old form.