2008年(49)
分类:
2008-05-22 13:26:50
对于list和 grid都可用。
注册的事件分别是 TOP_OF_PAGE和 END_OF_LIST,只要注册了它们,就会在ALV的上下方分别出现注释区域。
REPORT z_temp_demo7.
TYPE-POOLS slis.
DATA: itab LIKE TABLE OF zstu_info,
itab2 LIKE TABLE OF zscoreinfo WITH HEADER LINE,
events TYPE slis_t_event WITH HEADER LINE,
listheaders TYPE slis_t_listheader WITH HEADER LINE,
listends TYPE slis_t_listheader WITH HEADER LINE.
START-OF-SELECTION.
write : 'ok'.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 4 "0代表 list 4代表grid
IMPORTING
et_events = events[].
READ TABLE events[] WITH KEY name = 'TOP_OF_PAGE' INTO events.
events-form = 'PRINT_TOP_PAGE'.
MODIFY events[] FROM events TRANSPORTING form WHERE name = 'TOP_OF_PAGE'.
READ TABLE events[] WITH KEY name = 'END_OF_LIST' INTO events.
events-form = 'PRINT_END_LIST'.
MODIFY events[] FROM events TRANSPORTING form WHERE name = 'END_OF_LIST'.
SELECT * FROM zstu_info INTO TABLE itab.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = 'PRINT_INDEX'
i_structure_name = 'ZSTU_INFO'
it_events = events[]
TABLES
t_outtab = itab[].
*&---------------------------------------------------------------------*
*& Form PRINT_INDEX
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->COMM text
* -->SEL text
*----------------------------------------------------------------------*
FORM print_index USING comm LIKE sy-ucomm
sel TYPE slis_selfield.
IF comm = '&IC1'.
SELECT * FROM zscoreinfo INTO TABLE itab2.
itab2-stud_no = sel-tabindex + 1000.
MODIFY itab2[] FROM itab2 TRANSPORTING stud_no WHERE stud_no = '1' OR stud_no <> '1'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_structure_name = 'ZSCOREINFO'
TABLES
t_outtab = itab2[].
IF sy-subrc <> 0.
ENDIF.
ENDIF.
ENDFORM. "PRINT_INDEX
*&---------------------------------------------------------------------*
*& Form PRINT_TOP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM print_top_page.
IF listheaders[] IS INITIAL.
listheaders-typ = 'H'.
listheaders-info = 'This is top'.
APPEND listheaders.
ENDIF.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = listheaders[]
* I_LOGO =
* I_END_OF_LIST_GRID = 'X'
* I_ALV_FORM =
.
ENDFORM. "
*&---------------------------------------------------------------------*
*& Form print_end
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM print_end_list.
IF listends[] IS INITIAL.
listends-typ = 'H'.
listends-info = 'This is end'.
APPEND listends.
ENDIF.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = listends[]
* I_LOGO =
* I_END_OF_LIST_GRID = 'X'
* I_ALV_FORM =
.
ENDFORM. "