REPORT ZAUTOREFRESH.
CLASS lcl_timer DEFINITION DEFERRED .
DATA : i_spfli TYPE TABLE OF spfli .
DATA : ob_grid TYPE REF TO cl_gui_alv_grid ,
ob_recev TYPE REF TO lcl_timer ,
ob_timer TYPE REF TO cl_gui_timer .
*----------------------------------------------------------------------*
* CLASS lcl_receiver DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_timer DEFINITION.
PUBLIC SECTION.
METHODS:
handle_finished FOR EVENT finished OF cl_gui_timer.
ENDCLASS. "lcl_receiver DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_timer IMPLEMENTATION.
METHOD handle_finished.
PERFORM refresh_data .
MESSAGE s003(z001) WITH 'Report refreshed at' sy-uzeit.
CALL METHOD ob_timer->run.
ENDMETHOD. "handle_finished
ENDCLASS. "lcl_receiver IMPLEMENTATION
*--------------------------------------------------------------------*
* Start of Selection
*--------------------------------------------------------------------*
START-OF-SELECTION .
PERFORM select_data .
*--------------------------------------------------------------------*
* End of Selection
*--------------------------------------------------------------------*
END-OF-SELECTION .
* Step 1 : Initialise Time control
CREATE OBJECT ob_timer.
* Step 2 : Initialise object to receive event
CREATE OBJECT ob_recev.
* Step 3 : Couple event to method
SET HANDLER ob_recev->handle_finished FOR ob_timer. "
* Step 4 : Set Interval in seconds
ob_timer->interval = 20 .
* Step 5 : Start Timer
CALL METHOD ob_timer->run.
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 .
* Get grid reference
IF ob_grid IS INITIAL .
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ob_grid.
ENDIF.
IF ob_grid IS NOT INITIAL. "Sanity Test
PERFORM select_data .
CALL METHOD ob_grid->refresh_table_display.
ENDIF.
ENDFORM. "refresh_data
*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
FORM display_data .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_structure_name = 'SPFLI'
TABLES
t_outtab = 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
Output
CLASS lcl_timer DEFINITION DEFERRED .
DATA : i_spfli TYPE TABLE OF spfli .
DATA : ob_grid TYPE REF TO cl_gui_alv_grid ,
ob_recev TYPE REF TO lcl_timer ,
ob_timer TYPE REF TO cl_gui_timer .
*----------------------------------------------------------------------*
* CLASS lcl_receiver DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_timer DEFINITION.
PUBLIC SECTION.
METHODS:
handle_finished FOR EVENT finished OF cl_gui_timer.
ENDCLASS. "lcl_receiver DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_timer IMPLEMENTATION.
METHOD handle_finished.
PERFORM refresh_data .
MESSAGE s003(z001) WITH 'Report refreshed at' sy-uzeit.
CALL METHOD ob_timer->run.
ENDMETHOD. "handle_finished
ENDCLASS. "lcl_receiver IMPLEMENTATION
*--------------------------------------------------------------------*
* Start of Selection
*--------------------------------------------------------------------*
START-OF-SELECTION .
PERFORM select_data .
*--------------------------------------------------------------------*
* End of Selection
*--------------------------------------------------------------------*
END-OF-SELECTION .
* Step 1 : Initialise Time control
CREATE OBJECT ob_timer.
* Step 2 : Initialise object to receive event
CREATE OBJECT ob_recev.
* Step 3 : Couple event to method
SET HANDLER ob_recev->handle_finished FOR ob_timer. "
* Step 4 : Set Interval in seconds
ob_timer->interval = 20 .
* Step 5 : Start Timer
CALL METHOD ob_timer->run.
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 .
* Get grid reference
IF ob_grid IS INITIAL .
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ob_grid.
ENDIF.
IF ob_grid IS NOT INITIAL. "Sanity Test
PERFORM select_data .
CALL METHOD ob_grid->refresh_table_display.
ENDIF.
ENDFORM. "refresh_data
*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
FORM display_data .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_structure_name = 'SPFLI'
TABLES
t_outtab = 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
Output
thanks for your nice post..
ReplyDeleteregards
thomas
it helps me....
ReplyDeletethx for ur post :)
It is very helpful.. Thank you!!
ReplyDeleteVery helpful. Thank you
ReplyDelete