Transactional Integrity of tRFCsYou can execute function modules in background tasks in another R/3 System or an external program. When you call function modules in this way, they are not executed at once, but wait until a COMMIT WORK is triggered.
Transactional RFCs receive there name from the fact that the associated remote function call mechanism guarantees transactional integrity for all calls made with the IN BACKGROUND TASK suffix. As with database updates, LUWs (logical units of work) are created for calls that are scheduled to run in background tasks. All tRFCs with a single destination that occur between one COMMIT WORK and the next belong to a single LUW. Within a given LUW, all calls:
● are executed in the order in which they are called
● run in the same program context in the target system
● run as a single transaction: they are either committed or rolled back as a unit.
LUWs are identified by transaction IDs that are unique world-wide. The transaction ID can be determined from an ABAP program by calling function module ID_OF_BACKGROUNDTASK. (You have to call this function after the first asynchronous CALL, and before the related COMMIT WORK.)
Because the RFC is like a transaction, database operations are either all executed or - if a function module terminates - all rolled back. If an LUW runs successfully, you cannot execute it again. In some cases, it may be necessary to program the roll back of an LUW, (for example, because a table is locked). To do this, you call the function module RESTART_OF_BACKGROUNDTASK which performs a rollback and ensures that the LUW is executed again later.
Normally, the LUW is executed immediately after COMMIT WORK in the specified target system. However, you can also define a certain time at which you want the execution to be made. To do this, call the function module START_OF_BACKGROUNDTASK from within the affected LUW after the first CALL... IN BACKGROUND TASK and before COMMIT WORK.
You can also
execute programs asynchronously in 'C'-implemented function modules
(connection type TCP/IP in transaction SM59, see
Destination
Types). As usual, the function modules are implemented in connection with
the RFC API. The RFC library contains function modules ARFC_DEST_SHIP and ARFC_DEST_CONFIRM that call the appropriate functions.