ABAP Keyword Documentation → ABAP - Dictionary → Classic Objects in ABAP Dictionary
Data Types
Global data types can be defined in the ABAP Dictionary. These data types are visible for all repository objects of the current AS ABAP and can be used there (as long as the package concept allows it).
The possible data types in ABAP Dictionary are:
- Data elements for elementary data types and reference types
- Structures that can comprise any other number of data types.
- Table types with any row type
In ABAP programs, the TYPE
addition of declarative statements can be used
to reference the data types in ABAP Dictionary. Here, data elements work like elementary ABAP types,
structures work like structured ABAP types, and table types work like the corresponding ABAP types. The elementary components of each data type in ABAP Dictionary are based on a set of
built-in types in ABAP Dictionary for which a
mapping to the
built-in ABAP types is defined. If a data type is changed in ABAP Dictionary, all consumers are modified automatically.
The name of a data type
- can have a maximum of 30 characters,
- can consist of letters, numbers, and underscores,
- must start with a letter,
- can be introduced using a namespace prefix (/.../) of a prefix namespace
- is in the same namespace as the global classes and interfaces of the class library.
- must not be the name of a built-in data type in ABAP.
All types created in ABAP Dictionary, including database tables and views, are in a namespace of the global data types and object types that covers the entire current AS ABAP. Domains, on the other hand, are in a separate namespace, which enables them to have the same name as, for example, a data element.
Alongside its technical attributes, a data type in ABAP Dictionary can have semantic information, such as documentation texts, texts for use on UIs, or associations with search helps. Data types without semantic attributes can also be declared in groups known as type groups.
Other versions:
7.31 | 7.40 | 7.54
Notes
- In addition to the classic data types of the ABAP Dictionary, the CDS entities of ABAP Dictionary also display data types, which can be used as such in ABAP programs.
- As well as in ABAP Dictionary, global type declarations are also possible in classes and interfaces. Data types should always be created in a context that meets the requirements in question, while also encapsulating as much as possible. See also the associated programming guidelines.
- A data type in ABAP Dictionary should always be used in accordance with its semantic attributes. Elementary data types in ABAP Dictionary in particular should never be selected only on the basis of their technical attributes. See also the associated programming guidelines.
- Namespace prefixes can be used to prevent namespace conflicts.
- Within a program, locally defined types obscure global types from ABAP Dictionary with the same name.
Example
A data type defined in ABAP Dictionary, such as the structure DEMO_CONN, can be referenced in the parameter interfaces of global procedures (methods or function modules) and in the ABAP programs that use the procedures.
CLASS cl_demo_class DEFINITION.
PUBLIC SECTION.
CLASS-METHODS demo_meth
IMPORTING
para TYPE demo_conn .
ENDCLASS.
DATA structure TYPE demo_conn.
START-OF-SELECTION.
cl_demo_class=>demo_meth( structure ).
CLASS cl_demo_class IMPLEMENTATION.
METHOD demo_meth.
...
ENDMETHOD.
ENDCLASS.
Example
The elementary components of the structure SYST describe the ABAP system fields. The semantic attributes of these components or the data elements used for them are designed for system fields used internally in programs. It is not recommended that these components or their data elements are used for other purposes, such as dynpro fields or Web Dynpro fields, just because their technical attributes are right. Their semantic attributes, in particular their text descriptions and documentation, are not usually suitable for UIs. If there are no types with suitable semantic attributes that can be reused, new data types must be created.