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.
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.
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 a comment