cancel
Showing results for 
Search instead for 
Did you mean: 

Auto Refresh Report

Former Member
0 Kudos

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?

Accepted Solutions (0)

Answers (4)

Answers (4)

olivergrande
Associate
Associate
0 Kudos

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

Former Member
0 Kudos

Thanks for thoses Tips,

Will try it.

Regards,

Kor

gerwin_borkowsky
Explorer
0 Kudos

Hi,

the CL_GUI_TIMER has one (big) problem. The timer runs only for one time and then has to be started "manually" again. If you has opened a modal window (i.e. the detail popup of a alv grid) the event fired by the timer get lost.

Through that the event-handler can't start the timer again and the report won't be refreshed anymore.

Ciao

Gerwin

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

That is true. We actually opened an OSS problem with SAP on the issue. We were basicially told that this was the way the GUI/automation controller worked. If a modal window is up, any events that fire to the main window are lost. It's not so bad that you lose one timer event, but that you lose the opportunity to reset the timer. We actually ended up writting our own timer control in Visual Basic. This timer control resets itself on the frontend. So even if ABAP can't respond to a timer event, they will keep firing.

gerwin_borkowsky
Explorer
0 Kudos

Hi,

that was the answer I got and the way I solved this problem.

Former Member
0 Kudos

Thomas,

Would you mind posting the sample VB code on the forum? That is if its possible of course.

Kind Regards,

Francisco

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I'm not sure I can post the VB project files. The code is actually quite simple. I will see if I can summarize the details. However I am actually out of the office this week and next week. I will try and gather the details, but no promises until I am back in the office.

Former Member
0 Kudos

Thomas,

Please do take your time, it is not urgent per my part, I am just curious to know for when if I have to do this in the future.

Regards,

Francisco

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

<b>Shameless Self-Advertisement Alert!</b>

If you would like some content that may help you get started; I have a session that I gave at ASUG in 2002 that you might find interesting. It details how to write the ABAP Object Proxy for your ActiveX control. The following is a link to the presentation:

http://files.asug.com/asug/speaker_jung_session_1605.zip

If you have any problems getting to it, just post back here and I will e-mail it to you.

While on the topic of shameless plugs: if you like the presentation I gave at ASUG, why not vote for my SAPTechED presentation here on SDN. My presentation is on how to leverage your ABAP skills for Web development in the form of BSP.

Former Member
0 Kudos

Thanks Thomas!

I will review/vote for you.

kmoore007
Active Contributor
0 Kudos

Oliver,

Do you have an example of the Event Handle_autorefresh in your example of cl_gui_timer?

kmoore007
Active Contributor
0 Kudos

Oliver,

What would be an example of code for event_handler->handle_autorefresh?

Thanks

olivergrande
Associate
Associate
0 Kudos

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

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

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.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Yes, you are very much correct. I really meant that it would tie up a "dialog session". Thanks

Regards,

Rich Heilman

Former Member
0 Kudos

Dont know if this is any help but an example automatic refresh report can be found here: http://www.sapdevelopment.co.uk/reporting/rep_autorefresh.htm

Regards

MArt

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

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.

Former Member
0 Kudos

Hi,

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

regards

johannes

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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.