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

ABAP Quick - CL_GUI_TIMER

2548

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.

Advertising


Our first Quick tip 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.

 

CL_GUI_TIMER

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 lcl_app DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS: handle_finished FOR EVENT finished OF cl_gui_timer.
ENDCLASS.

" 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.

 

Conclusion

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 useful thing out of the box.


Included topics:
QuickCL_GUI_TIMER
Comments (0)



And further ...

Are you satisfied with the content of the article? We post new content in the ABAP area every Tuesday and Friday and irregularly in all other areas. Take a look at our tools and apps, we provide them free of charge.


052: 10 Minutes from Start to Launchpad

Category - YouTube

In this episode, we'll look at how we can create a RAP application within 10 minutes, generate and deploy it, and finally launch it in the Launchpad.

09/07/2026

ABAP in Practice - Creating a Setup App

Category - ABAP

No more SAP GUI? How do we then create a static setup app while still remaining flexible on the ABAP side for further implementation? Here's a practical example.

08/28/2026

DDIC of the Future (Comparison)

Category - ABAP

What does the future hold for the DDIC, and can we already use the new features today? In this article, we compare the world of today with that of tomorrow and show you where to find all the features.

07/03/2026

DDIC of the Future (Tomorrow)

Category - ABAP

What does the future hold for the DDIC, and can we already use its new features today? In this article, we'll take a look at tomorrow and how CDS artifacts can help us with modeling.

06/30/2026

DDIC of the Future (Today)

Category - ABAP

What does the future hold for the DDIC, and can we already use the new features today? In this article, we'll look at the current state of the dictionary in ABAP.

06/26/2026