SAP TYPES REFERRING ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• TYPE type TYPES
• LIKE dobj TYPES

TYPES, TYPE, LIKE
Short Reference

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

ABAP Addition
... LINE OF ...

What does it do?
By specifying a data type type or a data object dobj, dtype inherits all properties of the specified data type or data object.
The following can be specified for type:
A non-generic data type from the ABAP Dictionary or ABAP CDS allowed by the package check, particularly including the structure of a DDIC database table
BEGIN_SECTION VERSION 5 OUT , of a DDIC view
END_SECTION VERSION 5 OUT , a CDS entity (a CDS view, CDS table function, or CDS hierarchy), or a CDS type ( CDS simple type).
A non-generic 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, this must be completely typed. The declared type is inherited. No data object must be bound when the statement is evaluated.
If a reference is made to a data type in the ABAP Dictionary, its elementary components are transformed to built-in ABAP types in accordance with the tables of built-in types in the ABAP Dictionary.



Latest notes:

A data type that is defined by a TYPE reference to another 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 the ABAP Dictionary or is a CDS simple type, its semantic properties are preserved.
The data objects that can be referred to with LIKE also include the public attributes of global classes.
A data type that is declared by a direct TYPE or LIKE reference to a boxed component inherits its data type but is not a boxed component.
A data type that 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.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX
Definition of a local type my_scarr with the properties of the dictionary type SCARR-CARRID. The field help and input help are available for the parameter para on the selection screen.
ABEXA 00737
ABAP_EXAMPLE_END

ABAP_EXAMPLE_V5
Definition of a local type also_my_struct_type based on the type my_struct_type using LIKE.
ABEXA 01696
ABAP_EXAMPLE_END
• LINE OF TYPES

ABAP Addition

What does it do?
The optional addition LINE OF can be used if type is a table type or if dobj is an internal table. This means that dtype inherits the properties of the line type of the internal table.

ABAP_EXAMPLE_VX5
These TYPES statements define two data types local to the program. The first inherits a table type from a type pool of the ABAP Dictionary, and the second corresponds to the line type of this table type.
ABEXA 00738
ABAP_EXAMPLE_END

Return to menu