Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

3 timers in one program

Former Member
0 Likes
814

Hello Experts!

I have a program which displays an ALV list on the screen and it is automatically update. For the update I use 3 timers with different intervals. The screen is updated regularly but after a while the timers with the shorter interval are kicked and are not working, only the timer with the biggest interval. I would like to know the followings: Why is this happening? Is there an way to work around it besides resetting the timers again? Thank you!

1 ACCEPTED SOLUTION
Read only

Clemenss
Active Contributor
0 Likes
768

Hi Erzsebet Pirk,

no, it should work.

Make sure the timers raise events registered with same object instance, i.e. some code experts create new grid instance with refresh.

Post relevant code lines!

Regards,

Clemens

4 REPLIES 4
Read only

Clemenss
Active Contributor
0 Likes
769

Hi Erzsebet Pirk,

no, it should work.

Make sure the timers raise events registered with same object instance, i.e. some code experts create new grid instance with refresh.

Post relevant code lines!

Regards,

Clemens

Read only

Former Member
0 Likes
768

Hi Clemens,

I do create new instance of ALV on the events of refresh, it is timer that gives me trouble. I use one class and 3 methods for the 3 different timers. Two of the methods checks the database for new entries for in different Z custom tables and updates the ALV list on the screen. The 3rd one refreshes the screen every 10 mins. This program runs 24/7.

The declaration and the definitions are the following:

class zmm1_requests_metdef definition.

public section.

methods:

handle_update_timer for event finished of cl_gui_timer importing sender,

handle_update_newentry for event finished of cl_gui_timer importing sender,

handle_update_wlan for event finished of cl_gui_timer importing sender.

endclass.

Data:

gr_event_handler type ref to zmm1_requests_metdef,

gv_guitimer type ref to cl_gui_timer,

gv_guitimer_newentry type ref to cl_gui_timer,

gv_guitimer_wlan type ref to cl_gui_timer,

gv_settime type i value 600,

gv_settime_newentry type i value 180,

gv_wlan_timer type ref to cl_gui_timer,

gv_wlanvalue type i value 20. "20 seconds timer

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

create object gr_event_handler.

create object: gv_guitimer, gv_guitimer_newentry, gv_guitimer_wlan.

gv_guitimer_newentry->interval = gv_settime_newentry.

gv_guitimer->interval = gv_settime.

gv_guitimer_wlan->interval = gv_wlanvalue.

set handler gr_event_handler->handle_update_newentry for gv_guitimer_newentry.

set handler gr_event_handler->handle_update_timer for gv_guitimer.

set handler gr_event_handler->handle_update_wlan for gv_guitimer_wlan.

call method gv_guitimer->run( ).

call method gv_guitimer_newentry->run( ).

call method gv_guitimer_wlan->run( ).

The methods contain the entry check subroutines and the display forms.

Thank you,

Erzsebet

Read only

Clemenss
Active Contributor
0 Likes
768

Hi Erzsebet,

OK according to your un-formatted code you create three object instances for the timers. Now where is the handler instantiated and what is the code of the handler metods?

At least for performance reasons you should not create new ALV instances if the structure of the table displayed does not change.

Please do not forget to format the code lines using the <> button above. Also use Preview tab before posting.

Regards,

Clemens

Read only

Former Member
0 Likes
768

Hi Clemenst!

The code for the methods are almost the same, but the entry check is different. See below:

method handle_update_newentry .
    if gv_update = '0'.
      gv_update = '1'.
      perform check_new_entry.
      if gv_newentry = '1'.
        if gv_subs_selektion-subd = 0201.
          perform display_whlists.
        call method gv_guitimer_newentry->run( ).
        elseif gv_subs_selektion-subd = 0202.
          perform display_productionlist.
          call method gv_guitimer_newentry->run( ).
        elseif gv_subs_selektion-subd = 0203.
          perform display_completelist.
          call method gv_guitimer_newentry->run( ).
        endif.
        gv_newentry = '0'.
        gv_update   = '0'.
      elseif gv_newentry = '0'.
        gv_update = '0'.
        call method gv_guitimer_newentry->run( ).
      endif.
    elseif gv_update = '1'.
      call method gv_guitimer_newentry->run( ).
    endif.
  endmethod.

Both only updates the internal table or the ALV if there is a new entry in the database. The handler first initiated after the first display and in the methods.

Thank you,

Betty

(it is easier)