SAP® Documentation

Single view

ABENDATA_INLINE - DATA INLINE

CPI1466 during Backup   CPI1466 during Backup  
This documentation is copyright by SAP AG.
SAP E-Book

DATA - Inline Declaration

Syntax

... DATA(var) ...

Effect

A declaration expression with the declaration operator DATA declares a variablevar used as an operand in the current writing position. The declared variable is visible statically in the program from the location 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 reading position of the same statement.

Only use inline declarations locally.

Notes

  • A valid statement with an inline declaration of a variable can generally be interpreted as a short form for a declaration statement used as a direct prefix.
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 data object is still valid in the statement and is only obscured after the statement.
  • Just like the statement DATA, an inline declaration does not open a local context for the current statement block. An inline declaration for a variable can only be made once within a context and the variable cannot yet be declared there using DATA.
  • An inline declaration cannot occur on the right-hand side of an assignment or within an expression.
  • The operand position and the types of other operands can be included in the static derivation of the operand type. If the type of a different operand cannot be identified statically (perhaps because it is specified as a generically typed field symbol), either a suitable standard type is used or no inline declaration is possible.
  • If the operand type is defined by reference to a data type in ABAP Dictionary, it is used together with its semantic attributes, such as field help, input help, or conversion routines.
  • If more than one equally valid operand type is possible in the same declaration position, the recommended preferred data type is generally used.

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.

Example

Inline declaration of an internal table as a target field of a SELECT statement and inline declaration of a variable for the table transformed to HTML. The data type of the variable is determined by the return value of the method.

SELECT *
       FROM scarr
       INTO TABLE @DATA(itab).

DATA(html) = cl_demo_output=>get( itab ).






General Material Data   Vendor Master (General Section)  
This documentation is copyright by SAP AG.

Length: 4679 Date: 20200127 Time: 224307     sap01-206 ( 31 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.