ABAP Keyword Documentation →  ABAP − Reference →  Declarations →  Inline Declarations → 

DATA - Inline Declaration

Syntax

... DATA(var) ...

Effect

A declaration expression with the declaration operator DATA declares a variable var used as an operand in the current writer position. The declared variable is visible statically in the program from DATA(var) and is valid in the current context. The declaration is made when the program is compiled, regardless of whether the statement is actually executed.

The declaration operator DATA can be specified in every compatible declaration position. The date type of the variable is determined by the operand type. It must be possible to derive this type statically in full.

A variable var declared inline cannot be used in a reader position of the same statement.

Programming Guideline

Only use inline declarations locally.

Notes

DATA var TYPE ...
... var ...
Exceptions to this rule occur only if an identically named data object from a more global context is used in the same statement. This field symbol is still valid and is only hidden after the statement.

Example

Inline declaration of an internal table as a target field of an assignment and inline declaration of an appropriate work area in a LOOP.

TYPES t_itab TYPE TABLE OF i
             WITH NON-UNIQUE KEY table_line.

DATA(itab) = VALUE t_itab( ( 1 ) ( 2 ) ( 3 ) ).
LOOP AT itab INTO DATA(wa).
  ...
ENDLOOP.