ABAP Keyword Documentation → ABAP − Reference → Declarations
Typing
Typing means defining a generic or complete data type for a formal parameter of a procedure or for a field symbol. When an actual parameter is assigned to a formal parameter, or a data object to a field symbol, a check is carried out to make sure the data type matches the typing.
Other versions: 7.31 | 7.40 | 7.54
Generically Typed
Unlike data objects, where the data type has a specific property and is always identified in full, formal
parameters and field symbols that are generically typed receive their complete data type only when an
actual parameter is passed in a procedure call or when a memory area is assigned using ASSIGN
.
When using generically typed formal parameters or field symbols, a difference is made between static and dynamic access.
- In static access to a generically typed formal parameter, field symbol, or their components, the type attributes specified by the typing of the formal parameter are used. In static accesses where a complete data type is required, a standard type is used if possible.
- In static access to a generically typed formal parameter, field symbol ,or their components, the type attributes of the actual parameter are used.
The attributes of the actual parameter, which are not checked in calls or assignments, can be different from those of the formal parameter. This can produce different behavior in static and dynamic accesses. A dynamic access to components of generically typed formal parameters will result in a runtime error, if the components are not available in the actual parameter.
Fully Typed
During compilation and at runtime, formal parameters and field symbols that are completely typed are treated in the same way as data objects with completely known data types.
During the use of completely typed formal parameters, or field symbols, the attributes specified by the typing are used, regardless of whether they are accessed statically or dynamically.
Notes
- The typing of formal parameters or field symbols defines some or all of the type attributes before the actual specification of the type. This permits the use of formal parameters and field symbols in operand positions that require certain type attributes.
- If the typing of an existing field symbol or formal parameter is made weaker, note that there may then be fewer options for static accesses and that the associated standard type may change if they are used in inline declarations.
- The static type of data reference variables is always completely generic
(
data
) or completely typed (seeDATA
- reference variables).
- An obsolete table parameter can be typed in full or typed generically with respect to the table key and the same rules apply as to other formal parameters.
Programming Guideline
Be as specific as possible when typing formal parameters
Executable Example
Generic Typing and Full Typing