Properties of interface parameters

When an interface parameter p1, p2... is defined in the Function Builder, properties are determined for the parameter, which are reflected in the syntax of parameters and table_parameters.

Syntax of parameters

... { VALUE(p1) | p1 }
         {TYPE [REF TO] type} | {LIKE struc-comp} | {STRUCTURE struc}
         [OPTIONAL|{DEFAULT def1}]
    { VALUE(p2) | p2 }
         {TYPE [REF TO] type} | {LIKE struc-comp} | {STRUCTURE struc}
         [OPTIONAL|{DEFAULT def2}]
    ...

Syntax of table_parameters

... p1  {TYPE itab_type} | {STRUCTURE struc} [OPTIONAL]
    p2  {TYPE itab_type} | {STRUCTURE struc} [OPTIONAL]
    ...

The syntax and semantics of VALUE, TYPE, OPTIONAL, and DEFAULT are mainly the same as in the definition of method interfaces with [CLASS-]METHODS. The option of typing interface parameters with LIKE or STRUCTURE is obsolete.

Type of parameter passing

There are two ways in which parameters can be passed: pass by reference and pass by value. Pass by value is selected in the Function Builder by selecting pass by value, and in the above syntax, differs from pass by reference by the specification of VALUE( ).

Note the following for the different types of parameter:

Typing of interface parameters

The parameter interface of a function module is public across the system. Interface parameters can therefore only be typed with reference to data types from the ABAP Dictionary or from the public visible section of global classes. In the Function Builder, interface parameters can be typed by the selection of either TYPE, TYPE REF TO or LIKE. While typing with TYPE is also displayed as TYPE in the above syntax, typing with LIKE is not only represented by LIKE, but also by STRUCTURE.

Note

If a component of a global program structure in the function group of a function module has exactly the same identity (structure name struc and component comp) as the component of a structure in the ABAP Dictionary specified after LIKE, LIKE refers to the component of the structure defined in the function group. This leads to a warning in a syntax check. In contrast, TYPE always refers to types in the ABAP Dictionary.

Optional parameters

IMPORTING, CHANGING, and TABLES parameters can be made optional by the selection of optional in the Function Builder. EXPORTING parameters are always optional. IMPORTING and CHANGING parameters can be assigned a replacement parameter (default value in the Function Builder). In the above syntax, this is expressed using the additions OPTIONAL or DEFAULT. For an optional parameter, no actual parameter must be entered when the function module is called. While a formal parameter with the addition OPTIONAL is then initialized according to its type, a formal parameter with the addition DEFAULT assumes the value and type of the replacement parameter def1 def2 ....

If no actual parameter is specified for a generically typed formal parameter with the addition OPTIONAL when it is called, the type of the formal parameter is completed according to fixed rules.

Note

Within a function module, the logical expression IS SUPPLIED can be used to check if an optional formal parameter was assigned an actual parameter when it was called.

Global Parameters

The formal parameters of a function module can be made known globally in the Function Builder through the path Edit → Interfaces → Globalize parameters. Then the field Global is selected in the properties of the function module. The formal parameters of a global interface have the following properties:

In the function group, no global data objects with the same name must be created like a global parameter. If several function modules of a function group have global interfaces, parameters with the same name must be defined identically.

Note

The use of global interface parameters is obsolete and, in new function modules, interfaces should generally not be globalized. ________________________________________________________________________