CREATE DATA dref
{ {TYPE tabkind OF [REF TO] {type|(name)}}
| {LIKE tabkind OF dobj} }
[WITH key]
[INITIAL SIZE n].
The addition tabkind OF causes the CREATE DATA statement to generate an internal table. The additions have the same meanings as in the declaration of internal tables with the DATA statement. In particular, the explicit definition of the table key is only optional when you generate a standard table.
Whereas all the specifications for DATA have to be static, you can use the following dynamic specifications for CREATE DATA:
Table keytab must have a character-type data type and must contain the name of a valid component in each row or the identifier table_line for the table key in a single row.
Generation of an internal table for any database table and import of the first
rows of that database table into the internal table. Since the data reference
dref has a dynamic type, you have to use the field symbol
PARAMETERS: dbtab TYPE c LENGTH 10,
rows TYPE i DEFAULT 100.
DATA dref TYPE REF TO data.
FIELD-SYMBOLS: TYPE ANY TABLE,
<wa> TYPE ANY,
TRY.
CREATE DATA dref TYPE STANDARD TABLE OF (dbtab)
WITH NON-UNIQUE DEFAULT KEY.
ASSIGN dref->* TO .
SELECT *
FROM (dbtab) UP TO rows ROWS
INTO TABLE .
LOOP AT ASSIGNING <wa>.
DO.
ASSIGN COMPONENT sy-index
OF STRUCTURE <wa> TO
IF sy-subrc = 0.
WRITE /
ELSE.
EXIT.
ENDIF.
ENDDO.
ULINE.
ENDLOOP.
CATCH cx_sy_create_data_error.
WRITE 'Wrong Database!'.
ENDTRY.