Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Declarative statemnts →  Data Types and Data Objects →  Declaring Data Types →  TYPES 

TYPES - TYPE, LIKE

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


TYPES dtype { {TYPE [LINE OF] type} 
            | {LIKE [LINE OF] dobj}  }.

Addition

... LINE OF ...

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.

  • type can be a non-generic type from ABAP Dictionary, allowed by the package check, including in particular the structure of a database table, or it can be a public type from a global class allowed by the package check, or a non-generic data type of the same program that has already been defined by TYPES.
  • A data object that is visible at this point can be specified for dobj. If a field symbol or formal parameter is specified for dobj, 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 converted to predefined ABAP types according to the table of predefined types in ABAP Dictionary.


Notes

  • You can use LIKE to refer to data objects, and also to the public attributes of global classes.
  • A data type that is declared by a direct TYPE or LIKE 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 line 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 line type of this table type.

DATA: event_table TYPE cntl_simple_events, 
      event       LIKE LINE OF event_table.