ABAP Keyword Documentation →  ABAP − Reference →  Data Interfaces and Communication Interfaces →  RFC - Remote Function Call →  CALL FUNCTION - RFC → 

CALL FUNCTION - STARTING NEW TASK

Short Reference

Syntax

CALL FUNCTION func STARTING NEW TASK task
              [DESTINATION {dest|{IN GROUP {group|DEFAULT}}}]
              [{CALLING meth}|{PERFORMING subr} ON END OF TASK]
              parameter_list.

Extras:

1. ... DESTINATION IN GROUP {group|DEFAULT}

2. ... {CALLING meth}|{PERFORMING subr} ON END OF TASK

Effect

Asynchronous call (aRFC) of a remote-enabled function module specified in func using the RFC interface. Use addition DESTINATION to specify a single destination in dest or use IN GROUP to specify a group of application servers. The latter supports parallel processing of multiple function modules. The calling program is continued using the statement CALL FUNCTION, as soon as the remotely called function has been started in the target system, without having to wait for its processing to be finished. Use CALLING and PERFORMING to specify callback routines for the takeover of events when the remotely called function is terminated. func and dest expect character-like data objects.

If the destination is not specified and also not defined using the addition KEEPING TASK of the statement RECEIVE, then the destination "NONE"is used implicitly. The asynchronous RFC does not support communication with external systems or programs written in other programming languages.

A character-like data object must be specified for task. This object must contain a freely definable task ID with a maximum of eight digits for the remotely called function module. This task ID must be unique for each call, and is handed to the callback routines for identifying the function. Every task ID defines its own RFC connection with its own context, so that for repeated calls of function modules of the same task ID and with the same destination, the global data of the associated function group can be accessed if the connection is still available. (This is the case, for example, if the PERFORMING or CALLING addition is used. For asynchronous RFC without a response (without the PERFORMING or CALLING addition), the RFC connection is closed immediately after the call.)

More Information

For more information on aRFC, see Asynchronous RFC (aRFC) in the SAP Library.

Notes

Addition 1

... DESTINATION IN GROUP {group|DEFAULT}

Effect

If IN GROUP is specified as the destination, this supports parallel execution of multiple function modules on a predefined group of application servers of the current AS ABAP. This variant of aRFC is also known as parallel remote function call (pRFC).

group expects a data object of the type RZLLI_APCL from ABAP Dictionary, either an initial data object or one that includes the name of an RFC server group created in transaction RZ12. If DEFAULT is specified or if group is initial, all currently available application servers of the current AS ABAP are used as the group. Only one RFC server group may be used within a program. During the first asynchronous RFC using the addition IN GROUP, the specified RFC server group is initialized. For each asynchronous RFC where the group is specified, the most suitable application server is determined automatically, and the called function module is executed on this.

If the function module cannot be executed on any of the application servers, because not enough resources are available at present, a predefined exception RESOURCE_FAILURE is raised, to which, in addition to the other RFC exceptions, a return code can be assigned. For this exception, the addition MESSAGE is not permitted.

Notes

Addition 2

... {CALLING meth}|{PERFORMING subr} ON END OF TASK

Effect

Use this addition to specify either a method meth or a subroutine subr as the callback routine executed after terminating the asynchronously called function module. For meth, the same information can be specified as for method call, in particular the dynamic information. subr expects a subroutine of the same program to be specified statically.

The method meth must be public, and can have only one non-optional input parameter p_task of type clike. The specified subroutine subr can have exactly one USING parameter of the type clike. In the call, the RFC interface fills this parameter with the task ID of the remotely called function specified in the call in task. In the method meth or in the subroutine subr, the statement RECEIVE can be used to receive the results of the remote function. In the callback routine, no statements can be executed that interrupt the routine or that trigger an implicit database commit. Class-based exceptions must be handled within the callback routine. Statements for list output are not executed.

A prerequisite for the execution of the callback routine is that the calling program still exists in its internal mode when the remote function is terminated. It is then executed at the next change of the work process. If the program was terminated or is located on the stack as part of a call sequence, the callback routine is not executed. Use the statement WAIT UNTIL to stop the program execution until certain callback routines or all callback routines have been executed.

Notes




Continue
CALL FUNCTION - STARTING NEW TASK parameter_list
RECEIVE
WAIT UNTIL
Thresholds for Resource Allocation for Asynchronous RFC