为了使ALV输出的报表更加美观,除了设置报表的各行的各列颜色,还可以给输出的报表添加一个标题,这个很简单,只需要传给函数REUSE_ALV_GRID_DISPLAY 输入项目下的I_GRID_TITLE = '标题' 即可;
除此之外,还可以进行一个类似于页眉的设置,可以在一个子程序中进行,处理好之后,将子程序名称传给 i_callback_top_of_page .如下代码
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_repid
it_fieldcat = int_fcat
i_callback_top_of_page = 'ALV_TOP_OF_PAGE'
i_save = 'A'
i_callback_user_command = 'FRM_UCOMM' "实现双击事件
TABLES
t_outtab = imat
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
FORM alv_top_of_page.
DATA:it_commentary TYPE slis_t_listheader.
DATA wa_commentary LIKE LINE OF it_commentary .
CLEAR wa_commentary.
wa_commentary-typ = 'S'.
wa_commentary-key = 'WRITE BY:'.
wa_commentary-info = sy-uname.
APPEND wa_commentary TO it_commentary .
CLEAR wa_commentary.
wa_commentary-typ = 'S'.
wa_commentary-key = 'DATA:'.
wa_commentary-info = sy-datum .
APPEND wa_commentary TO it_commentary .
本帖隐藏的内容
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'EXPORTING
it_list_commentary = it_commentary
i_logo = 'ENJOYSAP_LOGO'.
ENDFORM. "ALV_TOP_OF_PAGE