Académique Documents
Professionnel Documents
Culture Documents
Class CL_GUI_TIMER trigger event FINISHED at given intervals (in seconds). This event can be used to
select the data, carry out processing and update the content internal table attached to ALV. Below
sample code illustrate how to use this class to refresh ALV. To summarise the program logic in short,
you need to define object of CL_GUI_ALV_GRID, a local class to handle event FINISHED, couple this
event method defined in local class, specify time interval in seconds and kick start the timer.
Note that I have used SELECT.. APPENDING TABLE to show change in data after refresh. And I think it is
good idea to inform user about last time report was refresh with MESSAGE statement.
REPORT
zpwtest8.
DATA : ob_grid
ob_recev
ob_timer
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_timer DEFINITION.
PUBLIC SECTION.
METHODS:
handle_finished FOR EVENT finished OF cl_gui_timer.
ENDCLASS.
"lcl_receiver DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_timer IMPLEMENTATION.
METHOD handle_finished.
PERFORM refresh_data .
MESSAGE s003(z001) WITH 'Report refreshed at' sy-uzeit.
"handle_finished
ENDCLASS.
"lcl_receiver IMPLEMENTATION
*--------------------------------------------------------------------*
*
Start of Selection
*--------------------------------------------------------------------*
START-OF-SELECTION .
PERFORM select_data .
*--------------------------------------------------------------------*
*
End of Selection
*--------------------------------------------------------------------*
END-OF-SELECTION .
PERFORM display_data .
*--------------------------------------------------------------------*
*&
Form
Select_Date
*--------------------------------------------------------------------*
FORM select_data .
SELECT *
APPENDING TABLE i_spfli
FROM spfli .
ENDFORM.
"SELECT_DATA
*&---------------------------------------------------------------------*
*&
Form
refresh_data
*&---------------------------------------------------------------------*
FORM refresh_data .
ENDFORM.
"refresh_data
*&---------------------------------------------------------------------*
*&
Form
display_data
*&---------------------------------------------------------------------*
FORM display_data .
= i_spfli
EXCEPTIONS
program_error
= 1
OTHERS
= 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM .
"display_data