Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Declarations →  Declaration Statements →  Data Types and Data Objects →  Declaring Data Types →  TYPES 

TYPES - TYPE, LIKE

Quick 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.

  • The following can be specified for type:
  • 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 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 transformed to built-in ABAP types in accordance with the tables of built-in types in ABAP Dictionary.


Notes

  • A data type defined using a TYPE reference to a different data type is a copy of this data type (possibly in a different context and with a different name). If the original type is defined in ABAP Dictionary, its semantic attributes are preserved.

  • LIKE can be used to reference 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.
  • A data type, which is declared by a TYPE or LIKE reference to an enumerated type, has exactly the same meaning as the enumerated type itself. The value set defined for the enumerated type is not duplicated.

Example

Defines a local type my_scarr with the attributes of the dictionary type SCARR-CARRID. The field help and input help for the parameter para exist on the selection screen.

TYPES my_carrid TYPE scarr-carrid. 

PARAMETERS para TYPE my_carrid. 

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.