COMMIT WORK & SYSTEM EVENTS

Advertisements

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.

Execute-

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-

With rollback-

For rollback work-


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s