Perform on rollback
If you know “perform on rollback”, stop reading. But I experienced that a lot of people do not know about “perform on rollback”
The situation was that I had to add some functionality to a process which “provides” me with a rollback, but I had to store the information that I at least attempted to do something…so either change the complete framework or perform on rollback
Unfortunately perform-on-rollback can not have any parameters and therfore I did the following:
- create one class with a static class method which actually does what I want to be done: save data to dataase, e.g. CL_STORAGE=>SAVE and
- create one class method which provides the data to the SAVE method, e.g. CL_STORAGE=>SET_DATA.
- Also create a method which you have to call once to “register” the SAVE-method to be called regardless of the rollback/commit.
- Then create a form routine which calls the CL_STORAGE=>SAVE method and
- create one form routine which does the perform-on-rollback.
This will somehow look like:
perform store_my_data on ROLLBACK.
perform store_my_data on COMMIT.
And the class methods:
PERFORM execute_regardless IN PROGRAM blahblubb.
You can imagine the rest…