SAP® Documentation

Single view

ABAPCREATE_DATA_ITAB - CREATE DATA ITAB

rdisp/max_wprun_time - Maximum work process run time   BAL Application Log Documentation  
This documentation is copyright by SAP AG.
SAP E-Book

CREATE DATA - TABLE OF

Short Reference



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$].

Effect

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 being created.

Whereas the content of DATA is specified statically, the following can be specified dynamically for CREATE DATA:

  • The row type after TYPE or the static type of a row flagged as a reference variable after TYPE REF TO can have a character-like data object called name. In this case, the same rules apply as in the other variants of CREATE DATA.

  • The definition of the primary table key can specify a parenthesized internal table keytab instead of a static component comp1 comp2 ...:


    ... WITH $[UNIQUE$|NON-UNIQUE$] KEY (keytab) ...


    The table keytab must have a character-like data type and must contain the name of a valid component in each row or the identifier table_line for the primary table key in a single row.

  • A numeric data object can be specified for n after INITIAL SIZE.

Notes

  • The definition of the table key is subject to the following conditions that do not apply to 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 when creating an empty table key dynamically, 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.


Example

Creates and uses an anonymous hash table. The type of the data reference variable is generic, which means it can only be dereferenced in the case of assignment to a field symbol.

DATA dref TYPE REF TO data.

FIELD-SYMBOLS <fs> TYPE ANY TABLE.

CREATE DATA dref TYPE HASHED TABLE OF scarr
                 WITH UNIQUE KEY carrid.
ASSIGN dref->* TO <fs>.

SELECT *
       FROM scarr
       INTO TABLE @<fs>.

cl_demo_output=>display( <fs> ).

Creating Tabular Data Objects








BAL_S_LOG - Application Log: Log header data   BAL Application Log Documentation  
This documentation is copyright by SAP AG.

Length: 6128 Date: 20191215 Time: 222812     sap01-206 ( 30 ms )

Our Service

Looking for Support? Questions?

The

Consolut

Callback-Service

Leave us your contact details and we will call you back. Panels marked with * are mandatory.