标签:
在ABAP内表使用时,有时候我需要按照规定的某几个字段进行汇总,方法如下:
TABLES: spfli.
TYPES: BEGIN OF ty_bd_order,
cityfrom TYPE spfli-cityfrom,
cityto TYPE spfli-cityto,
END OF ty_bd_order.
DATA: gw_date TYPE ty_bd_order,
gt_date TYPE TABLE OF ty_bd_order,
gt_order TYPE TABLE OF ty_bd_order.
SELECT cityfrom cityto INTO TABLE gt_date FROM spfli.
SORT gt_date BY cityfrom cityto.
LOOP AT gt_date INTO gw_date.
AT NEW cityto.
APPEND gw_date TO gt_order.
ENDAT.
ENDLOOP.
LOOP AT gt_order INTO gw_date.
WRITE: / gw_date-cityfrom,gw_date-cityto.
ENDLOOP.
内表gt_order 的结果就是按字段cityfrom,cityto 汇总的结果。
标签:
原文地址:http://blog.csdn.net/qinyuezhan/article/details/42238001