原理
タイマークラスCL_GUI_TIMERを使用して、継続的に呼び出します。手順は次のとおりです。
- タイマーをインスタンス化し、タイマーの終了イベントを監視します
- 選択出力で画面要素の属性と値を変更し、同時にタイマーの実行を開始します
- タイミングが終了すると、終了イベントがトリガーされ、機能コードを設定することにより、画面ロジックフローは再び選択出力に戻ります。
個人的な推測:カスタム画面とALVも定期的に更新でき、タイマーのサイクルとPBOのトリガーに使用できますが、いくつかの記事を読んだ後、このタイマークラスは不明な理由で推奨されていないようで、ALVはUI5開発ではありません。定期的に更新するのは面白くないと思います。それはかなりの鐘と笛です。
参照コード
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.