When a transaction is finished the data is either persisted or rolled back using the commands- COMMIT WORK ( & WAIT) or ROLLBACK WORK.
Now many a times we may need to react after the such commands- commit/rollback to do some other actions. But how to know if it is committed/rolled back?
Here is the way- the command COMMIT WORK ( & WAIT) or ROLLBACK WORK always triggers an event – TRANSACTION_FINISHED of class CL_SYSTEM_TRANSACTION_STATE which exports a parameter KIND whose value is either C ( committed) / R ( rolled back). We can register for this event and react on it.
The below program is a small example how to declare a event handler method and do the evet registration via set handler.
After the update function module- the commit work is trigged and then the event is raised, so the handler method is triggered and executed.
Here is the EVENT-
The export parameter KIND-
The values of KIND-
When commit work/rollback work is executed, the method, RAISE_TRANSACTION_FINISHED raise the event.
Let’s using the event parameter and print the value in our event handler.
For commit work-
For rollback work-