zoukankan      html  css  js  c++  java
  • ABAP-利用定时器自动刷新屏幕

    *&---------------------------------------------------------------------*
    *& Report Y_XB_TEST1
    *&---------------------------------------------------------------------*
    *&
    *&---------------------------------------------------------------------*
    REPORT Y_XB_TEST1 NO STANDARD PAGE HEADING.
    
    CLASS lcl_event_handler DEFINITION DEFERRED.
    
    DATA: go_timer    TYPE REF TO cl_gui_timer,
    
          go_evt_hndl TYPE REF TO lcl_event_handler,
    
          gv_datum    TYPE sy-datum,
          gv_uzeit    TYPE sy-uzeit.
    
    *&---------------------------------------------------------------------*
    
    *&      START-OF-SELECTION
    
    *&---------------------------------------------------------------------*
    
    START-OF-SELECTION.
      gv_datum = sy-datum.
      gv_uzeit = sy-uzeit.
    
      PERFORM list_output.
    
      PERFORM init_timer.
    
    *&---------------------------------------------------------------------*
    
    *&      USER-COMMAND
    
    *&---------------------------------------------------------------------*
    
    AT USER-COMMAND.
    
      IF sy-ucomm = 'RFSH'.
        sy-lsind = sy-lsind - 1.
    
        PERFORM list_output.
      ENDIF.
    
    *&---------------------------------------------------------------------*
    
    *&      CLASS lcl_event_handler DEFINITION
    
    *&---------------------------------------------------------------------*
    
    CLASS lcl_event_handler DEFINITION.
    
      PUBLIC SECTION.
    
        METHODS:
    
          handle_timer FOR EVENT finished OF cl_gui_timer.
    
    ENDCLASS.                    "lcl_event_handler DEFINITION
    
    *&---------------------------------------------------------------------*
    
    *&      CLASS lcl_event_handler IMPLEMENTATION
    
    *&---------------------------------------------------------------------*
    
    CLASS lcl_event_handler IMPLEMENTATION.
    
      METHOD handle_timer.
    
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = 'RFSH'.
    
        CALL METHOD go_timer->run "必须重新激活定时器
          EXCEPTIONS
            OTHERS = 9.
    
      ENDMETHOD.                 "handle_timer
    
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    
    *&---------------------------------------------------------------------*
    
    *&      Form  INIT_TIMER
    
    *&---------------------------------------------------------------------*
    
    FORM init_timer.
    
      CHECK go_timer IS INITIAL.
    
      CREATE OBJECT go_timer
        EXCEPTIONS
          OTHERS = 9.
    
      CREATE OBJECT go_evt_hndl.
    
      SET HANDLER go_evt_hndl->handle_timer FOR go_timer.
    
    
      go_timer->interval = 5.  "设置间隔为10秒
    
      CALL METHOD go_timer->run "激活定时器
        EXCEPTIONS
          OTHERS = 9.
    
    ENDFORM.                    " INIT_TIMER
    *&---------------------------------------------------------------------*
    *& Form LIST_OUTPUT
    *&---------------------------------------------------------------------*
    *& text
    *&---------------------------------------------------------------------*
    *& -->  p1        text
    *& <--  p2        text
    *&---------------------------------------------------------------------*
    FORM list_output .
      DATA: datediff TYPE p,
            timediff TYPE p DECIMALS 2.
    
      datediff = sy-datum - gv_datum.
      timediff = ( sy-uzeit - gv_uzeit ) / 60.
    
      WRITE: /5 '本次开始时间:' ,AT 30 gv_datum , AT 45 gv_uzeit.
      WRITE: /5 '本次运行时长:' ,AT 30 datediff LEFT-JUSTIFIED,
                                  AT 38 '' ,
                                  at 45 timediff LEFT-JUSTIFIED ,
                                  AT 51 ''.
    
    ENDFORM.
  • 相关阅读:
    dinic模板
    ZOJ 3042 City Selection II 【序】【离散化】【数学】
    Codeforces 452D [模拟][贪心]
    Day25 python基础---面向对象进阶--模块与包
    Day22&23&24 python基础---面向对象进阶--常用模块
    Day21 python基础---面向对象进阶--内置方法
    Day19&20 python基础---面向对象进阶--装饰器函数,反射,内置方法
    Day18 python基础---面向对象三大特性---多态、封装
    Day17 python基础---面向对象三大特性---继承
    Day16 python基础---面向对象初识---组合
  • 原文地址:https://www.cnblogs.com/liangliang245916893/p/14265410.html
Copyright © 2011-2022 走看看