By

Inline Declaration

A declaration using the DATA operator defines a variable at the point where it is used as an operand.

  • This variable becomes statically visible from the position of DATA(var) and is valid within the current context.
  • The declaration is processed at compile time, regardless of whether the statement is executed at runtime.
  • The DATA declaration operator can be used in any position where a compatible declaration is allowed.
  • An inline declaration for a variable can be made only once within a given context, and the variable must not have already been declared using DATA in that context.
  • An Inline declaration cannot be used on the right-hand side of an assignment or inside an expression.

Syntax:

  • Inline variable declaration
DATA(lv_var) = ‘Sample’.
  • Loop AT with Inline Declaration
LOOP AT itab INTO DATA(ls_itab).
  ….
ENDLOOP.

  • Inline declaration of an internal table
SELECT vbeln,
              Posnr,
              matnr,
              netwr
              FROM vbap
              INTO TABLE @DATA(lt_vbap)
              UP TO 20 ROWS.

Thanks for Visiting!

Sangeeta Singh

Leave a Reply

Discover more from HANAxABAP

Subscribe now to keep reading and get access to the full archive.

Continue reading