注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

XINBO'S SAP BLOG

你所浪费的今天,是昨天死去的人奢望的明天。你所厌恶的现在,是未来的你回不去的曾经

 
 
 

日志

 
 

向在线的人群发消息  

2009-06-13 11:51:13|  分类: REPORTING&&OTHER |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

*&---------------------------------------------------------------------*
*& Report  ZMESSAGE01
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZMESSAGE01 NO STANDARD PAGE HEADING.
INCLUDE <ICON>.

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,
            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,
            END OF T_USER,
            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
        INTO (T_USER-NAME_FIRST,
              T_USER-NAME_LAST,
              T_USER-DEPARTMENT)
        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 NAME_LAST NAME_FIRST.
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 < 16.
        T_USER-SELECTION = 'X'.
        MODIFY T_USER TRANSPORTING SELECTION WHERE SELECTION = ''.
        PERFORM DISPLAY_LIST.
    ELSEIF SY-CUCOL < 30.
        CLEAR T_USER-SELECTION.
        MODIFY T_USER TRANSPORTING SELECTION WHERE SELECTION = 'X'.
        PERFORM DISPLAY_LIST.
    ELSEIF SY-CUCOL < 45.
        PERFORM TRANSFER_SELECTION.
        PERFORM POPUP_MSG.
    ELSEIF SY-CUCOL < 54.
        PERFORM TRANSFER_SELECTION.
        SORT T_USER BY BNAME.
        PERFORM DISPLAY_LIST.
    ELSEIF SY-CUCOL < 62.
        PERFORM TRANSFER_SELECTION.
        SORT T_USER BY NAME_LAST.
        PERFORM DISPLAY_LIST.
    ELSEIF SY-CUCOL < 70.
        PERFORM TRANSFER_SELECTION.
        SORT T_USER BY MANDT.
        PERFORM DISPLAY_LIST.
    ENDIF.
  ENDIF.
* End of line-selection

*&---------------------------------------------------------------------*
*&      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_LAST(10),
             SY-VLINE, T_USER-NAME_FIRST(10),
             SY-VLINE, T_USER-DEPARTMENT(15),
             SY-VLINE.
    HIDE: T_USER-COUNTER, T_USER-SELECTION.
ENDLOOP.
FORMAT COLOR OFF.
WRITE: /(70) SY-ULINE.
ENDFORM.                    " DISPLAY_LIST

*&---------------------------------------------------------------------*
*&      Form  DISPLAY_MENU
*&---------------------------------------------------------------------*
FORM DISPLAY_MENU.
    FORMAT COLOR COL_HEADING HOTSPOT.
    WRITE:   (71) 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, '用户',
       SY-VLINE NO-GAP, (4) ICON_SORT_UP NO-GAP, '姓',
       SY-VLINE NO-GAP, (4) ICON_SORT_UP NO-GAP, '集团',
       SY-VLINE,
    /(71) SY-ULINE.
   FORMAT HOTSPOT OFF.
   WRITE: /(70) SY-ULINE.
   WRITE: / SY-VLINE, ' ',
            SY-VLINE, '集 ',
            SY-VLINE, '用户名      ',
            SY-VLINE, '姓        ',
            SY-VLINE, '名        ',
            SY-VLINE, '部门           ',
            SY-VLINE,
          /(70) 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
              'No user selected!'.
        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'
                  START_COLUMN    = 100
                  START_ROW       = 80
        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

  评论这张
 
阅读(615)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017