Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Declarations →  Typing →  Checking Typing 

General Rules for Typing

The general rules for checking apply strictly to the following:

The general rules for checking the typing are:

  • If the assignment is made to generically typed field symbols or field parameters, the system checks whether the technical type attributes of the assigned data object are a subset of the generic type. The type attributes that are not defined by typing are applied to the actual parameter.
  • In assignments to fully typed field symbols or formal parameters, the technical properties of the data type of the assigned data object must correspond exactly to the typing. If the assignment is made to field symbols or formal parameters typed with enumerated types, the type of the assigned data object must be exactly the same enumerated type as is used for the typing.
  • The result of the typing check when actual parameters are passed to formal parameters is independent of the passing type used. In a pass by value, the check for pass by reference is always carried out, even though this is stricter than necessary in individual cases.
  • If reference variables are passed, up casts are possible but down casts are not. If actual parameters are passed to input parameters typed as reference variables, an up cast is only possible if there is no change of content within the procedure. When a subroutine is passed to the parameters, an up cast is not possible.
  • If memory areas are assigned to field symbols typed as reference variables, the typing of the field symbol and the static type of the memory area must be the same.
  • If the assignment is made to generically and fully typed field symbols or formal parameters, only the technical type attributes are checked. The following are not checked:
  • Semantic properties of data types defined in the ABAP Dictionary (conversion routines, documentation, and so on)
  • Initial memory requirement of internal tables
If generally typed formal parameters or field symbols are accessed dynamically, these attributes are applied to the type of the actual parameter. If generically typed formal parameters or field symbols are accessed statically, these attributes are applied to the typing of the formal parameter.
  • When assigning to field symbols or formal parameters for which a structure is defined with the obsolete STRUCTURE addition are called in Unicode programs, elementary data structures must be character type and flat and for structures the fragment views must match. The assigned data object must be at least as long as the structure.

Other versions: 7.31 | 7.40 | 7.54


Notes

  • In the case of generically typed field symbols or formal parameters, and in the case of formal parameters of function modules and externally called subroutines, the typing is checked first at the time of the assignment - that is, at runtime. In the case of fully typed field symbols and formal parameters of methods and internally called subroutines, the check is performed as part of the syntax check.

  • The constructor operators CONV and CAST are well suited to converting or casting invalid actual parameters to the type of a formal parameter.