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

CALL FUNCTION - STARTING NEW TASK

Quick 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.

Additions

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. The addition DESTINATION is used 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 in a callback routine using the addition KEEPING TASK of the statement RECEIVE, 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 32 digits for the remotely called function module. This task ID is passed to the callback routines to identify the function. Each task ID defines a separate RFC connection with a dedicated RFC session.

If a callback routine is specified, it must be ended before another function module is called with the same task ID and destination. If not, the call raises an exception.

More Information

More information about aRFC can be found in the

RFC documentation on SAP Help Portal.

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 objects 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. The first asynchronous RFC using the addition IN GROUP initializes the specified RFC server group. 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

This addition is used to specify either a method meth or a subroutine subr as the callback routine registered to be executed after terminating the asynchronously called function module. The same information can be specified for meth as for the general method call, in particular 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 must 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 a registered callback routine is that the calling program still exists in its internal session when the remote function is terminated. It is then executed here at the next change of the work process in a roll-in. If the program was terminated or is located on the stack as part of a call sequence, the callback routine is not executed.

If multiple callback routines are registered during a program section, they are executed in an undefined order when the work process changes in a roll-in. The statement WAIT FOR ASYNCHRONOUS TASKS can be used to stop the program execution until certain or all callback routines have been executed.

Notes



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