Entering content frameFunction documentation Receiving Results from an Asynchronous RFC Locate the document in its SAP Library structure

To receive results from an asynchronously called function, use the following syntax:

CALL FUNCTION RemoteFunction

STARTING NEW TASK Task

PERFORMING RETURN_FORM ON END OF TASK.

Once the called function is completed, the next dialog step in the calling program (such as AT USER-COMMAND ) guides the system into the FORM routine that checks for results. This FORM routine consists of a special syntax and must be called with a using parameter that refers to the name of the task:

Client System

CALL FUNCTION ‘TRAVEL_CREATE_FLIGHT’

STARTING NEW TASK ‘FLIGHT’

DESTINATION ‘S11’

PERFORMING RETURN_FLIGHT ON END OF TASK.

...

FORM RETURN_FLIGHT USING TASKNAME.

RECEIVE RESULTS FROM FUNCTION ‘TRAVEL_CREATE_FLIGHT’

IMPORTING FLIGHTID = SFLIGHT-ID

EXCEPTIONS SYSTEM_FAILURE MESSAGE SYSTEM_MSG.

SET USER-COMMAND ‘OKCD’.

ENDFORM.

Note

The key word RECEIVE occurs only with the function module call CALL FUNCTION func STARTING NEW TASK taskname . If the function module returns no results, this part need not be defined.

Note

The key word RECEIVE is new from R/3 Release 3.0 onwards. Therefore, both partner systems, client and server, must have Release 3.0 of the R/3 System.

For more information on RECEIVE , see the online help in the ABAP editor.

The effect of the SET USER-COMMAND ‘OKCD’ statement is exactly as if the user had entered the function in the command field and pressed ENTER. This means that the current positioning of the list and the cursor is taken into account.

Note

No call-backs are supported.

Caution

The SET USER-COMMAND ‘OKCD’ statement replaces the REFRESH SCREEN command. REFRESH SCREEN is no longer maintained and should therefore not be used.

Example

DATA: INFO LIKE RFCSI,

* Result of RFC_SYSTEM_INFO function

MSG(80) VALUE SPACE.

* Exception handling

CALL FUNCTION ‘RFC_SYSTEM_INFO’

STARTING NEW TASK ‘INFO’

PERFORMING RETURN_INFO ON END OF TASK

EXCEPTIONS

COMMUNICATION_FAILURE = 1 MESSAGE MSG

COMMUNICATION_FAILURE = 2.MESSAGE MSG.

IF SY-SUBRC = 0.

WRITE: ‘Wait for reply’.

ELSE.

WRITE MSG

ENDIF.

...

AT USER-COMMAND.

* Return from FORM routine RETURN_INFO via SET USER-COMMAND

IF SY-UCOMM = ‘OKCD’.

IF MSG = SPACE.

WRITE: ‘Destination =‘, INFO-RFCDEST.

ELSE.

WRITE MSG.

ENDIF.

ENDIF.

...

FORM RETURN_INFO USING TASKNAME.

RECEIVE RESULTS FROM FUNCTION ‘RFC_SYSTEM_INFO’

IMPORTING RFCSI_EXPORT = INFO

EXCEPTIONS

COMMUNICATION_FAILURE = 1 MESSAGE MSG

SYSTEM_FAILURE = 2 MESSAGE MSG.

SET USER-COMMAND ‘OKCD’. "Set OK-code

ENDFORM.

 

 

Leaving content frame