ABAP Keyword Documentation → ABAP − Reference → Declarations → Declaration Statements → Data Types and Data Objects → Declaring Data Types
TYPES
Other versions: 7.31 | 7.40 | 7.54
Syntax Forms
Using Built-In Types
1. TYPES { {dtype[(len)] TYPE abap_type [DECIMALS dec]}
| {dtype TYPE abap_type [LENGTH len] [DECIMALS dec]}}.
Reference to Existing Types
2. TYPES dtype { {TYPE [LINE OF] type}
| {LIKE [LINE OF] dobj} }.
Reference Types
3. TYPES ref_type { {TYPE REF TO type}
| {LIKE REF TO dobj} }.
Structured Types
4. TYPES BEGIN OF struc_type.
...
TYPES comp ...
TYPES comp TYPE struc_type BOXED.
INCLUDE {TYPE|STRUCTURE} ...
...
TYPES END OF struc_type.
Enumerated Types
5. TYPES BEGIN OF ENUM enum_type
[STRUCTURE struc]
[BASE TYPE dtype].
TYPES val1 [VALUE IS INITIAL],
TYPES val2 [VALUE val],
TYPES val3 [VALUE val],
...
TYPES END OF ENUM enum_type
[STRUCTURE struc].
Mesh Types
6. TYPES BEGIN OF MESH mesh_type.
...
TYPES node TYPE [REF TO] table_type
associations ...
TYPES END OF MESH mesh_type.
Table Types
7. TYPES table_type { {TYPE
tabkind OF [REF TO] type}
| {LIKE tabkind OF dobj} }
[tabkeys][INITIAL SIZE n].
Ranges Table Types
8. TYPES dtype {TYPE RANGE OF type}|{LIKE RANGE OF dobj}
[INITIAL SIZE n].
LOB Handle Structures
9. TYPES dtype TYPE dbtab|view
lob_handle_type FOR lob_handle_columns
[
lob_handle_type FOR lob_handle_columns
...
].
Effect
The statement TYPES
defines a standalone data type.
Naming conventions apply to the names. The defined data type can be viewed within the current context from this position.
The syntax makes it possible to define elementary data types, reference types, structured types, table types, and mesh types. As well as the types that are completely self-constructed, special types such as ranges table types or LOB handle structures can be derived from existing types.
For the definition of a structured type struc_type
, any type definitions
of two TYPES
statements are enclosed by using the additions BEGIN
OF and END OF
. Here, a structured data type struc_type
is defined that contains the enclosed data types as components struc_type-...
. Structure definitions can be nested. A mesh type is a special structure type whose components are tabular nodes for which mesh
associations can be defined.
Notes
-
Outside classes,
LIKE
can also be used for an obsolete type reference. -
An obsolete addition
CLIENT SPECIFIED
declares a special type for target areas for ABAP SQL queries in which implicit client handling is disabled.
Continue
TYPES - BEGIN OF ENUM enum_type