SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Declarations → Typing → typing Addition →typing Addition - generic_type
Syntax
... { TYPE generic_type }
| { LIKE <generic_fs>|generic_para } ...
Effect
To generically type a formal parameter or a field symbol,
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 this typing. However, operands that expect particular internal tables are an exception to this rule. Here, only formal parameters or field symbols with the requisite internal table type are allowed.
The type attributes specified by the typing are used in static access to a generically typed formal parameter or field symbol. In dynamic access, the attributes of the actual parameter or memory area assigned apply.
If an actual parameter is not specified 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 formal parameter is typed with a standard type in accordance with the following rules:
If a replacement parameter is specified, then the type attributes of this parameter are applied.
Note
When typing formal parameters, the addition LIKE can be used to refer to formal parameters (in the same procedure) that have already been declared.
Example
In the following example, two generically typed field symbols are used in LOOP statement. To avoid syntax errors, <any_table> must be defined as an internal table. However, the system does not check the type of <any_object> until runtime, to ensure that the type of the data object assigned to it is compatible with the row type of the table.
FIELD-SYMBOLS: <any_object> TYPE ANY,
<any_table> TYPE ANY TABLE.
...
LOOP AT <any_table> INTO <any_object>.
...
ENDLOOP.