Skip to Content
author's profile photo Former Member
Former Member

auto refresh

I am trying to implement auto refresh functionality in one of my reports. The requirement is to automatically refresh the report with latest data after a selected time interval.i.e say after every 5 minutes.

Thanks in advance for your help,

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jan 27, 2008 at 06:50 PM

    Basically, you will want to use the class CL_GUI_TIMER. If you are on a release > 6.20, you'll be fine. Here is an example report, which is an ALV grid, copy and paste and run it. You will notice that every 3 seconds a new row is added to the ALV output automatically. Use this report as your example. The TIMEOUT field is the number of seconds that you want the program to wait before refreshing.

    
    REPORT rich_0001.
    
    
    TYPE-POOLS : slis.
    
    DATA: BEGIN OF itab OCCURS 0,
          fld1 TYPE i,
          fld2 TYPE i,
          END OF itab.
    
    *---------------------------------------------------------------------*
    *       CLASS lcl_event_handler DEFINITION
    *---------------------------------------------------------------------*
    CLASS lcl_event_handler DEFINITION.
    
      PUBLIC SECTION.
    
        CLASS-METHODS: on_finished FOR EVENT finished OF cl_gui_timer.
    
    ENDCLASS.                    "lcl_event_handler DEFINITION
    
    
    DATA: gui_timer TYPE REF TO cl_gui_timer.
    DATA: event_handler TYPE REF TO lcl_event_handler.
    DATA: timeout TYPE i VALUE '3'.
    
    
    START-OF-SELECTION.
    
      CREATE OBJECT gui_timer.
    
      SET HANDLER event_handler->on_finished FOR gui_timer.
    
      gui_timer->interval = timeout.
      CALL METHOD gui_timer->run.
    
      PERFORM write_list.
    
    *----------------------------------------------------
    * FORM  alv_user_command
    *----------------------------------------------------
    FORM alv_user_command USING r_ucomm  TYPE sy-ucomm
                         rs_selfield  TYPE slis_selfield.
    
      PERFORM read_data.
      rs_selfield-refresh = 'X'.
    
    ENDFORM.                    "alv_user_command
    
    *----------------------------------------------------
    * FORM  write_list
    *----------------------------------------------------
    FORM write_list.
    
      DATA: fieldcat TYPE slis_t_fieldcat_alv.
      DATA: repid TYPE sy-repid.
    
      repid = sy-repid.
    
      PERFORM read_data.
    
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name         = repid
          i_internal_tabname     = 'ITAB'
          i_inclname             = repid
        CHANGING
          ct_fieldcat            = fieldcat
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
    
    
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          it_fieldcat             = fieldcat
          i_callback_program      = repid
          i_callback_user_command = 'ALV_USER_COMMAND'
        TABLES
          t_outtab                = itab
        EXCEPTIONS
          program_error           = 1
          OTHERS                  = 2.
    
    
    ENDFORM.                    "write_list
    
    *---------------------------------------------------------------------*
    *       FORM read_data                                                *
    *---------------------------------------------------------------------*
    FORM read_data.
    
    * Use your own database table here.
      itab-fld1 = itab-fld1 + 1.
      itab-fld2 = itab-fld2 + 1.
      APPEND itab.
    
    ENDFORM.                    "read_data
    *---------------------------------------------------------------------*
    *       CLASS lcl_event_handler IMPLEMENTATION
    *---------------------------------------------------------------------*
    CLASS lcl_event_handler IMPLEMENTATION.
    
      METHOD on_finished.
    
    * Start Timer again
        gui_timer->interval = timeout.
        CALL METHOD gui_timer->run.
    
    * cause PAI
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = 'REFR'.
    
      ENDMETHOD.
    
    ENDCLASS.
    
    
    

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 11:23 AM

    If you are running the report in a SAPGUI, you can probably use the

    CL_GUI_TIMER class for that. In the background, you can plan a job,

    running every 5 minutes.

    Cheers,

    Chaitanya.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.