*&---------------------------------------------------------------------*
* & Report ztest
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
Report ztest.
* Report z_send_popup no standard page heading.
Include <icon>.
* 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 shocould be sent 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 shocould be sent 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.
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.
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 sent 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.
Endif.
Endif.
Endform. "send_message