ABAP Keyword Documentation → ABAP - Reference → Declarations → Declaration Statements → Data Types and Data Objects → Declaring Data Objects → DATA
DATA - TYPE, LIKE
Other versions: 7.31 | 7.40 | 7.54
Syntax
DATA var { {TYPE [LINE OF] type}
| {LIKE [LINE OF] dobj} }
[VALUE val|{IS INITIAL}]
[READ-ONLY].
Effect
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
, except that:
- For
DATA
, a standard table type with generic primary table key can be specified afterTYPE
. This creates a bound table type with a standard key.
- For
DATA
, a table type can be specified afterTYPE
that is generic with respect to its secondary table key (thanks to the additionWITH FURTHER SECONDARY KEYS
). This type attribute 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.
Note
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. In the statement above, therefore, check whether a table with standard key is created by mistake if using a generic standard table type.
Example
These statements define two data objects, both of which have the same data type as the database table spfli
.
DATA: spfli_wa1 TYPE spfli,
spfli_wa2 LIKE spfli_wa1.