09-26-2009 1:41 PM
Dear community members,
within a transactional framework, developped in ABAP-OO (SAP NM 7.0), I would like several methods, mainly clean-up methods, to run after a 'commit work' has been triggered. The transacational framework, however, does not trigger the 'commit work' itsself, but has to listen on the 'commit work' event and to execute the clean-up methods.
Does anybodya of you know, how such a 'listener' class could look, or how one could react on the 'COMMIT WORK'-event 'or even an 'AFTER COMMIT'-event in an ABAP-OO context?
Thanks and best regards
Stefan
09-28-2009 5:55 AM
Define a global class (or using your class, define methods):
class post_commit_handler definition.
public section.
class-methods trans_finished for event transaction_finished
of cl_system_transaction_state
importing kind.
endclass. "post_commit_handler DEFINITION
class post_commit_handler implementation.
method trans_finished.
set handler post_commit_handler=>trans_finished activation false.
" clean up
endmethod. "trans_finished
endclass. "post_commit_handler IMPLEMENTATION
In the code just before you trigger the commit:
set handler post_commit_handler=>trans_finished.
matt
10-02-2009 11:26 AM
02-03-2021 11:41 PM
Hi, i tried to use this approach to call functionality that does some side effects on the systems... (e.g: calling a BAPI).
The issue is that you cannot commit work inside the method implementation for the event 'transactions_finished'.
If you do, you get the following 'Dump':
The only solution I found is to 'wait up to...' in order to achieve an implicit commit and persist the functionality called in the method.
What do you think about this approach? Can you recommend a better solution?
Thank you
02-04-2021 8:34 AM
Create a function module to do the work. Set it so that it runs in the update task - V2. Call it from your method. CALL FUNCTION ... IN UPDATE TASK.
Alternatively, mark it as RFC enabled, and call it from your method as CALL FUNCTION ... STARTING NEW TASK.