SAP CREATE DATA ITAB ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• TABLE OF CREATE DATA
• STANDARD TABLE CREATE DATA
• SORTED TABLE CREATE DATA
• HASHED TABLE CREATE DATA
• INITIAL SIZE CREATE DATA
• WITH UNIQUE KEY CREATE DATA
• WITH NON-UNIQUE KEY CREATE DATA
• WITH EMPTY KEY CREATE DATA
• DEFAULT KEY CREATE DATA

CREATE DATA, TABLE OF
Short Reference

ABAP_SYNTAX
CREATE DATA dref $[ area_handle$]
${ ${TYPE $[STANDARD$]$|SORTED$|HASHED TABLE OF $[REF TO$] ${type$|(name)$}$}
$| ${LIKE $[STANDARD$]$|SORTED$|HASHED TABLE OF dobj$} $}
$[ WITH ${ ${$[UNIQUE$|NON-UNIQUE$]
${KEY ${comp1 comp2 ...$}$|(keytab)$}$| ${DEFAULT KEY$}$}$}
$| ${EMPTY KEY$} $]
$[INITIAL SIZE n$].

What does it do?
The statement CREATE DATA uses the addition tabkind OF to create an internal table. The meaning of the additions is the same as when declaring internal tables using the statement DATA, but with special rules for CREATE DATA if dobj is specified after LIKE. The explicit definition of the primary table key is only optional if a standard table is created.
Whereas for DATA all specifications must be static, the following dynamic specifications are possible for CREATE DATA:
The line type after TYPE or the static type of a line flagged as a reference variable after TYPE REF TO can be specified as the content of a character-like data object called name, whereby the same rules apply as in the other variants of CREATE DATA.
For the definition of the primary table key a parenthesized internal table keytab can be specified instead of a static component comp1 comp2 ...:
... WITH $[UNIQUE$|NON-UNIQUE$] KEY (keytab) ...
The table keytab must have a character-like data type and, when the statement is executed, it must contain the name of a valid component in each line or the identifier table_line for the primary table key in a single line.
A numeric data object can be specified for n after INITIAL SIZE.



Latest notes:

The following restrictions apply to the definition of the table key, unlike to DATA:
No secondary table keys can be defined in the statement CREATE DATA.
The name primary_key and the addition COMPONENTS cannot be specified explicitly in the definition of the primary key. Runtime type creation should be used instead to create dynamic table types with secondary keys. The same applies to the dynamic creation of an empty table key, since the internal table keytab can only be used to define non-empty keys.
CREATE DATA cannot be used to create internal tables with header lines.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Creation and use of an anonymous hashed table.
ABEXA 00160
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
Creating Tabular Data Objects
ABAP_EXAMPLE_END

Return to menu