Skip to Content
avatar image
Former Member

Auto Refresh Report

How can i create a Report that refreshes every xx Mins, without occupying a Workprocess? When not possible in ABAP exists there a other way to refresh a Report?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Jun 03, 2004 at 02:46 PM

    Hi,

    did you try the WAIT UP TO n SECONDS - statement in abap?

    regards

    johannes

    Add comment
    10|10000 characters needed characters exceeded

    • WAIT UP TO n SECONDS....will tie up a work process.

      Here is a solution.

      Create a function module like this. No parameters

      FUNCTION Z_ENQUE_SLEEP.

      CALL FUNCTION 'ENQUE_SLEEP'

      EXPORTING

      SECONDS = 1.

      ENDFUNCTION.

      Next implement the following report program.

      This is a sample....it should give you an idea of

      what you have to do in your program.

      REPORT ZRICH_0010

      no standard page heading.

      START-OF-SELECTION.

      CALL FUNCTION 'Z_ENQUE_SLEEP'

      STARTING NEW TASK 'WAIT'

      PERFORMING WHEN_FINISHED ON END OF TASK.

      Write:/ sy-datum, sy-uzeit.

      END-OF-SELECTION.

      AT USER-COMMAND.

      SY-LSIND = SY-LSIND - 1.

      CALL FUNCTION 'Z_ENQUE_SLEEP'

      STARTING NEW TASK 'INFO'

      PERFORMING WHEN_FINISHED ON END OF TASK.

      Write:/ sy-datum, sy-uzeit.

      **********************************************************

      • WHEN_FINISHED

      **********************************************************

      FORM WHEN_FINISHED USING TASKNAME.

      • Trigger an event to run the at user-command

      RECEIVE RESULTS FROM FUNCTION 'Z_ENQUE_SLEEP'.

      SET USER-COMMAND 'BUMM'.

      ENDFORM.

  • Jun 03, 2004 at 06:55 PM

    In release 620 there is Frontend Timer control that you can use. The proxy class for this control is CL_GUI_TIMER. Because the timer runs on the frontend no system resources are used up waiting for the timer to fire. Your report just has to register this timer and respond to the raised event. If you aren't on 620, but you are running the 620 SAPGui, you can back-port this useful proxy class.

    You need to create a class that inherits from the superclass CL_GUI_CONTROL and has a forward declaration for SFES. You need to declare one public constant called EVENTID_FINISHED of type I with an initial value of 1. You need to delare one Public Instance attribute of type I with an initial value of 0. You have to declare one public instance event named FINISHED with no parameters. You will create three Public Methods:

    <b>Constructor</b>

    Interface

    @78\QImporting@ LIFETIME TYPE I OPTIONAL Lifetime

    @78\QImporting@ VALUE( SHELLSTYLE ) TYPE I OPTIONAL Shell Style

    @78\QImporting@ VALUE( PARENT ) TYPE REF TO CL_GUI_CONTAINER OPTIONAL Parent Container

    @03\QException@ ERROR error

    method constructor.

    data clsid(80).

    data event_tab type cntl_simple_events.

    data event_tab_line type cntl_simple_event.

    if clsid is initial.

    data: return,

    guitype type i.

    guitype = 0.

    call function 'GUI_HAS_OBJECTS'

    exporting

    object_model = sfes_obj_activex

    importing

    return = return

    exceptions

    others = 1.

    if sy-subrc ne 0.

    raise error.

    endif.

    if return = 'X'.

    guitype = 1.

    endif.

    if guitype = 0.

    call function 'GUI_HAS_OBJECTS'

    exporting

    object_model = sfes_obj_javabeans

    importing

    return = return

    exceptions

    others = 1.

    if sy-subrc ne 0.

    raise error.

    endif.

    if return = 'X'.

    guitype = 2.

    endif.

    endif.

    case guitype.

    when 1.

    clsid = 'Sapgui.InfoCtrl.1'.

    when 2.

    clsid = 'com.sap.components.controls.sapImage.SapImage'.

    endcase.

    endif.

    call method super->constructor

    exporting

    clsid = clsid

    shellstyle = 0

    parent = cl_gui_container=>default_screen

    autoalign = space

    exceptions others = 1.

    if sy-subrc ne 0.

    raise error.

    endif.

    call method cl_gui_cfw=>subscribe

    exporting

    shellid = h_control-shellid

    ref = me

    exceptions others = 1.

    if sy-subrc ne 0.

    raise error.

    endif.

    • Register the events

    event_tab_line-eventid = zcl_es_gui_timer=>eventid_finished.

    append event_tab_line to event_tab.

    call method set_registered_events

    exporting

    events = event_tab.

    endmethod.

    <b>Cancel</b>

    Interface

    @03\QException@ ERROR Error During Method Call

    method cancel.

    call method call_method

    exporting

    method = 'SetTimer'

    p_count = 1

    p1 = -1

    queue_only = 'X'

    exceptions others = 1.

    if sy-subrc ne 0.

    raise error.

    endif.

    endmethod.

    <b>Run</b>

    Interface

    @03\QException@ ERROR Error

    method run.

    call method call_method

    exporting

    method = 'SetTimer'

    p_count = 1

    p1 = interval

    queue_only = 'X'

    exceptions others = 1.

    if sy-subrc ne 0.

    raise error.

    endif.

    endmethod.

    You also need on Redefinition of method <b>Dispatch</b>.

    Interface

    @78\QImporting@ VALUE( CARGO ) TYPE SYUCOMM Cargo

    @78\QImporting@ VALUE( EVENTID ) TYPE I Event ID

    @78\QImporting@ VALUE( IS_SHELLEVENT ) TYPE CHAR1 Shell Event

    @78\QImporting@ VALUE( IS_SYSTEMDISPATCH ) TYPE CHAR1 OPTIONAL System event

    @03\QException@ CNTL_ERROR Control No Longer Valid

    method dispatch.

    case eventid.

    when eventid_finished.

    raise event finished.

    endcase.

    endmethod.

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 03, 2004 at 08:10 PM

    Actually some clarification on <i>occupying a workprocess</i> might be needed. If you use the ENQUE_SLEEP inside a RFC enabled function with the STARTING NEW TASK statement you do free up your current frontend session. But that is because the ENQUE_SLEEP is actually running in another workprocess. If you look in SM51 you will still see a dialog workprocess in a Running state for the whole time that your ENQUE_SLEEP is sleeping. However the wait up to x seconds by itself does put the user's frontend into a wait state. But it does not consume a dialog workprocess. If you place a wait up to x seconds command in a remote function module and call it via the starting new task option you can free the frontend session while also not tying up any backend workprocesses.

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 04, 2004 at 09:24 AM

    Hallo,

    you can also use CL_GUI_TIMER:

    CREATE OBJECT refresh_timer

    EXCEPTIONS OTHERS = 1.

    IF sy-subrc = 0.

    SET HANDLER event_handler->handle_autorefresh FOR refresh_timer.

    refresh_timer->interval = refr_interval.

    ENDIF.

    Then the front end will wait up to <i>refr_interval</i> seconds.

    Regards,

    Oliver

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Kenneth,

      my answer is a little late, because I was on vacation.

      The event_handler is a local class in your program. I use one class to handle all control events.

      CLASS lcl_event_handler DEFINITION.

      PUBLIC SECTION.

      METHODS:

      handle_autorefresh FOR EVENT finished

      OF cl_gui_timer.

      ENDCLASS. "lcl_event_handler DEFINITION

      CLASS lcl_event_handler IMPLEMENTATION.

      METHOD handle_autorefresh.

      • Do the refresh

      CALL METHOD refresh_timer->run

      EXCEPTIONS

      OTHERS = 0.

      ENDMETHOD. "handle_autorefresh

      ENDCLASS. "lcl_event_handler

      As already posted from Gerwin and Thomas, it could happen that the event get lost. Therefor I have an additional form in my program that restarts the time. The form is called during PBO of my main screen and after all system events.

      Hope it helps,

      Oliver