1 *modifying a set of lines directly(批量修改内表数据)
2 *使用"LOOP ... ASSIGNING ..."可以直接修改内表中的数据,而不需要先将内表数据复制到相应工作区,然后再更新回去。
3 ***METHOD ONE:
4 LOOP AT itab INTO wa.
5 i = sy-tabix MOD 2.
6 IF i = 0.
7 wa-flag = ‘X‘.
8 MODIFY itab FROM wa.
9 ENDIF.
10 ENDLOOP.
11
12 ***METHOD TWO:
13 field-symboles:<wa> like itab.
14 LOOP AT itab ASSIGNING <wa>.
15 i = sy-tabix MOD 2.
16 IF i = 0.
17 <wa>-flag = ‘X‘.
18 ENDIF.
19 ENDLOOP.
20
21 ***METHOD THERE:
22 DATA: gt_list TYPE TABLE OF ty_list.
23 FIELD-SYMBOLS <fs_list> TYPE ty_list.
24 CASE <fs_list>-wbstk.
25 WHEN ‘C‘.
26 <fs_list>-status = icon_led_green.
27 WHEN ‘B‘.
28 <fs_list>-status = icon_led_yellow.
29 WHEN ‘A‘.
30 <fs_list>-status = icon_led_red.
31 ENDCASE.
32 ENDLOOP.