ALV 列表中的两级列标题 [英] Two-level column headings in ALV List
问题描述
我想添加一个对列标题进行分组的标题行.
I want to add a header row grouping the column headers.
Departure Arrival <-- This row is what I want to add
Airport Gate Date Airport Gate Date
-------- ----- ----- -------- ----- -------
O'Hare A10 10Mar Atlanta G19 10Mar
DFW K98 11Mar Denver Z76 11Mar
请注意,我使用的是 ALV List,而不是 ALV 网格.我查看了示例程序 BALVBT01
,它有一个 2 级标题,但事实证明这是因为它们正在显示父/子数据.我的数据只有一层,我只想对列进行分组.
Note that I'm using an ALV List, not an ALV Grid. I've looked at the sample program BALVBT01
which has a 2-level header but it turns out it's because they are displaying parent/child data. My data has only one level, I just want to group the columns.
推荐答案
找到我的解决方案 此处.
在打印标准标题之前,使用 top_of_list
事件添加自定义标题信息.如果您想用自己的标题替换标准标题,您可以通过在布局表中传递 is_layout-no_colhead = 'X'
来关闭标准标题.
Use the top_of_list
event to add custom header info before the standard header is printed. If you want to replace the standard header with your own you can turn off the standard header by passing is_layout-no_colhead = 'X'
in the layout table.
* Get Event table
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
IMPORTING
et_events = it_evt.
* Add pointer to custom top_of_list event handler
READ TABLE it_evt INTO wa_evt
WITH KEY name = slis_ev_top_of_list .
wa_evt-form = 'MY_TOP_OF_LIST' .
MODIFY it_evt FROM wa_evt INDEX sy-tabix .
* Pass event table when printing ALV list
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = w_prog
is_layout = fs_layout
it_fieldcat = t_fieldcat
it_events = it_evt
TABLES
t_outtab = t_spfli.
************************************
* Custom event handler to write group-level header
FORM MY_TOP_OF_LIST .
ULINE AT 1(43) .
FORMAT COLOR COL_HEADING .
WRITE: / sy-vline ,
10 'SAP' ,
22 sy-vline ,
31 'VPPA' ,
43 sy-vline .
ENDFORM.
这篇关于ALV 列表中的两级列标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!