abap function


所属类别:ERP

文章作者:驰叙

特别推荐:免费发布信息 承包关键词~~抢爆了!HOT!


息化】 REPORT Z_SEND_POPUP NO STANDARD PAGE HEADING. include . * Global data decleration data: itab_uinfo like standard table of uinfo with header line. data: itab_send like standard table of uinfo with header line. data: box(1) TYPE c, lines TYPE i, w_text1 like sm04dic-popupmsg, w_text2 like sm04dic-popupmsg, message like SM04DIC-POPUPMSG.

start-of-selection.

set pf-status 'LIST'.

* Text which should be send to other users perform show_input_message.

* First, show all User which are in the system...perform show_loged_on_users.

lines = sy-linno - 1.

END-OF-SELECTION.

AT USER-COMMAND.

case sy-ucomm. when 'EXEC'.

* Determine Text read line 2 field value w_text1. w_text2 = w_text1.

DO lines TIMES. clear box. READ LINE sy-index FIELD VALUE box. IF box = 'X'. itab_send-bname = itab_uinfo-bname. itab_send-mandt = itab_uinfo-mandt. append itab_send.

endif. enddo. * Finally send message.... perform send_message.

when 'AUFF'.

* Text which should be send to other users perform show_input_message.

* First, show all User which are in the system... perform show_loged_on_users.

lines = sy-linno - 1. sy-lsind = sy-lsind - 1. when others. endcase.

*&---------------------------------------------------------------------* *& Form show_loged_on_users *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM show_loged_on_users.

* Get all loged on users perform get_loged_on_users.

* Combine to only GUI - Users perform combine_users.

* Show Users perform show_users_in_list.

ENDFORM. " show_loged_on_users *&---------------------------------------------------------------------* *& Form get_loged_on_users *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM get_loged_on_users.

data: itab_RFCHOSTS like standard table of RFCHOSTS with header line.

CALL FUNCTION 'RFC_GET_LOCAL_DESTINATIONS' TABLES LOCALDEST = itab_RFCHOSTS EXCEPTIONS NOT_AVAILABLE = 1 OTHERS = 2. IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.

loop at itab_RFCHOSTS.

CALL FUNCTION 'THUSRINFO' Destination itab_rfchosts TABLES USR_TABL = itab_UINFO EXCEPTIONS communication_failure = 17.

endloop.

ENDFORM. " get_loged_on_users *&---------------------------------------------------------------------* *& Form combine_users *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM combine_users.

data: itab_loc_uinfo like standard table of uinfo with header line.

itab_loc_uinfo[] = itab_uinfo[].

clear itab_uinfo. refresh itab_uinfo.

loop at itab_loc_uinfo. if itab_loc_uinfo-stat = '2' and "GUI - User itab_loc_uinfo-bname ne space. read table itab_uinfo with key mandt = itab_loc_uinfo-mandt bname = itab_loc_uinfo-bname. if sy-subrc ne 0. itab_uinfo = itab_loc_uinfo. append itab_uinfo. endif. endif. endloop.

* finaly sort... sort itab_uinfo by bname.

ENDFORM. " combine_users *&---------------------------------------------------------------------* *& Form show_users_in_list *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM show_users_in_list.

data: w_color type c,w_BAPIBNAME like BAPIBNAME-BAPIBNAME,w_BAPIADDR3 like BAPIADDR3.

data: itab_return like standard table of BAPIRET2.

loop at itab_uinfo. * First, Color Handling.... if w_color eq space. format color col_heading. w_color = 'X'. else. format color col_normal. w_color = space. endif.

* Get Additional Information to the user..

w_BAPIBNAME = itab_uinfo-bname.

CALL FUNCTION 'BAPI_USER_GET_DETAIL' EXPORTING USERNAME = w_BAPIBNAME IMPORTING ADDRESS = w_BAPIADDR3 TABLES RETURN = itab_return.

write : / ICON_HR_POSITION as icon, box as checkbox, itab_uinfo-mandt, itab_uinfo-bname, w_bapiaddr3-FULLNAME, at sy-linsz ' '. Hide: box, itab_uinfo-mandt, itab_uinfo-bname.

endloop.

ENDFORM. " show_users_in_list *&---------------------------------------------------------------------* *& Form show_input_message *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM show_input_message.

w_text1 = ' Enter text here'.

format color col_negative. WRITE : ICON_BW_RA_SETTING_ACTIVE as icon, 'Please fill in the text for Sending:', ICON_BW_RA_SETTING_ACTIVE as icon, at sy-linsz ' ' . WRITE / w_text1 INPUT ON.

ULINE.

ENDFORM. " show_input_message *&---------------------------------------------------------------------* *& Form send_message *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM send_message.

data: w_name like sy-uname, w_mandt like sy-mandt, w_icon1 like ICON-NAME, w_icon2 like ICON-NAME, w_icon3 like icon-name, w_success type c, w_succt(100) type c.

concatenate sy-uname ':' w_text2 into message.

loop at itab_send. w_name = itab_send-bname. w_mandt = itab_send-mandt.

CALL FUNCTION 'TH_POPUP' EXPORTING CLIENT = w_mandt USER = w_name MESSAGE = message * MESSAGE_LEN = 0 * CUT_BLANKS = ' ' EXCEPTIONS USER_NOT_FOUND = 1 OTHERS = 2 . IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

else.

w_success = 'X'.

endif.

endloop.

refresh itab_send. clear itab_send.

if w_success ne space.

w_icon1 = 'ICON_MANAGER'. w_icon2 = 'ICON_PM_INSERT'. w_icon3 = 'ICON_MESSAGE_INFORMATION_SMALL'.

concatenate sy-uname ':Your message has be send to the selected user(s)' into w_succt.

CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING TITLEBAR = 'Send Message to User' TEXT_QUESTION = w_succt TEXT_BUTTON_1 = 'Yes' ICON_BUTTON_1 = w_icon1 TEXT_BUTTON_2 = 'Yuhuu' ICON_BUTTON_2 = w_icon2 DISPLAY_CANCEL_BUTTON = ' ' POPUP_TYPE = w_icon3 * IMPORTING * ANSWER = * TABLES * PARAMETER = EXCEPTIONS TEXT_NOT_FOUND = 1 OTHERS = 2 . IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. endif. ENDFORM. " send_message

相关信息

· 巧妙配置Win2003自带mail服务器

· 用ASP与ADO查询Web数据库

· Windows平台下程序日志的设计和实现(下:代码)

· 下一代Windows Update








....

13514 65810