简体   繁体   English

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

Note that I'm using an ALV List , not an ALV Grid.请注意,我使用的是 ALV列表,而不是 ALV 网格。 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.我查看了示例程序BALVBT01 ,它有一个 2 级标题,但事实证明这是因为它们正在显示父/子数据。 My data has only one level, I just want to group the columns.我的数据只有一层,我只想对列进行分组。

Found my solution here . 在这里找到了我的解决方案。

Use the top_of_list event to add custom header info before the standard header is printed.使用top_of_list事件在打印标准标题之前添加自定义标题信息。 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.如果您想用自己的标题替换标准标题,您可以通过在布局表中传递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.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM