Problem solve Get help with specific problems with your technologies, process and projects.

tRFC and asynchronous calls of RFC from a non-R/3 client

You mentioned that BAPIs are RFC-enabled functions and that RFC call is executed synchronously. Now, I am executing a BAPI from an R/3 system with a RFC target/destination as an external program (say a Java program running a JCo client). Can this RFC call be executed in tRFC (transactional RFC) mode? If so, then what are the necessary steps in R/3 to achieve this?
Before I go into detail, I want to draw the reader's attention to a common misunderstanding. There is tRFC (transactional RFC) and the possibility to build transactions via RFC (since release 4.x)

tRFC (transactional or asynchronous RFC)
A tRFC is simply a renaming of what was known as asynchronous RFC. This is achieved by calling an RFC in a background task. So an tRFC call always looks like this:
call function 'funcname'
in background task
exporting ...
importing ...
tables ...
Doing so, the RFC will be executed asynchronously from the calling application, i.e. it is executed in its own transactional environment. This may be necessary if the immediate execution of the RFC cannot be guaranteed, e.g. when using a leased line or registered service, so that the receiver is online only during certain periods. The tRFC calls will be queued and executed when the receiver is online again.

BAPI transaction chains via RFC
BAPI RFCs are transactional by definition, i.e. a BAPI must not commit its work automatically. This allows to call multiple BAPIs in a sequence and then decide to COMMIT WORK or ROLLBACK WORK for the whole thing. Hence, you can build your own transactions by doing a sequence of BAPI calls. The COMMIT WORK and ROLLBACK are done with the special system BAPIs BAPI_TRANSACTION_COMMIT and BAPI_TRANSACTION_ROLLBACK.

tRFC (asynchronous RFC) from external clients
To my knowledge, calling an RFC in background task is not supported from external sources. I could imagine a workaround by calling the standard
DATA: program type standard table of abaptext.
               MODE = 'F'
               PROGRAMNAME = '<<RFC1>>'
*        IMPORTING
*               ERRORMESSAGE =
               program = program
*               writes =

This function allows execution of an arbitrary ABAP via RFC. The ABAP code is passed to the function as a text table. So you construct the necessary call and pass it to RFC_ABAP_INSTALL_AND_RUN which is used as a shuttle for your ABAP call. Because you want to make an asynchronous call, you do not have to wait for any response and can call the actual function module IN BACKGROUND TASK.

Dig Deeper on SAP supplier relationship management software