In some cases it is required to integrate logic implemented by the help of BOPF into other applications. Using the service manager of BOPF, all application logic can be easily consumed by other applications. But what is about the saving a transaction?
In a standalone BOPF application, the consumer ends the current transaction by the help of the standalone transaction manager. It provides the option to make the current transaction undone (called "cleanup") or to save all changes since the last save to persistency (called "save").
Example:
DATA(lo_transaction_manager) = /bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( ).
lo_transaction_manager->save( ).
While executing the save, BOPF registers by default an update task to write the modifications done in the current transaction from buffer into the database tables. Finally, a COMMIT WORK is executed. However, there are situation that do not allow BOPF to raise a COMMIT WORK. For instance, if the BOPF application is integrated into an existing application or foreign application framework.In that case, a slave transaction manager can be used by the foreign application to prepare the BOPF objects of the current transaction for the saving and afterwards to execute the COMMIT WORK. The foreign application is called master transaction manager as it invokes the COMMIT WORK and ROLLBACK WORK - and not the BOPF:
The master transaction manager (called "Legacy Application" in the picture) has to call Finalize/CheckBeforeSave/... on the slave transaction manager before triggering the COMMIT WORK. This triggers for instance the execution of the finalize determination of the participating BOPF BOs.
Example:
DATA(lo_slave_transaction_manager) = /bobf/cl_tra_trans_mgr_factory=>get_slave_transaction_manager( ).
lo_slave_transaction_manager->finalize( ... ).
After the COMMIT WORK, the BOPF BOs shall be invoked via the slave transaction manager's AfterSuccessfulSave core service. This is in priniciple only necessary if the the participating BOs have AfterCommit determinations configured and it is intended to continue with the next transaction in the same session.
Hint: You can check the implementation of method "/BOBF/CL_TRA_TRANSACTION_MGR->/BOBF/IF_TRA_TRANSACTION_MGR~SAVE()" to learn about the correct order and error handling of the Finalize/CheckBeforeSave/AdjustNumbers call sequence and the error handling in between.
