我想添加一个标题行来对列标题进行分组。
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
请注意,我使用的是 ALVList,不是 ALV 网格。我看过示例程序BALVBT01
它有一个 2 级标题,但事实证明这是因为它们正在显示父/子数据。我的数据只有一个级别,我只想对列进行分组。
找到了我的解决方案here https://web.archive.org/web/20111012055616/http://sample-code-abap.blogspot.com/2008/01/printing-multiple-line-header-and.html.
Use the top_of_list
在打印标准标题之前添加自定义标题信息的事件。如果您想用自己的标准头替换标准头,您可以通过传递来关闭标准头is_layout-no_colhead = 'X'
在布局表中。
* 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.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)