ABAP refresh the selection screen regularly

principle

Use the timer class CL_GUI_TIMER to call continuously, the steps are as follows

  • Instantiate the timer and monitor the finished event of the timer
  • Change the attributes and values ​​of screen elements at selection output, and start running the timer at the same time
  • When the timing is over, the finished event is triggered, and by setting the function code, the screen logic flow returns to at selection output again.

Personal guess : custom screens and ALVs can also be refreshed regularly, and can be used to cycle timers and trigger PBO; but after reading some articles, it seems that this timer class is not recommended for unknown reasons, and ALV is not a UI5 development. I don’t think it’s interesting to refresh on a regular basis, and it’s pretty bells and whistles.

Reference Code

parameters : p_time type i default 3.

class lcl_event definition.

  public section.

    methods m_timer_finished for event finished of cl_gui_timer.

endclass.
class lcl_event implementation.

  method m_timer_finished.

    "    cl_gui_cfw=>set_new_ok_code(
    "      exporting
    "        new_code = 'REFR').

    "触发新的屏幕逻辑流,实现屏幕刷新
    call function 'SAPGUI_SET_FUNCTIONCODE'
      exceptions
        others = 0.

  endmethod.                    "handle_finished

endclass.                    "lcl_event IMPLEMENTATION

initialization.

  data(lo_timer) = new cl_gui_timer( ).
  lo_timer->interval = 1.

  data(lo_event) = new lcl_event( ).
  set handler lo_event->m_timer_finished for lo_timer.

at selection-screen output.
  if lo_timer is bound.
    lo_timer->run( ).
    p_time = p_time - 1.
  endif.

  if p_time le 0.
    lo_timer->cancel( ).
  endif.

Guess you like

Origin blog.csdn.net/u012232542/article/details/106717321