Syntax
… DATA(var) …
Effect
A declaration expression with the declaration operator DATA declares a variable var 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.
大意:就是用data来声明一个变量。
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 ).
貌似在 7.40这个版本用不上。
本文介绍ABAP中使用DATA关键字进行内联变量声明的方法,包括内部表的声明及赋值,以及变量用于HTML转换的例子。这种声明方式在编译时进行,无论实际是否执行。
&spm=1001.2101.3001.5002&articleId=108018670&d=1&t=3&u=11ec52af97fa4fbaa93cb43882ee5eb3)
1021

被折叠的 条评论
为什么被折叠?



