SAP DATA REFERRING ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• LINE OF CONSTANTS
• LINE OF STATICS
• LINE OF CLASS-DATA
• LINE OF DATA

DATA, TYPE, LIKE
Short Reference

ABAP_SYNTAX
DATA var ${ ${TYPE $[LINE OF$] type$}
$| ${LIKE $[LINE OF$] dobj$} $}
$[VALUE val$|${IS INITIAL$}$]
$[READ-ONLY$].

What does it do?
When a type data type or a dobj data object is specified, the data type of variable var is already fully defined before the declaration. The syntax and meaning of the additions TYPE and LIKE are exactly the same as the definition of the data types with TYPES, with the following exceptions:
In the case of DATA, a standard table type with generic primary table key can be specified after TYPE. This creates a bound table type with a standard key.
In the case of DATA, a table type can be specified after TYPE that is generic with respect to its secondary table key because of the explicit addition WITH FURTHER SECONDARY KEYS. This type property is not relevant for the declared data object.
If neither TYPE nor LIKE is specified, a data object with the bound data type c of length 1 is created.



Latest notes:

For internal tables, the declaration of the primary table key as a standard key can be critical for various reasons. It is best to define the key fields explicitly instead. For this reason, in the case of the statement above, it must be ensured that a table with a standard key is not created by mistake if a generic standard table type is used.
If an enumerated type is specified after TYPE or a data object with this type is specified after LIKE, an enumerated variable is created.
When referring to data types defined in the ABAP Dictionary, the initial value of elementary data types is not the initial value assigned to the built-in dictionary types and is the initial value of the mapped built-in ABAP types instead.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Use of the TYPE addition to declare a work area for a SELECT statement. Use of the LIKE addition to declare a further data object of the same type.
ABEXA 00184
ABAP_EXAMPLE_END

Return to menu