ABAP Keyword Documentation → ABAP - Reference → Data Interfaces and Communication Interfaces → RFC - Remote Function Call → CALL FUNCTION - RFC
CALL FUNCTION - STARTING NEW TASK
Other versions: 7.31 | 7.40 | 7.54
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. 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 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 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
More information about aRFC can be found in the
SAP NetWeaver documentation in SAP Help Portal.
Notes
- When dynpros are called in aRFC processing, additional ABAP sessions are opened in the RFC client. The maximum of six ABAP sessions cannot be exceeded; if there are more, an error message is displayed.
- Asynchronous RFC triggers a database commit in the calling program. An sRFC in updates is an exception to this.
-
If multiple asynchronous RFCs with various destinations are removed in succession in a calling program,
this triggers automatically the parallel processing of the function modules called. Since the relevant
management can cause resource bottlenecks on both the client and the server, this kind of parallel processing is only recommended using the addition
DESTINATION IN GROUP. -
Calls using
STARTING NEW TASKare always executed using the RFC interface and a destination specified asdestis always interpreted accordingly. This is why, unlike in synchronous RFC, initial string or text fields containing only blanks cannot be specified fordest.
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
-
The parallel processing of function modules with the addition
IN GROUPmakes optimal use of the available resources and is preferable to self-programmed parallel processing with explicitly specified destinations. - An application server that is used as part of an RFC server group for parallel processing must have at least three dialog work processes, of which one is currently free. Other resources, such as requests in the queue, the number of system messages and so on, are also respected and must not exceed certain threshold values.
-
To ensure that only those application servers that have enough resources are accessed, it is preferable
work with explicitly defined RFC server groups instead of working with the addition
DEFAULT. -
The function modules of the function group SPBT provide service functions for parallel processing, for
example, initialization of RFC server groups, determining the used destination, or temporarily removing an application server from an RFC server group.
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 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 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 session 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. The statement WAIT FOR ASYNCHRONOUS TASKS can be used to stop the program execution until certain or all callback routines have been executed.
Notes
-
If no
RECEIVEstatement is executed in the callback routine to receive the result of the remote function, the connection remains intact and implicitly behaves like the statementRECEIVEwith the additionKEEPING TASK. This implicit behavior is generally not desired. -
It is recommended that the time of execution of the callback routine is programmed using
WAIT FOR ASYNCHRONOUS TASKS. This statement produces an explicitly requested change in the work process and offers further control options. Only in exceptional cases should callback routines be executed for implicit changes to the work process, for example at the end of a dialog step.