Typing Addition - generic_type

Syntax

... TYPE generic_type ...

Effect

Any formal parameter or field symbol can be assigned a generic type by using the specification generic_type after the TYPE addition. When an actual parameter or memory area is assigned to a generically-typed formal parameter or field symbol, the system checks whether the specified data type is a subset of the generic type.

The formal parameter or field symbol can be used as operands anywhere that is not excluded by its type. However, operands that expect particular internal tables form an exception to this rule. Here, only formal parameters or field symbols with the requisite internal table type are allowed.

If you do not specify an actual parameter for a generically-typed optional formal parameter of a method or a function module when calling the procedure and no replacement parameter is defined in the procedure, the type of the formal parameter is completed according to the following rules:

Note

The completion of generic table types is only defined as of Release 6.40.

Example

In the following example, two generically-typed fields symbols are used in a LOOP statement. To avoid syntax errors, <any_table> must be defined as an internal table. However, the system does not check the type of until runtime, to ensure that the type of the data object assigned to it is compatible with the line type of the table.

FIELD-SYMBOLS: TYPE ANY,
                 TYPE ANY TABLE.

...

LOOP AT INTO .
  ...
ENDLOOP.