Function documentation Using Asynchronous Remote Function Calls Locate the document in its SAP Library structure

Asynchronous remote function calls (aRFCs) are similar to transactional RFCs, in that the user does not have to wait for their completion before continuing the calling dialog. There are three characteristics, however, that distinguish asynchronous RFCs from transactional RFCs:

The parameters of asynchronous RFCs are not logged to the database, but sent directly to the server.

You can use asynchronous remote function calls whenever you need to establish communication with a remote system, but do not want to wait for the function’s result before continuing processing. Asynchronous RFCs can also be sent to the same system. In this case, the system opens a new session (or window) and allows you to switch back and forth between the calling dialog and the called session.

To start a remote function call asynchronously, use the following syntax:

CALL FUNCTION RemoteFunction STARTING NEW TASK taskname

Destination ...

EXPORTING...

TABLES ...

EXCEPTIONS...

Note

The following calling parameters are available:

passes references to internal tables. All table parameters of the function module must contain values.

passes values of fields and field strings from the calling program to the function module. In the function module, the correponding formal parameters are defined as import parameters.

see Using Pre-Defined Exceptions for RFC

RECEIVE RESULTS FROM FUNCTION func is used within a FORM routine to receive the results of an asynchronous remote function call. The following receiving parameters are available:

The addition KEEPING TASK prevents an asynchronous connection from being closed after receiving the results of the processing. The relevant remote context (roll area) is kept for re-use until the caller terminates the connection.

Example

Call a transaction asynchronally and display it in an amodal window:

DATA: MSG_TEXT(80) TYPE C. "Message text

...

* Asynchronous call to transaction SM59 ->

* Create a new session

CALL FUNCTION ‘ABAP4_CALL_TRANSACTION’ STARTING NEW TASK ‘TEST’

DESTINATION ‘NONE’

EXPORTING

TCODE = ‘SM59’

EXCEPTIONS

COMMUNICATION_FAILURE = 1 MESSAGE MSG_TEXT

SYSTEM_FAILURE = 2 MESSAGE MSG_TEXT

IF SY-SUBRC NE 0.

WRITE: MSG_TEXT.

ELSE.

WRITE: ‘O.K.’

ENDIF.

Details are explained in the following topics:

Calling Requirements for Asynchronous RFCs

Receiving Results from an Asynchronous RFC

Keeping the Remote Context

Parallel Processing with Asynchronous RFC

 

 

Leaving content frame