Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7202699
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

2009-06-22 19:45:11

REPORT  z_send_message NO STANDARD PAGE HEADING LINE-SIZE 120 .
 
INCLUDE .
 
DATA: BEGIN OF usr_tabl OCCURS 0.
        INCLUDE STRUCTURE uinfo.
DATA: END OF usr_tabl.
DATA: l_length        TYPE i,
      t_abaplist      LIKE abaplist OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF t_user OCCURS 0,
        counter     TYPE i,
        selection   TYPE c,
        mandt       LIKE sy-mandt,
        bname       LIKE sy-uname,
        name_first  LIKE v_adrp_cp-name_first,
        name_last   LIKE v_adrp_cp-name_last,
        department  LIKE v_adrp_cp-department,
        tel_number  LIKE v_adrp_cp-tel_number,
      END OF t_user .
DATA: l_client        LIKE sy-mandt,
      l_userid        LIKE uinfo-bname,
      l_opcode        TYPE x,
      l_funct_code(1) TYPE c,
      l_test(200)     TYPE c.
l_opcode = 2.
CALL 'ThUsrInfo' ID 'OPCODE' FIELD l_opcode
                 ID 'TAB' FIELD usr_tabl-*sys* .
CLEAR t_user.
REFRESH t_user.
LOOP AT usr_tabl.
  t_user-mandt = usr_tabl-mandt.
  t_user-bname = usr_tabl-bname.
  APPEND t_user.
ENDLOOP.
SORT t_user.
DELETE ADJACENT DUPLICATES FROM t_user.
LOOP AT t_user.
  t_user-counter = sy-tabix.
  SELECT v~name_first
         v~name_last
         v~department
         v~tel_number
      INTO (t_user-name_first,
            t_user-name_last,
            t_user-department,
            t_user-tel_number)
      FROM usr21 AS u
          JOIN v_adrp_cp AS v
            ON u~persnumber = v~persnumber AND
               u~addrnumber = v~addrnumber
      WHERE u~bname = t_user-bname.
  ENDSELECT.
  MODIFY t_user.
ENDLOOP.
SORT t_user BY department name_last.
PERFORM display_list.
TOP-OF-PAGE.
  PERFORM display_menu.
* End of top-of-page
TOP-OF-PAGE DURING LINE-SELECTION .
  PERFORM display_menu.
* End of top-of-page during line-selection
AT LINE-SELECTION.
  IF sy-curow = 2.
    IF sy-cucol < 19.
      t_user-selection = 'X'.
      MODIFY t_user TRANSPORTING selection WHERE selection = ''.
      PERFORM display_list.
    ELSEIF sy-cucol < 36.
      CLEAR t_user-selection.
      MODIFY t_user TRANSPORTING selection WHERE selection = 'X'.
      PERFORM display_list.
    ELSEIF sy-cucol < 50.
      PERFORM transfer_selection.
      PERFORM popup_msg.
    ELSEIF sy-cucol < 67.
      PERFORM transfer_selection.
      SORT t_user BY name_last.
      PERFORM display_list.
    ELSEIF sy-cucol < 81.
      PERFORM transfer_selection.
      SORT t_user BY name_first.
      PERFORM display_list.
    ELSEIF sy-cucol < 93.
      PERFORM transfer_selection.
      SORT t_user BY mandt.
      PERFORM display_list.
    ENDIF.
  ENDIF.
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_LIST
*&---------------------------------------------------------------------*
FORM display_list.
  sy-lsind = 0.
  FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
  LOOP AT t_user.
    WRITE: / sy-vline, t_user-selection AS CHECKBOX,
             sy-vline, t_user-mandt,
             sy-vline, t_user-bname,
             sy-vline, t_user-name_first(15),
             sy-vline, t_user-name_last(15),
             sy-vline, t_user-department(20),
             sy-vline, t_user-tel_number(20), sy-vline.
    HIDE: t_user-counter, t_user-selection.
  ENDLOOP.
  FORMAT COLOR OFF.
  WRITE: /(108) sy-uline.
ENDFORM.                    " DISPLAY_LIST
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_MENU
*&---------------------------------------------------------------------*
FORM display_menu.
  FORMAT COLOR COL_HEADING HOTSPOT.
  WRITE:   (91) sy-uline,
     / sy-vline NO-GAP, (4) icon_select_all NO-GAP,    '选择全部  ',
       sy-vline NO-GAP, (4) icon_deselect_all NO-GAP,  '全部不选择  ',
       sy-vline NO-GAP, (4) icon_short_message NO-GAP, '发送消息  ',
       sy-vline NO-GAP, (4) icon_sort_up NO-GAP, 'Last Name' NO-GAP,
       sy-vline NO-GAP, (4) icon_sort_up NO-GAP, 'First Name' NO-GAP,
       sy-vline NO-GAP, (4) icon_sort_up NO-GAP, 'Client' NO-GAP,
       sy-vline,
     /(91) sy-uline,
     /(108) sy-uline.
  FORMAT HOTSPOT OFF.
  WRITE: / sy-vline, ' ',
           sy-vline, 'Cli',
           sy-vline, 'User        ',
           sy-vline, 'First Name     ',
           sy-vline, 'Last Name      ',
           sy-vline, 'Department          ',
           sy-vline, 'Telephone           ',
           sy-vline,
         /(108) sy-uline.
  FORMAT COLOR OFF.
ENDFORM.                    " DISPLAY_MENU
*&---------------------------------------------------------------------*
*&      Form  TRANSFER_SELECTION
*&---------------------------------------------------------------------*
FORM transfer_selection.
  DO.
    READ LINE sy-index FIELD VALUE t_user-selection.
    IF sy-subrc <> 0.
      EXIT.
    ENDIF.
    MODIFY t_user TRANSPORTING selection
           WHERE counter = t_user-counter.
  ENDDO.
  CLEAR t_user.
ENDFORM.                    " TRANSFER_SELECTION
*&---------------------------------------------------------------------*
*&      Form  POPUP_MSG
*&---------------------------------------------------------------------*
FORM popup_msg.
  DATA: l_msg      LIKE sm04dic-popupmsg VALUE 'Experimental Message',
        l_len      TYPE i,
        l_ret      TYPE c.
  LOOP AT t_user WHERE selection = 'X'.
    PERFORM get_message CHANGING l_msg l_ret.
    EXIT.
  ENDLOOP.
  IF l_ret = 'A'.            "User cancelled the message
    EXIT.
  ENDIF.
*   Get the message text
  l_len = STRLEN( l_msg ).
  LOOP AT t_user WHERE selection = 'X'.
    CALL FUNCTION 'TH_POPUP'
         EXPORTING
              client         = t_user-mandt
              user           = t_user-bname
              MESSAGE        = l_msg
              message_len    = l_length
*                     CUT_BLANKS     = ' '
         EXCEPTIONS
              user_not_found = 1
              OTHERS         = 2.
    IF sy-subrc <> 0.
      WRITE: 'User ', t_user-bname, 'not found.'.
    ENDIF.
  ENDLOOP.
  IF sy-subrc <> 0.
*       Big error! No user has been selected.
    MESSAGE ID 'AT' TYPE 'E' NUMBER '315' WITH '至少选择一个用户!'.
    EXIT.
  ENDIF.
ENDFORM.                    " POPUP_MSG

*&---------------------------------------------------------------------*
*&      Form  GET_MESSAGE
*&---------------------------------------------------------------------*
FORM get_message CHANGING p_l_msg LIKE sm04dic-popupmsg
                          p_returncode TYPE c.
  DATA: BEGIN OF fields OCCURS 1.
          INCLUDE STRUCTURE sval.
  DATA: END OF fields,
        returncode TYPE c.
  fields-tabname = 'SM04DIC'.
  fields-fieldname = 'POPUPMSG'.
  fields-fieldtext = 'Message :'.
  CONCATENATE ' - Msg from' sy-uname '.' INTO fields-value SEPARATED BY ' '.
  APPEND fields.
  CALL FUNCTION 'POPUP_GET_VALUES'
    EXPORTING
      popup_title = 'Supply the popup message'
    IMPORTING
      returncode  = p_returncode
    TABLES
      fields      = fields.
  IF p_returncode = 'A'.
    EXIT.
  ELSE.
    READ TABLE fields INDEX 1.
    p_l_msg = fields-value.
  ENDIF.
ENDFORM.                    " GET_MESSAGE
阅读(3077) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~