ABAP根据字段汇总
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ABAP根据字段汇总相关的知识,希望对你有一定的参考价值。
ABAP里我想要根据某个或某几个字段汇总:具体是我ALV里面物料相同,供应商相同,就是需求量不同,我想相同的物料、相同的供应商,需求量也随之合并,怎么实现,求解。。。谢谢各位!!
把 供应商 物料号 需求量放到一个内表里面。然后把数据汇总例如 你把所有的数据都放到了一个内表GT_ITAB里面
然后定义个内表
DATA: BEGIN OF GWA_TEMP,I LIFNR LIKE LFA1-LIFNR
MATNR LIKE MARA-MATNR,
MENGE TYPE P.
END OF GWA_TEMP.
LOOP AT GT_ITAB INTO GWA_ITAB,
LWA_TEMP-LIFNR = GWA_ITAB-LIFNR,
LWA_TEMP-MATNR = GWA_ITAB-MATNR,
LWA_TEMP-MENGE = GWA_ITAB-MENGE.
COLLECT LWA_TEMP INTO LT_TEMP
ENDLOOP.
就OK了 参考技术A 只能在ALV外面处理数据,然后把处理好的数据放进ALV 参考技术B *---type pools
TYPE-POOLS: slis.
*---internal tables
DATA: BEGIN OF it_flight OCCURS 0,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
seatsmax LIKE sflight-seatsmax,
seatsocc LIKE sflight-seatsocc,
END OF it_flight,
*--internal tables for alv
it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fcat LIKE LINE OF it_fieldcat,
layout TYPE slis_layout_alv,
it_sort type slis_t_sortinfo_alv,
wa_sort like line of it_sort.
*---start-of-selection .
START-OF-SELECTION.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'IT_FLIGHT'
i_inclname = sy-repid
CHANGING
ct_fieldcat = it_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2.
*----get data
SELECT carrid
connid
fldate
seatsmax
seatsocc
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE it_flight
UP TO 20 ROWS.
.
wa_fcat-do_sum = 'X'.
MODIFY it_fieldcat FROM wa_fcat TRANSPORTING do_sum
WHERE fieldname = 'SEATSOCC' .
wa_sort-fieldname = 'CARRID'.
wa_sort-group = 'UL'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
wa_sort-fieldname = 'CONNID'.
wa_sort-subtot = 'X'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = layout
it_fieldcat = it_fieldcat
it_sort = it_sort
TABLES
t_outtab = it_flight
EXCEPTIONS
program_error = 1. 参考技术C 用ALV TREE解决
以上是关于ABAP根据字段汇总的主要内容,如果未能解决你的问题,请参考以下文章