DATA - TYPE, LIKE
Short Reference
ABAP Syntax_2 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 , except
that:
For 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 .
For DATA , a table type can be specified after TYPE that is
generic with respect to its
secondary table key (thanks to the addition
WITH 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.
Latest notes: For internal tables, the declaration of the primary table
key as a standard key can be critical for
various reasons. We recommend that you 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 ABAP Coding 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.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved