开发者

Two-level column headings in ALV List

开发者 https://www.devze.com 2023-01-03 23:11 出处:网络
I want to add a header row grouping the column headers. DepartureArrival<-- This row is what I want to add

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. 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.


Found my solution here.

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.
0

精彩评论

暂无评论...
验证码 换一张
取 消