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
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. APPEND 'CALL FUNCTION 'SAVE_TEXT' TO program. APPEND 'IN BACKGROUND TASK' TO program. .... CALL FUNCTION 'RFC_ABAP_INSTALL_AND_RUN' EXPORTING MODE = 'F' PROGRAMNAME = '<<RFC1>>' * IMPORTING * ERRORMESSAGE = TABLES 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.
Related Q&A from Axel Angeli
An SAP user wants to know how to upload data into SAP R/3 when SAP Scripting is not enabled.continue reading
An SAP user is receiving an error message while integrating SAP iDoc PORDCR1 for a purchase order.continue reading
An SAP user is having difficulty with PERNR iDoc while transporting data from SAP to an external system.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.