Show TOC

Transactional RFC Server ProgramsLocate this document in the navigation structure


After having connected to an SAP system (via RfcRegisterServer or RfcStartServer ) and after having installed the supported RFC functions, the RFC server program has to use the RFC call RfcSetTransactionHandlers for working with the TIDs to check and execute the real RFC function it supports before entering in the loop with RfcListenAndDispatch .

This function installs the following four functions to control transactional behavior:


    This function will be activated if a tRFC is called from an SAP system. The current TID is passed. The function has to store this TID in permanent storage and return 0. If the same function will be called again later with the same TID, it has to make sure that it will return a value <>0. If the same TID is already running within another process but is not completed, the function has to wait until the transaction finishes or the server sends a corresponding return code.


    This function will be called if all RFC functions belonging to this transaction are done and the local transaction can be completed. It should be used to locally commit the transaction if necessary (working with database).


    This function is called instead of the function RFC_ON_COMMIT_TRANSACTION if there is an error occurring in the RFC library while processing the local transaction. This function can be used to roll back the local transaction (working with database).


    This function will be called if the local transaction is completed. All information about this TID can be deleted.


    These four 'technical' functions must be implemented once in a tRFC server program. They can be reused by any business function that is to be executed as tRFC function.

    If you do not install and work with these four functions it can not be guaranteed that an RFC call issued by CALL FUNCTION... IN BACKGROUND TASK is executed by this RFC server program exactlyonce .

tRFC between tRFC component, RFC library and tRFC server program

The tRFC component, the RFC library and the tRFC server communicate with each other in two phases:

  • Phase 1/F1: Function transfer

  • Phase 2/F2: Confirmation

F1: Function transfer

After tRFC data is received, the RFC library will activate the tRFC server program (action: start ). Using RfcDispatch in a loop, the library will call up the following functions within this function transfer phase:


  • T2 : the required RFC function 'abc_function'



As described above, the function transfer phase will be repeated by the tRFC component in the SAP system if any CPI-C error (network errors, for example) occurs during this phase. The maximum number of tries and the time between two tries can be defined by using transaction SM59 and TRFC options .


    If the call finally fails, the transaction will be rolled back completely.

F2: Confirmation

After the RFC library informs the tRFC components in the SAP system about a successful T3, it will immediately receive confirmation of the current transaction. The RFC library will then call up the function


After this phase, the current transaction is successfully completed on both sides.