Thursday, April 10, 2008

CALL FUNCTION SYNTAX FOR SAP ABAP extended

Variant 5

CALL FUNCTION func IN BACKGROUND TASK.

Additions

1. ... DESTINATION dest
2. ... EXPORTING p1 = f1 ... pn = fn
3. ... TABLES p1 = itab1 ... pn = itabn

Effect

Flags the function module func to be run asynchronously. It is not executed at once, but the data passed with EXPORTING bzw. TABLES is placed in a database table and the next COMMIT WORK then executes the function module in another work process.

Note

This variant applies only from R/3 Release 3.0. Both partner systems (the client and the server systems) must have a Release 3.0 version of the R/3 System.

Addition 1

... DESTINATION dest

Effect

Executes the function module externally as a Remote Function Call ( RFC ); dest can be a literal or a variable.
Depending on the specified destination, the function module is executed either in another R/3 System or as a C-implemented function module. Externally callable function modules must be flagged as such in the function library (of the target system).
Since each destination defines its own program context, further calls to the same or different function modules with the same destination can access the local memory (global data) of these function modules.

Addition 2

... EXPORTING p1 = f1 ... pn = fn

Effect

EXPORTING passes values of fields and field strings from the calling program to the function module. In the function module, the formal parameters are defined as import parameters. Default values must be assigned to all import parameters of the function module in the interface definition.

Addition 3

... TABLES p1 = itab1 ... pn = itabn

Effect

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

Notes


If several function module calls with the same destination are specified before COMMIT WORK , these form an LUW in the target system.
Type 2 destinations (R/3 - R/2 connections) cannot be specified.



CALL FUNCTION

Variant 4

CALL FUNCTION func DESTINATION dest.

Additions




1. The same as with CALL FUNCTION func
2. ... EXCEPTIONS syst_except = rc MESSAGE mess

Effect

Executes the function module externally as a Remote Function Call ( RFC ); dest can be a literal or a variable.
Depending on the specified destination, the function module is executed in another R/3 or R/2 System. Externally callable function modules must be flagged as such in the function library (of the target system).
Since each destination defines its own program context, further calls to the same or different function modules with the same destination can access the local memory (global data) of these function modules.

You can maintain existing destinations by selecting Tools -> Administration -> Administration -> Network -> RFC .

Notes

Special destinations:

  • The destination NONE refers to the calling system. Function modules called with

    CALL FUNCTION func DESTINATION 'NONE' ...

    are executed in the system of the calling program, but in their own program context.
  • You can use the destination BACK if the current program was already called by RFC . The, BACK refers back to the calling program:

    CALL FUNCTION func DESTINATION 'BACK' ...

    If the program is not called from a "remote" source, the exception COMMUNICATION_FAILURE is triggered.
Each R/3 System has a standard name. This is formed from the host name (e.g. SY-HOST ), the system name ( SY-SYSID ) and the system nummer (two-character
  • number assigned on installation of the applications server).
    You can use this name as a destination. For example, you can call the function module func in the system C11 on the host sapxyz with system number 00 as follows:

    CALL FUNCTION func DESTINATION 'sapxyz_C11_00' ...
  • You can also use saprouter path names as destinations (see also saprouter documentation).

Note

Parameter passing. When you pass data to an externally called function module, there are some differences to the normal function module call:

  • With table parameters, only the table itself is passed, not the header line.
  • If one of the parameters of the interface of an externally called function module is not specified when called, the import parameters are set to their initial value. If no default value was given in the interface definition, TABLES parameters are defined as an empty table and unspecified export parameters are lost.

Note

Passing structured data objects. Since transport to another system may require data conversion, the structure of field strings and internal tables must be known to the runtime system when the call is made. The structure of a field string or internal table is not known if it was defined with

... LIKE structure ,

if the structure passed was passed to the subroutine with the explicit addition STRUCTURE , or if it is a parameter of a function module.

In these cases, external calls can result in a conversion error.

Note

C interface. You can call externally callable function modules from C programs. It is also possible to store function modules in a C program and call them via CALL FUNCTION ... DESTINATION . For this purpose, SAP provides a C interface .

Addition 2

... EXCEPTIONS syst_except = rc MESSAGE mess

Effect

Function module calls with the addition DESTINATION can handle two special system exceptions:
SYSTEM_FAILURE

This is triggered if a system crash occurs on the receiving

side.
COMMUNICATION_FAILURE

This is triggered if there is a connection or communication problem.
In both cases, you can use the optional addition

... MESSAGE mess

to receive a description of the error.

Note

Runtime errors

  • CALL_FUNCTION_DEST_TYPE :Destination type not allowed.
  • CALL_FUNCTION_NO_DEST :Destination does not exist.
  • CALL_FUNCTION_NO_LB_DEST :Destination (in 'Load Balancing' mode) does not exist.
  • CALL_FUNCTION_TABINFO :Data error (info internal table) during 'Remote Function Call'

No comments:

Blog Archive