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 obscure 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 path specifications 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 whose name 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 the 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 dynamic specification of a data type, a class, or an interface is possible. 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. Only the names of compilation units can be used for programs after \PROGRAM. It is not possible to use the names of include programs, since they cannot be generated and loaded as standalone programs.
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, you can omit the function group 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 an absolute type name is used in a program to specify a type of a different program, 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 reminds you 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 ).
cl_demo_output=>write( type_descr->absolute_name ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA(ref) = new c1( ).
ref->m1( ).
ref->m2( ).
cl_demo_output=>display( ).