ABAP Keyword Documentation → ABAP - Reference → Declarations → Declaration Statements → Data Types and Data Objects → Types and Objects - Overview
Absolute Type Names
The type name that can be used statically in ABAP statements is relative to its context, and is also known as the relative type name. As described in Validity and Visibility, local data types hide more global data types of the same name. The same applies to classes and interfaces, which can also be interpreted as type definitions in this regard.
Absolute type names, however, name a type uniquely. An absolute type name as a specified path is composed of the following components:
- \TYPE=name
- \CLASS=name
- \INTERFACE=name
- \PROGRAM=name
- \CLASS-POOL=name
- \FUNCTION-POOL=name
- \TYPE-POOL=name
- \METHOD=name
- \FORM=name
- \FUNCTION=name
The last component of a path must always be \TYPE=name, \CLASS=name, or \INTERFACE=name. It describes a data type, a class, or an interface. The name must be entered in uppercase letters. Absolute type names that only consist of \TYPE=name, \CLASS=name, or \INTERFACE=name describe a data type from ABAP Dictionary or a global class/interface of the class library. To create absolute type names for local data types, classes, and interfaces, use sequential component names that specify its context as prefixes.
Absolute type names can be used in all statements in which a data type, a class, or an interface can be specified dynamically. This makes it possible to stop a local type from obscuring a global type by specifying an absolute type name, and the absolute type names can be used to access the types, classes, and interfaces of other programs dynamically. It is possible to load a different program into the current internal session if this is necessary to access the program.
A data type is uniquely identified by its absolute type name. Various options exist, however, for forming an unique path for a type. For example, the function group can be omitted for a type in a function module, because every function module is unique. If types are located in a class pool or function group, the technical name name of the ABAP program can also be specified. Since the latter is not known most of the time, we recommend using \CLASS-POOL or \FUNCTION-POOL instead.
A data type that only exists as a property of a data object does not have a relative type name. However, internally it has an absolute type name (technical type name) that uniquely defines the data type.
Other versions: 7.31 | 7.40 | 7.54
Notes
- The type description classes of the Run Time Type Services (RTTS), such as CL_ABAP_TYPEDESCR, contain methods that return the absolute type name of data types or data objects.
- If in a program an absolute type name is used to specify a type of a different program, then this program is added to a new
additional program group or to the current
program group, if not
already loaded. The program constructor
LOAD-OF-PROGRAM
is not yet executed.
Example
When the methods m1
and m2
of the class
c1 are called in the following example, the RTTS get the absolute type names \TYPE=SPFLI
or \PROGRAM=RTTI_TEST\CLASS=C1\METHOD=M2\TYPE=SPFLI for the generically
typed parameter p
. The use of the name spfli
has
different meanings in the methods m1
and m2
. A syntax check warning provides a reminder of this.
PUBLIC SECTION.
METHODS: m1,
m2,
m3 IMPORTING p TYPE any.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD m1.
DATA struc TYPE spfli.
m3( struc ).
ENDMETHOD.
METHOD m2.
TYPES spfli TYPE spfli.
DATA struc TYPE spfli.
m3( struc ).
ENDMETHOD.
METHOD m3.
DATA type_descr TYPE REF TO cl_abap_typedescr.
type_descr = cl_abap_typedescr=>describe_by_data( p ).
WRITE / type_descr->absolute_name.
ENDMETHOD.
ENDCLASS.