Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ON COMMIT ABAP CLASS METHOD

Former Member
0 Kudos

Hi Friends,

Can i execute and abap oo method on commit work.

similiar to perform form on commit.

thanx

1 ACCEPTED SOLUTION

christian_wohlfahrt
Active Contributor
0 Kudos

Hi Kaushik!

This should be possible, but with a little bit different approach:

You can implement an event handler for the commit event. Then you have to register this method for the commit event. Have a look at program SAPMSSY0. In routines %_before_commit, %_commit and %_after_commit you will find some events, e.g.

* Raise event 'Commit Requested' for Object Manager
  CALL METHOD cl_os_transaction_end_notifier=>raise_commit_requested.

, for which you might like to register your method.

Regards,

Christian

3 REPLIES 3

christian_wohlfahrt
Active Contributor
0 Kudos

Hi Kaushik!

This should be possible, but with a little bit different approach:

You can implement an event handler for the commit event. Then you have to register this method for the commit event. Have a look at program SAPMSSY0. In routines %_before_commit, %_commit and %_after_commit you will find some events, e.g.

* Raise event 'Commit Requested' for Object Manager
  CALL METHOD cl_os_transaction_end_notifier=>raise_commit_requested.

, for which you might like to register your method.

Regards,

Christian

This methods are now privates.

The only friend of cl_os_transaction_end_notifier is cl_os_transaction

which have the event : IF_OS_TRANSACTION~SAVE_REQUESTED.

So here what I've done :

In the class constructor :

data O_mngr type ref to if_os_transaction_manager.

data o_trans type ref to if_os_transaction.

O_mngr = cl_os_system=>get_transaction_manager( ).

O_tran = O_mngr->Get_current_transaction( ).

Set handler my-event for O_tran.

I hope it'll helps...

Please also note that you could do a loopback with a perform on commit to the class (need to be adapted for instance).

To do so create a module pool with 2 forms :

form register.

perform loopback on commit level 2147483647.

endform.

form loopback.

ZCL_MY_CLASS=>MY_LOOPBACK_ENTRY( ).

endform.

Please also note that IF_OS_TRANSACTION~SAVE_REQUESTED is raised on %_before_commit,

while PERFORM ON COMMIT is raised on %_commit, so a few later on.

This could be usefull when you need to register FM in update task at the very last moment.

Usefull link on Commit sequence :https://help.sap.com/abapdocu_70/en/ABAPCOMMIT.htm

And perform on commit : https://help.sap.com/abapdocu_70/en/ABAPPERFORM_SUBR.htm