ABAP Keyword Documentation → ABAP - Reference → Creating Objects → CREATE DATA
CREATE DATA - TYPE, LIKE
Other versions: 7.31 | 7.40 | 7.54
Syntax
CREATE DATA dref [area_handle]
{ {TYPE [LINE OF] {type|(name)}}
| {LIKE [LINE OF] dobj} }.
Effect
The type of the generated data object is defined by the specified type or data object.
-
typecan be any data type from the ABAP Dictionary, in particular the structure of a database table, a public data type of a global class, or any data type of the same program that has already been defined withTYPESand that is either more specific than or identical to the static type ofdref. Alternatively, you can specify a character-like data objectnamein parentheses which contains the name of the existing data type when the statement is executed. This is not case-sensitive. The name innamecan also be an absolute type name. If a standard table type with a generic primary table key is specified afterTYPE, a new bound table type with standard key is generated and used. -
A data object that is visible at this point can be
specified for
dobj. The generated data object inherits the current data type. Ifdobjis specified as a formal parameter or field symbol, it can be completely or partially generic. When the CREATE DATA statement is executed, a data object must be connected to a generically typed field symbol or parameter. The type of the data object is used. In the case of a completely typed field symbol or parameter, the declared type is used. A data object does not have to be connected.
You can use the optional addition LINE OF if type
or the name in name is a table type, or if dobj
is an internal table. As a result, the generated data object inherits the attributes of the row type of the internal table.
Notes
-
You can use
LIKEto refer to data objects, and also to the public attributes of global classes. -
If, in
name, a type of another program is specified using an absolute type name, this program is loaded into a new additional program group or into the current program group, depending on the program type (if not already loaded).
Example