ABAP在ALV工具栏显示一个计时器
生活随笔
收集整理的這篇文章主要介紹了
ABAP在ALV工具栏显示一个计时器
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
| 其實(shí)就是調(diào)用一個(gè)類,刷新不斷ALV界面,下面是來自Sariel的一段代碼: *&---------------------------------------------------------------------* |
*&---------------------------------------------------------------------*
TYPE-POOLS slis.
CLASS lcl_timer_receiver DEFINITION DEFERRED.
DATA: BEGIN OF gt_data OCCURS 0,
? ? ? ? flag TYPE string,
? ? ? END OF gt_data.
DATA: gv_text ? ? ? ?TYPE smp_dyntxt.
DATA: go_timer ? ? ? TYPE REF TO cl_gui_timer,
? ? ? go_timer_event TYPE REF TO lcl_timer_receiver.
*----------------------------------------------------------------------*
* ? ? ? CLASS lcl_timer_receiver DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_timer_receiver DEFINITION.
? PUBLIC SECTION.
? ? METHODS handle_finished FOR EVENT finished OF cl_gui_timer.
? PRIVATE SECTION.
? ? DATA: lv_mod TYPE i,
? ? ? ? ? lv_int TYPE i,
? ? ? ? ? lv_hh ?TYPE numc2,
? ? ? ? ? lv_mm ?TYPE numc2,
? ? ? ? ? lv_ss ?TYPE numc2.
ENDCLASS. ? ? ? ? ? ? ? ? ? ?"lcl_timer_receiver DEFINITION
*----------------------------------------------------------------------*
* ? ? ? CLASS lc_timer_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_timer_receiver IMPLEMENTATION.
? METHOD handle_finished.
? ? CALL METHOD go_timer->run.
? ? lv_int = lv_int + 1.
? ? lv_ss = lv_int MOD 60.
? ? IF lv_int MOD 60 EQ 0.
? ? ? lv_mm = lv_mm + 1.
? ? ? lv_ss = 0.
? ? ENDIF.
? ? IF lv_int MOD 3600 EQ 0 .
? ? ? lv_hh = lv_hh + 1.
? ? ? lv_mm = 0.
? ? ? lv_ss = 0.
? ? ENDIF.
? ? gv_text-text = lv_hh && ':' && lv_mm && ':' && lv_ss.
? ENDMETHOD. ? ? ? ? ? ? ? ? ? ?"HANDLE_FINISHED
ENDCLASS. ? ? ? ? ? ? ? ? ? ?"lc_timer_receiver IMPLEMENTATION
*&---------------------------------------------------------------------*
*& ? ? ?Event ?INITIALIZATION
*&---------------------------------------------------------------------*
INITIALIZATION.
? gv_text-text = '00:00:00'.
*&---------------------------------------------------------------------*
*& ? ? ?Event ?START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
? PERFORM frm_dsp_alv.
*&---------------------------------------------------------------------*
*& ? ? ?Form ?FRM_DSP_ALV
*&---------------------------------------------------------------------*
FORM frm_dsp_alv .
? DATA: lt_fcat ? TYPE slis_t_fieldcat_alv,
? ? ? ? ls_fcat ? TYPE slis_fieldcat_alv,
? ? ? ? ls_layo ? TYPE slis_layout_alv,
? ? ? ? lt_events TYPE slis_t_event,
? ? ? ? ls_events TYPE slis_alv_event.
? gt_data-flag = 'SAP顧問圈'.
? APPEND gt_data.
? gt_data-flag = 'bbs.sapclub.cc'.
? APPEND gt_data.
? ls_fcat-fieldname = ls_fcat-seltext_s = 'FLAG'.
? APPEND ls_fcat TO lt_fcat.
? ls_events-name = slis_ev_caller_exit_at_start. ?"= CALLER_EXIT
? ls_events-form = slis_ev_caller_exit_at_start.
? APPEND ls_events TO lt_events.
? CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
? ? EXPORTING
? ? ? i_callback_program ? ? ? = sy-repid
? ? ? i_callback_pf_status_set = slis_ev_pf_status_set ?"= PF_STATUS_SET
? ? ? is_layout ? ? ? ? ? ? ? ?= ls_layo
? ? ? it_fieldcat ? ? ? ? ? ? ?= lt_fcat
? ? ? it_events ? ? ? ? ? ? ? ?= lt_events
? ? TABLES
? ? ? t_outtab ? ? ? ? ? ? ? ? = gt_data
? ? EXCEPTIONS
? ? ? program_error ? ? ? ? ? ?= 1
? ? ? OTHERS ? ? ? ? ? ? ? ? ? = 2.
ENDFORM. ? ? ? ? ? ? ? ? ? ?" FRM_DSP_ALV
*&---------------------------------------------------------------------*
*& ? ? ?Form ?CALLER_EXIT
*&---------------------------------------------------------------------*
FORM caller_exit USING u_exit TYPE slis_data_caller_exit.
? CREATE OBJECT: go_timer, go_timer_event.
? SET HANDLER go_timer_event->handle_finished FOR go_timer.
? go_timer->interval = 1.
ENDFORM. ? ? ? ? ? ? ? ? ? ?"CALLER_EXIT
*&---------------------------------------------------------------------*
*& ? ? ?Form ?SET_PF_STATUS
*&---------------------------------------------------------------------*
FORM pf_status_set USING t_extab TYPE slis_t_extab.
? CALL METHOD go_timer->run.
? SET PF-STATUS 'PFLIST' EXCLUDING t_extab.
ENDFORM. ? ? ? ? ? ? ? ? ? ?" SET_PF_STATUS
ALV工具欄請注意:
1、復(fù)制標(biāo)準(zhǔn)工具欄請參考:ALV報(bào)表復(fù)制程序標(biāo)準(zhǔn)工具欄
2、一定要定義成動(dòng)態(tài)功能文本,GV_TEXT
總結(jié)
以上是生活随笔為你收集整理的ABAP在ALV工具栏显示一个计时器的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 浅谈SAP CRM开发——基本业务概念
- 下一篇: Neo4j 简介