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 Predefined 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.
Table Types
5. TYPES table_type { {TYPE
tabkind OF [REF TO] type}
| {LIKE tabkind OF dobj} }
[tabkeys][INITIAL SIZE n].
Ranges Table Types
6. TYPES dtype {TYPE RANGE OF type}|{LIKE RANGE OF dobj}
[INITIAL SIZE n].
Client Field for CDS Views
7. TYPES dtype TYPE cds_entitiy CLIENT SPECIFIED clnt.
Mesh Types
8. TYPES BEGIN OF MESH mesh_type.
...
TYPES node TYPE [REF TO] table_type
associations ...
TYPES END OF MESH mesh_type.
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 included with the additions BEGIN
OF and END OF
; a structured data type struc_type
is defined here, which contains the included 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 associations can be defined.
Note
Outside classes, LIKE
can also be used for an obsolete type reference.