1使用方法如下
变量:VALUEdtype|#()
结构:VALUEdtype|#(comp1 = a1 comp2 = a2…)
表 : VALUEdtype |#( ( ... ) ( ... ) ... ) ...
2代码示例
"""结构赋值
TYPES: BEGIN OF ty_columns1, "简单结构
cols1 TYPE i,
cols2 TYPE i,
END OF ty_columns1.
TYPES: BEGIN OF ty_columns2, "嵌套结构
coln1 TYPE i,
coln2 TYPE ty_columns1,
END OF ty_columns2.
DATA: struc_simple TYPE ty_columns1,
struc_nest1 TYPE ty_columns2,
struc_nest2 TYPE ty_columns2.
struc_nest1 = VALUE ty_columns2( coln1 = 1 ""类型用指定类型和#号都可以,
coln2-cols1 = 1
coln2-cols2 = 2 ).
struc_nest2 = VALUE #( coln1 = 1 ""用#相当于使用struc_nest2定义的类型
coln2 = VALUE #( cols1 = 1
cols2 = 2 ) ).
DATA(struc_nest3) = VALUE ty_columns2( coln1 = 1 ""快速定义的只能用特定的类型不能用#
coln2-cols1 = 1
coln2-cols2 = 2 ).
""表赋值
TYPES t_itab TYPE TABLE OF i WITH EMPTY KEY.
DATA itab TYPE t_itab.
itab = VALUE #( ( ) ( 1 ) ( 2 ) ).
DATA itab2 TYPE RANGE OF i.
itab2 = VALUE #( sign = 'I' option = 'BT' ( low = 1 high = 10 )
( low = 21 high = 30 )
( low = 41 high = 50 )
option = 'GE' ( low = 61 ) ).