This is a test message to test the length of the message box.
Quick - CL_TIMER
Created by Software-Heroes


Automated updating of lists, logs or status indicators? No problem for you with our little tip for a simple automation with a SAP standard class.

Our first Quicktipp should deal with the topic of automation of operations. Your user/customer wants to automate a log or a list of what he wants to use as a kind of cockpit? Not so easy in SAP without constantly pressing the Refresh button.

Luckily SAP implemented the CL_GUI_TIMER class, which is easy to use, as you will soon see. For this the following example:

" Create instance
DATA(lo_time) = NEW cl_gui_timer( ).

" Set timer 
lo_time->interval = 5.

" Start
lo_time->run( ).

We create a new instance of the class CL_GUI_TIMER and set the timer to 5 seconds. At the end we start the timer by calling the method RUN. But it's not that easy, because we forgot the most important part. What should actually happen at the end of the timer?

If you've already looked at the class, you'll find that it has an event that you need to register before you start the timer. For this you need a method that records the event and then you have to tell the instance the new created method.

" Definition example
    CLASS-METHODS: handle_finished FOR EVENT finished OF cl_gui_timer.

" Set handler
SET HANDLER handle_finished FOR lo_time.

When the event fires, the handle_finished method is executed. If the timer should start one more time then simply call the RUN method of the class and a new countdown will start.

If you want to cancel the timer before the end is reached, you can easily do it:

" Cancel timer
lo_time->cancel( ).

" Delete timer
lo_time->free( ).

At the end, the timer is aborted and the instance cleared.



With the class CL_GUI_TIMER you get a simple and clean way to automate a cockpit or just to update a screen with a check. Definitely a super usefull thing out of the box.

Included topics:
Comments (0)

ABAP - ALV still relevant in 2022?

Category - ABAP

Today the joking question, do we still need reports that generate ALV outputs in 2022? In this article, we want to look into this question.


ABAP in Change

Category - ABAP

The programming language ABAP has been changing for years and is being modernized in various concepts. In this article, we'll look at it in detail.


ABAP Quick - Clean Core

Category - ABAP

In this article something about Clean Core, what does it mean for the developer, what are the requirements and what do you have to pay attention to.


ABAP Quick - Processing in a new task

Category - ABAP

This tip is about asynchronous processing in a new process and what to look out for.


ABAP Quick - Convert JSON to internal

Category - ABAP

In this little tip, we'll go into how you can convert a JSON stream to an internal format and then use it properly.