*&---------------------------------------------------------------------*
*& Report ZDEMO07
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zdemo07.
CLASS lcl_event_handler DEFINITION DEFERRED.
DATA: ok_code LIKE sy-ucomm,
go_timer TYPE REF TO cl_gui_timer,
go_evt_hndl TYPE REF TO lcl_event_handler.
DATA: gt_spfli TYPE TABLE OF spfli,
go_grid TYPE REF TO cl_gui_alv_grid,
go_container TYPE REF TO cl_gui_custom_container.
START-OF-SELECTION.
CALL SCREEN 0100.
****** Module status_9000 OUTPUT
MODULE status_0100 OUTPUT.
DATA: g_init TYPE flag.
CLEAR ok_code.
IF g_init IS INITIAL.
g_init = 'X'.
PERFORM init_0100.
ENDIF.
ENDMODULE. " status_0100 OUTPUT
****** Module user_command_0100 INPUT
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " user_command_0100 INPUT
****** CLASS lcl_event_handler DEFINITION
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
METHODS:
handle_timer FOR EVENT finished OF cl_gui_timer.
ENDCLASS. "lcl_event_handler DEFINITION
****** CLASS lcl_event_handler IMPLEMENTATION
CLASS lcl_event_handler IMPLEMENTATION.
METHOD handle_timer.
DELETE gt_spfli INDEX 1.
CALL METHOD go_grid->refresh_table_display.
* CALL METHOD go_timer->cancel
* EXCEPTIONS
* OTHERS = 9.
CALL METHOD go_timer->run"必须重新激活定时器
EXCEPTIONS
OTHERS = 9.
ENDMETHOD. "handle_timer
ENDCLASS. "lcl_event_handler IMPLEMENTATION
****** Form init_0100
FORM init_0100.
SELECT * INTO TABLE gt_spfli
FROM spfli UP TO 30 ROWS.
CREATE OBJECT go_container
EXPORTING
container_name = 'OO_ALV'.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_container.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'SPFLI'
CHANGING
it_outtab = gt_spfli.
CREATE OBJECT go_evt_hndl.
CREATE OBJECT go_timer
EXCEPTIONS
others = 9.
SET HANDLER go_evt_hndl->handle_timer FOR go_timer.
go_timer->interval = 10. "设置间隔
CALL METHOD go_timer->run
EXCEPTIONS
OTHERS = 9.
ENDFORM. " init_0100
阅读(1192) | 评论(0) | 转发(0) |