REPORT z_barry_alv_header .
TABLES : t001.
TYPE-POOLS: slis.
DATA : w_repid LIKE sy-repid.
TYPES : BEGIN OF ty_comp.
INCLUDE STRUCTURE t001.
TYPES : END OF ty_comp.
DATA: wa_layout TYPE slis_layout_alv.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv.
DATA : it_comp TYPE TABLE OF ty_comp WITH HEADER LINE.
INITIALIZATION.
w_repid = sy-repid.
START-OF-SELECTION.
SELECT * FROM t001 INTO TABLE it_comp.
it_comp-butxt = '双击ALV的行'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = w_repid
i_internal_tabname = 'IT_COMP'
i_structure_name = 'T001'
i_inclname = w_repid
CHANGING
ct_fieldcat = it_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = w_repid
i_callback_html_top_of_page = 'HTML_TOP_OF_PAGE'
i_callback_user_command = 'USER_COMMAND'
is_layout = wa_layout
it_fieldcat = it_fieldcat
TABLES
t_outtab = it_comp
EXCEPTIONS
program_error = 1
OTHERS = 2.
*&---------------------------------------------------------------------*
*& Form html_top_of_page
*&---------------------------------------------------------------------*
FORM. html_top_of_page USING w_doc TYPE REF TO cl_dd_document.
DATA: code(255) TYPE c .
DATA: sdydo_html_table TYPE sdydo_html_line OCCURS 0.
DATA: wa LIKE LINE OF sdydo_html_table.
CALL METHOD w_doc->set_document_background
EXPORTING
picture_id = 'Z_BTZ'.
CLEAR code.
REFRESH w_doc->html_table.
wa-line = '
' ' &
'测试ALVHeader显示HTML
'.
APPEND wa TO w_doc->html_table.
CONCATENATE ' '
it_comp-butxt '
' INTO wa-line.
APPEND wa TO w_doc->html_table.
wa-line = ''.
APPEND wa TO w_doc->html_table.
ENDFORM. "HTML_TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form user_command
*&---------------------------------------------------------------------*
FORM. user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
READ TABLE it_comp INDEX rs_selfield-tabindex.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDFORM. "user_com
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13973563/viewspace-752286/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/13973563/viewspace-752286/