ABAP Keyword Documentation → ABAP - Reference → Declarations → Declaration Statements → Data Types and Data Objects → Declaring Data Types → TYPES
TYPES - TYPE, LIKE
Other versions: 7.31 | 7.40 | 7.54
Syntax
TYPES dtype { {TYPE [LINE OF] type}
| {LIKE [LINE OF] dobj} }.
Addition
Effect
If a data type type
or a data object dobj
is specified, dtype
assumes all the properties of the specified data type or data object.
-
The following can be specified for
type
:
- a non-generic data type from ABAP Dictionary allowed by the package check (particularly the structure of a database table, of a classic view or of a CDS entity of a CDS view,
- a public type of a global class allowed by the package check,
- a non-generic data type of the same program defined previously using
TYPES
-
A data object that is visible at this point can be
specified for
dobj
. If a field symbol or formal parameter is specified fordobj
, the symbol or parameter must be fully typed. The declared type is inherited. The evaluation of the statement does not require a data object to be bound.
If a reference is made to a data type in ABAP Dictionary, its primary components are transformed to predefined ABAP types in accordance with the tables of predefined types in ABAP Dictionary.
Notes
-
LIKE
can be used to refer to data objects, and also to the public attributes of global classes. -
A data type that is declared by a direct
TYPE
orLIKE
reference to a boxed component is assigned its data type but is not a boxed component.
Addition
... LINE OF ...
Effect
The optional addition LINE OF
can be used if type
is a table type or if dobj
is an internal table. If this addition is used, dtype
inherits the properties of the row type of the internal table.
Example
These TYPES
statements define two data types local to the program. The first assumes a table type from a
type group of ABAP Dictionary, and the second corresponds to the row type of this table type.
DATA: event_table TYPE cntl_simple_events,
event LIKE LINE OF event_table.