Transactional RFC Client Programs

After having been connected to an R/3 System (via RfcOpen), an RFC client program must use the following two RFC calls for working with the tRFC interface:

With this call, the RFC library tries to get a TID created by the R/3 System. If errors occur, the RFC client program has to reconnect later and must try to repeat this call. Otherwise, the RFC client program can assign this TID with the RFC data, and if the next call is not successful, it can be repeated later.

With this call, the RFC library will pack all RFC data belonging to an RFC function together with the TID and send them to the R/3 System using the tRFC protocol.
If an error occurs, the RFC client program has to reconnect later and must try to repeat this RFC call (RfcIndirectCall). In this case, it has to use the old TID and must not get a new TID with RfcCreateTransID. Otherwise, there is no guarantee that this RFC function will be executed exactly once in the R/3 System.
After this call is executed successfully, the transaction will be completed once and for all. The RFC client program can then update its own TID management (e.g. delete the TID entry).

Contrary to tRFC between R/3 Systems, a transaction from an RFC client program contains only one RFC function.

Technical Description

Sample test program trfctest.c

The C program trfctest.c which is delivered in the RFC SDK (executable and source code) is an example of a tRFC client program.

To connect to an R/3 System, a saprfc.ini file is needed.

Data which is to be transferred to an R/3 System via tRFC must be in a file. The file name will be required when the program is started. Each line in this file is one line in an internal table. Only one internal table with a 72-bit line length is used.

All data which is received in the R/3 System will be written in the TCPIC table in an R/3 System (only the first 40 bytes), and the function module STRFC_WRITE_TO_TCPIC will be activated.

The trfctest.c program uses the file I/O on the running platform to manage the TIDs.

For each TID there is an entry in the TID management. This entry contains the date and time, the TID itself, the state of the transaction (CREATED, CONFIRMED,...) and the name of the data file.

It is possible to break up the program trfctest.c in order to simulate error cases.

Whenever this program is started, it will look at the TID management for aborted transactions. If any transactions exist it will first try to repeat these transactions.

Since the program trfctest.c can be run on different platforms, a corresponding flag (SAPonUNIX, SAPonNT,...) must be set if you want to compile and link this program in your environment.

For more details, see the source code delivered with the RFC SDK.