DATA

Short Reference

Syntax Forms



Using Predefined Types

1. DATA { {var[(len)] TYPE abap_type [DECIMALS dec]}
       | {var TYPE abap_type [LENGTH len] [DECIMALS dec]} }
       [VALUE val|{IS INITIAL}]
       [READ-ONLY].

Reference to Existing Types

2. DATA var { {TYPE [LINE OF] type}
           | {LIKE [LINE OF] dobj} }
           [VALUE val|{IS INITIAL}]
           [READ-ONLY].

Reference Variables

3. DATA ref { {TYPE REF TO type}
           | {LIKE REF TO dobj} }
           [VALUE IS INITIAL]
           [READ-ONLY].

Structures

4. DATA BEGIN OF struc [READ-ONLY].
     ...
     {DATA comp ...} | {INCLUDE {TYPE|STRUCTURE} ...}.
     ...
  DATA END OF struc.

Internal Tables

5. DATA itab { {TYPE tabkind OF [REF TO] type}
            | {LIKE tabkind OF dobj} }
            [WITH key] [INITIAL SIZE n]
            [WITH HEADER LINE]
            [VALUE IS INITIAL]
            [READ-ONLY].

Ranges Table

6. DATA rtab {TYPE RANGE OF type}|{LIKE RANGE OF dobj}
            [INITIAL SIZE n]
            [WITH HEADER LINE]
            [VALUE IS INITIAL]
            [READ-ONLY].

Effect

The statement DATA declares a variable of any data type. The declared data object is visible within the current context as of this position. Within the declaration part of a class or an interface, DATA declares an instance attribute whose validity is bound to an instance of a class.

The data type of arbitrary variables var, reference variables ref , and internal tables itab, rtab, is defined either using the TYPE addition and a type specification, or using the LIKE addition and the specification of a data object. There are different syntax variants for the definition of elementary data objects, reference variables, and internal tables. If neither TYPE nor LIKE is specified, a data object with the bound data type c of length 1 is created.

For the definition of a structure struc, arbitrary data declarations are included by two DATA statements with the additions BEGIN OF and END OF. Here a struc structure is declared that contains the enclosed data objects comp as a struc-comp component. Structure definitions can be nested.

For the names var, ref, struc, comp, itab, and rtab, the naming conventions apply.

Notes