TYPES - TYPE, LIKE

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 the ABAP Dictionary, to which in particular the structure of a database table also belongs, or it can be a public type of a global class or a non-generic data type of the same program that has already been defined by TYPES. dobj can be a data object visible at this point that has already been declared. Within a procedure, generically typed formal parameters cannot be specified for dobj.

If a reference is made to a data type in the ABAP Dictionary, its primary components are converted to predefined ABAP types according to the table of predefined types in the ABAP Dictionary.

Note

The data objects that you can reference with LIKE include the public attributes of global classes, as well as the data objects of the program itself.

Addition

... LINE OF ...

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 copies a table type from a type group of the ABAP Dictionary, and the second corresponds to the line type of this table type.

TYPE-POOLS cntl.

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