Chinaunix首页 | 论坛 | 博客
  • 博客访问: 688345
  • 博文数量: 194
  • 博客积分: 7067
  • 博客等级: 少将
  • 技术积分: 2008
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-09 14:48
个人简介

我很好

文章分类

全部博文(194)

文章存档

2019年(1)

2018年(1)

2017年(3)

2015年(2)

2012年(2)

2011年(1)

2010年(27)

2009年(15)

2008年(142)

分类: WINDOWS

2009-09-18 17:22:55

REPORT z_alv_auto_refresh.
*>*********************************************************************
* This report displays User's info (SM04) using the FM :              *
* REUSE_ALV_GRID_DISPLAY                                              *
* The list is auto-refreshed (refresh time : 5 seconds)               *
*---------------------------------------------------------------------*
TYPE-POOLS: slis.                      " ALV Global Types
DATA :
  gt_user LIKE uinfo OCCURS 0 WITH HEADER LINE. " User info in SM04

class lcl_receiver definition.
  public section.
    methods:
      handle_finished for event finished of cl_gui_timer.
endclass.

class lcl_receiver implementation.
method handle_finished.
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = '&NTE'.
endmethod.
endclass.

data:
  test       type i,
  receiver   type ref to lcl_receiver,
  timer      type ref to cl_gui_timer.

*---------------------------------------------------------------------*
START-OF-SELECTION.
  create object timer.
  create object receiver.
  set handler receiver->handle_finished for timer.
  timer->interval = 5.
  PERFORM f_read_data.
  PERFORM f_display_data.
*---------------------------------------------------------------------*
*       Form  F_LIRE_DATA
*---------------------------------------------------------------------*
FORM f_read_data.
  REFRESH gt_user.
* Get User's info
  CALL FUNCTION 'THUSRINFO'
       TABLES
            usr_tabl = gt_user.
* Wait in a task
  call method timer->run.
ENDFORM.                               " F_READ_DATA
*---------------------------------------------------------------------*
*      Form  F_DISPLAY_DATA
*---------------------------------------------------------------------*
FORM f_display_data.
  DEFINE m_sort.
    add 1 to ls_sort-spos.
    ls_sort-fieldname = &1.
    append ls_sort to lt_sort.
  END-OF-DEFINITION.

  DEFINE m_event_exit.
    clear ls_event_exit.
    ls_event_exit-ucomm = &1.
    ls_event_exit-after = 'X'.
    append ls_event_exit to lt_event_exit.
  END-OF-DEFINITION.

  DATA :
    ls_layout     TYPE slis_layout_alv,
    lt_sort       TYPE slis_t_sortinfo_alv,
    ls_sort       TYPE slis_sortinfo_alv,
    lt_event_exit TYPE slis_t_event_exit,
    ls_event_exit TYPE slis_event_exit.
* Build Sort Table
  m_sort 'ZEIT'.
* Build Event Exit Table
  m_event_exit '&NTE'.                 " Refresh
  ls_layout-zebra = 'X'.
  ls_layout-colwidth_optimize = 'X'.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            i_callback_program      = sy-cprog
            i_callback_user_command = 'USER_COMMAND'
            is_layout               = ls_layout
            i_structure_name        = 'UINFO'
            it_sort                 = lt_sort
            it_event_exit           = lt_event_exit
       TABLES
            t_outtab                = gt_user.
ENDFORM.                               " F_DISPLAY_DATA
*---------------------------------------------------------------------*
*       FORM USER_COMMAND                                             *
*---------------------------------------------------------------------*
FORM user_command USING i_ucomm     TYPE syucomm
                        is_selfield TYPE slis_selfield.     "#EC CALLED
  CASE i_ucomm.
    WHEN '&NTE'.
      PERFORM f_read_data.
      is_selfield-refresh = 'X'.
      call method timer->run.
  ENDCASE.
ENDFORM.                               " USER_COMMAND

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/CompassButton/archive/2009/07/30/4393977.aspx

阅读(1049) | 评论(0) | 转发(0) |
0

上一篇:虚拟项目设想

下一篇:ZMASSDOWNLOAD

给主人留下些什么吧!~~