如何在ALV中输出标题头
1、申明变量
DATA: GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: GT_EVENTS TYPE SLIS_T_EVENT.
2、定义供alv回调用Form
*---------------------------------------------------------------------*
* FORM TOP_OF_PAGE *
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
* i_logo = 'HTMLCNTL_TESTHTM2_SAPLOGO'
I_LOGO = 'ENJOYSAP_LOGO'
IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
ENDFORM.
3、定义填写输出ALV标题头输出内容的内表Form
FORM E04_COMMENT_BUILD USING E04_LT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: LS_LINE TYPE SLIS_LISTHEADER.
*
* Listenüberschrift: Typ H
CLEAR LS_LINE.
LS_LINE-TYP = 'H'. "显示为黑体,大号字
* LS_LINE-KEY: not used for this type
LS_LINE-INFO = TEXT-100.
APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
* Kopfinfo: Typ S
CLEAR LS_LINE.
LS_LINE-TYP = 'S'. "显示为标准字体大小
LS_LINE-KEY = TEXT-101. "显示为标准字体大小,但是为黑体
LS_LINE-INFO = TEXT-102. "显示为标准字体大小
APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
LS_LINE-KEY = TEXT-103.
LS_LINE-INFO = TEXT-104.
APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
* Aktionsinfo: Typ A
CLEAR LS_LINE.
LS_LINE-TYP = 'A'. "显示为斜体
* LS_LINE-KEY: not used for this type
LS_LINE-INFO = TEXT-105.
APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
ENDFORM.
4、定义建立ALV事件内表FORM,将ALV事件内表的SLIS_EV_TOP_OF_PAGE事件处理函数名称替换成自定义的
FORM E03_EVENTTAB_BUILD USING E03_LT_EVENTS TYPE SLIS_T_EVENT.
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
*
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = E03_LT_EVENTS.
READ TABLE E03_LT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE 'TOP_OF_PAGE' TO LS_EVENT-FORM.
APPEND LS_EVENT TO E03_LT_EVENTS.
ENDIF.
ENDFORM.
5、调用函数
PERFORM E03_EVENTTAB_BUILD USING GT_EVENTS[].
PERFORM E04_COMMENT_BUILD USING GT_LIST_TOP_OF_PAGE[].
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
IT_FIELDCAT = GT_FIELDCAT[]
IT_SORT = GT_SORT[]
IT_EVENTS = GT_EVENTS[]
TABLES
T_OUTTAB = GT_SFLIGHT.
相关:http://blog.csdn.net/compassbutton/archive/2007/01/31/1499218.aspx
http://blog.csdn.net/CompassButton/archive/2006/12/01/1424228.aspx