场景:
集成多个ALV显示的程序。
1.定义变量
DATA: dyn_table TYPE REF TO data.
DATA: dyn_wa TYPE REF TO data.
FIELD-SYMBOLS: <dyn_table> TYPE table,
<dyn_wa> TYPE any,
TYPE any.
2.创建
*创建动态表结构
CREATE DATA dyn_table TYPE TABLE OF (pv_type).
创建动态内表
ASSIGN dyn_table-> TO <dyn_table>.
*创建动态工作区结构
CREATE DATA dyn_wa LIKE LINE OF <dyn_table>.
创建动态工作区
ASSIGN dyn_wa-> TO <dyn_wa>.
3.使用
LOOP AT <dyn_table> ASSIGNING <dyn_wa>.
ASSIGN COMPONENT 'AUART' OF STRUCTURE <dyn_wa> TO <fs>.
<fs> = 'YRE'. "虚拟订单类型 VBAK,取值默认“YRE”
ASSIGN COMPONENT 'MENGE' OF STRUCTURE <dyn_wa> TO <fs>.
<fs> = '1'. "数量 VBAP,取值默认“1”
ASSIGN COMPONENT 'BZ' OF STRUCTURE <dyn_wa> TO <fs>.
<fs> = '1'. "步骤
ENDLOOP.
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX rs_selfield-tabindex.
ASSIGN COMPONENT 'ZBOX' OF STRUCTURE <dyn_wa> TO <fs>.
ASSIGN COMPONENT 'VBELN_VL' OF STRUCTURE <dyn_wa> TO <vbeln>.