PROCESS BEFORE OUTPUT.
*CALL SUBSCREEN GD_SUBSCREENAREA INCLUDING 'ZSAPTALK' '110'.
MODULE STATUS_0100_USERLIST.
MODULE STATUS_0100_TALK.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.PROCESS BEFORE OUTPUT.
* MODULE STATUS_0110.
*
PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0110.PROCESS BEFORE OUTPUT.
MODULE STATUS_0150.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0150.PROCESS BEFORE OUTPUT.
MODULE STATUS_0200.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0200.*......................................................................*
*: Report ZSAPTALK :*
*: Author SAPdev.co.uk :*
*:.....................................................................*
*: Description : :*
*:.............: :*
*: This program is part of a suit of programs which implement an :*
*: instant messaging service for the SAP environment. Allows users to :*
*: send and receive instant messages as well as leave messages for :*
*: offline users to pickup later :*
*: :*
*: Please visit www.sapdev.co.uk for further info :*
*:....................................................................:*
REPORT ZSAPMESSANGER NO STANDARD PAGE HEADING LINE-SIZE 150.
**
INCLUDE ZSAPTALKSCR. " Selection Screen
**
INCLUDE ZSAPTALKTOP. " global Data
**
INCLUDE ZSAPTALKO01. " PBO-Modules
**
INCLUDE ZSAPTALKI01. " PAI-Modules
**
INCLUDE ZSAPTALKF01. " FORM-Routines
**
***********************************************************************
*START-OF_SELECTION.
START-OF-SELECTION.
clear: gd_stoprfc. "reset rfc/refresh flag
* retrieve whether user was viewing friends or all online users
get parameter ID 'ZMESS' field p_friend.
* resett parameter ID's
perform set_parameter_id using 'ZMESSAGE' gd_stoprfc.
* set users status as online
perform set_status_online using 'X'.
* check if first execution of program(does not always work)
if sy-CALLD eq 'X'. "First execution
clear: gd_talkingto, gd_stoprfc.
perform get_users_filepath.
* Setup file path/name to store conversation files
perform setup_global_filenames.
else.
* Get who user is talking to and users file path
* (for when program calls itself to reset screen level index)
perform get_who_user_is_talking_too. "Called from within program
endif.
* retrieve users friends list
perform get_friends_list.
* retrieve all online users
perform get_all_users_online tables it_usrtab.
* build fieldcatalog
perform build_fieldcatalog.
* layout attributes
PERFORM build_layout.
* build hierarchy header
PERFORM build_hierarchy_header CHANGING gd_hierarchy_header.
* Build report title
PERFORM build_report_title USING gd_report_title gd_logo.
* variant attributes
PERFORM build_variant.
CALL SCREEN 100.
* CALL SCREEN 100 STARTING AT 10 20 ENDING AT 100 50.*INCLUDE ZSAPTALKF01
*&---------------------------------------------------------------------*
*& Include ZSAPTALKF01 *
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form CREATE_ALVTREE_CONTAINER
*&---------------------------------------------------------------------*
* Create container for alv-tree
*----------------------------------------------------------------------*
FORM create_alvtree_container.
gd_tree_container_name = 'CC_USERLIST'.
create object gd_custom_container
exporting
container_name = gd_tree_container_name
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
if sy-subrc <> 0.
message x208(00) with 'ERROR'.
endif.
ENDFORM. "create_alvtree_container
*&---------------------------------------------------------------------*
*& Form CREATE_OBJECT_IN_CONTAINER
*&---------------------------------------------------------------------*
* Create ALVtree control
*----------------------------------------------------------------------*
FORM create_object_in_container.
create object gd_userlist
exporting
parent = gd_custom_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = 'X'
no_html_header = ''
no_toolbar = ''
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
if sy-subrc <> 0.
message x208(00) with 'ERROR'.
endif.
ENDFORM. "create_object_in_container
*&---------------------------------------------------------------------*
*& Form CREATE_EMPTY_ALVTREE_CONTROL
*&---------------------------------------------------------------------*
* Create empty tree control
*----------------------------------------------------------------------*
FORM create_empty_alvtree_control.
* Create emty tree-control
CLEAR: it_emptytab.
REFRESH: it_emptytab.
CALL METHOD gd_userlist->set_table_for_first_display
EXPORTING
is_hierarchy_header = gd_hierarchy_header
it_list_commentary = gd_report_title
i_logo = gd_logo
* i_background_id = 'ALV_BACKGROUND'
i_save = 'A'
is_variant = gd_variant
CHANGING
it_outtab = it_emptytab "Must be empty
it_fieldcatalog = gd_fieldcat.
ENDFORM. " CREATE_EMPTY_ALVTREE_CONTROL
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
* Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
FORM build_fieldcatalog.
* Please not there are a number of differences between the structure of
* ALVtree fieldcatalogs and ALVgrid fieldcatalogs.
* For example the field seltext_m is replace by scrtext_m in ALVtree.
fieldcatalog-fieldname = 'BNAME'. "Field name in itab
fieldcatalog-scrtext_m = 'User ID'. "Column text
fieldcatalog-COLTEXT = 'User ID'. "Column Text
fieldcatalog-col_pos = 0. "Column position
fieldcatalog-outputlen = 30. "Column width
fieldcatalog-emphasize = 'X'. "Emphasize (X or SPACE)
fieldcatalog-key = 'X'. "Key Field? (X or SPACE)
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
* fieldcatalog-fieldname = 'DISNAME'. "Field name in itab
* fieldcatalog-scrtext_m = 'Name'. "Column text
* fieldcatalog-COLTEXT = 'Name'. "Column Text
* fieldcatalog-col_pos = 0. "Column position
* fieldcatalog-outputlen = 12. "Column width
* fieldcatalog-emphasize = 'X'. "Emphasize (X or SPACE)
* fieldcatalog-key = 'X'. "Key Field? (X or SPACE)
** fieldcatalog-do_sum = 'X'. "Sum Column?
** fieldcatalog-no_zero = 'X'. "Don't display if zero
* APPEND fieldcatalog TO gd_fieldcat.
* CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
* Build layout for ALV grid report
*----------------------------------------------------------------------*
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
* gd_layout-totals_only = 'X'.
* gd_layout-f2code = 'DISP'. "Sets fcode for when double
* "click(press f2)
* gd_layout-zebra = 'X'.
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text = 'helllllo'.
ENDFORM. " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form build_hierarchy_header
*&---------------------------------------------------------------------*
* build hierarchy-header-information
*----------------------------------------------------------------------*
* -->P_L_HIERARCHY_HEADER structure for hierarchy-header
*----------------------------------------------------------------------*
FORM build_hierarchy_header CHANGING
p_hierarchy_header TYPE treev_hhdr.
p_hierarchy_header-heading = 'User List'(013).
p_hierarchy_header-tooltip = 'User list'(014).
p_hierarchy_header-width = 30.
p_hierarchy_header-width_pix = ''.
ENDFORM. " build_hierarchy_header
*&---------------------------------------------------------------------*
*& Form BUILD_REPORT_TITLE
*&---------------------------------------------------------------------*
* Build table for ALVtree header
*----------------------------------------------------------------------*
* <-> p1 Header details
* <-> p2 Logo value
*----------------------------------------------------------------------*
FORM build_report_title CHANGING
pt_report_title TYPE slis_t_listheader
pa_logo TYPE sdydo_value.
DATA: ls_line TYPE slis_listheader,
ld_date(10) TYPE c.
* List Heading Line(TYPE H)
CLEAR ls_line.
ls_line-typ = 'H'.
* ls_line-key "Not Used For This Type(H)
ls_line-info = 'User Message Service'.
APPEND ls_line TO pt_report_title.
* Users name (Status Line- TYPE S)
ls_line-typ = 'S'.
ls_line-key = 'Name '.
ls_line-info = gd_myname.
APPEND ls_line TO pt_report_title.
* Status Line(TYPE S)
ld_date(2) = sy-datum+6(2).
ld_date+2(1) = '/'.
ld_date+3(2) = sy-datum+4(2).
ld_date+5(1) = '/'.
ld_date+6(4) = sy-datum(4).
ls_line-typ = 'S'.
ls_line-key = 'Date'.
ls_line-info = ld_date.
APPEND ls_line TO pt_report_title.
** Action Line(TYPE A)
* CLEAR ls_line.
* ls_line-typ = 'A'.
* CONCATENATE 'Report: ' sy-repid INTO ls_line-info SEPARATED BY space
.
* APPEND ls_line TO pt_report_title.
ENDFORM. "build_report_title
*&---------------------------------------------------------------------*
*& Form BUILD_VARIANT
*&---------------------------------------------------------------------*
* Build variant
*----------------------------------------------------------------------*
form build_variant.
* Set repid for storing variants
gd_variant-report = sy-repid.
endform. " BUILD_VARIANT
*&---------------------------------------------------------------------*
*& Form CREATE_ALVTREE_HIERARCHY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* Builds ALV tree display, (inserts nodes, subnodes etc)
*----------------------------------------------------------------------*
form create_alvtree_hierarchy.
data: ls_sflight type sflight,
lt_sflight type sflight occurs 0.
data: ld_ebeln_key type lvc_nkey,
ld_ebelp_key type lvc_nkey.
* clear: wa_usrtab.
* wa_usrtab-disname = 'Contacts'.
* perform add_user_node using wa_usrtab
* ''
* changing ld_ebeln_key.
If p_friend EQ ' '.
loop at it_messfriends into wa_messfriends
where friend ne sy-uname.
perform add_user_line using wa_messfriends
ld_ebeln_key
changing ld_ebelp_key.
endloop.
ELSE.
loop at it_usrtab into wa_usrtab
where bname ne sy-uname.
perform add_user_line using wa_usrtab
ld_ebeln_key
changing ld_ebelp_key.
endloop.
endif.
*{V2
*Add users who have sent messages
loop at it_messtab into wa_messtab.
wa_usrtab-bname = wa_messtab-FROMUSER.
perform add_user_line using wa_usrtab
ld_ebeln_key
changing ld_ebelp_key.
endloop.
*}V2
* calculate totals
call method gd_userlist->update_calculations.
* this method must be called to send the data to the frontend
call method gd_userlist->frontend_update.
endform. " CREATE_ALVTREE_HIERARCHY
*&---------------------------------------------------------------------*
*& Form ADD_EKKO_NODE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_WA_EKPO text
* -->P_0553 text
* <--P_EBELN_KEY text
*----------------------------------------------------------------------*
form add_user_node using ps_usrtab like wa_usrtab
value(p_relate_key)
changing p_node_key.
data: ld_node_text type lvc_value,
ls_sflight type sflight.
* Set item-layout
data: lt_item_layout type lvc_t_layi,
ls_item_layout type lvc_s_layi.
if not ps_usrtab-disname is initial.
ld_node_text = ps_usrtab-disname.
else.
ld_node_text = ps_usrtab-bname.
endif.
ls_item_layout-t_image = '@3P@'. "'@3Y@'.
* ls_item_layout-fieldname = gd_userlist->c_hierarchy_column_name.
* if ld_node_text EQ gd_talkingto.
* ls_item_layout-style =
* cl_gui_column_tree=>STYLE_EMPHASIZED_POSITIVE.
* else.
ls_item_layout-style = cl_gui_column_tree=>STYLE_DEFAULT.
* endif.
append ls_item_layout to lt_item_layout.
* Add node
call method gd_userlist->add_node
EXPORTING
i_relat_node_key = p_relate_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = ld_node_text
is_outtab_line = ps_usrtab
it_item_layout = lt_item_layout
IMPORTING
e_new_node_key = p_node_key.
endform. " ADD_USER_NODE
*---------------------------------------------------------------------*
* FORM WHEN_FINISHED *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> TASKNAME *
*---------------------------------------------------------------------*
form when_finished using taskname.
receive results from function 'Z_ENQUE_SLEEP'.
g_ref_from_timer = 'X'.
* Trigger an event to run the at user-command
set user-command 'FCT_R'.
ok_code = 'FCT_R'.
save_ok = 'FCT_R'.
* sy-ucomm = 'FCT_R'.
GET PARAMETER ID 'ZMESSAGE' field gd_stoprfc.
check gd_stoprfc is initial.
leave to screen 0.
* perform update_conversation using gd_talkingto.
endform. " WHEN_FINISHED
**&---------------------------------------------------------------------
*
**& Form ADD_EKPO_LINE
**&---------------------------------------------------------------------
*
** text
**----------------------------------------------------------------------
*
** -->P_WA_EKPO text
** -->P_LD_EBELN_KEY text
** <--P_LD_EBELP_KEY text
**----------------------------------------------------------------------
*
form add_user_line using ps_usrtab like wa_usrtab
value(p_relate_key)
changing p_node_key.
data: ld_node_text type lvc_value,
ls_sflight type sflight.
* Set item-layout
data: lt_item_layout type lvc_t_layi,
ls_item_layout type lvc_s_layi.
* Check if user has unread messages for contact
read table it_messtab into wa_messtab
with key fromuser = ps_usrtab-bname.
* If so display envolope icon next to contacts name
if sy-subrc eq 0.
ls_item_layout-t_image = '@E2@'.
delete it_messtab index sy-tabix. "V2
endif.
ls_item_layout-fieldname = gd_userlist->c_hierarchy_column_name.
ls_item_layout-style = cl_gui_column_tree=>style_default.
* Define display text for node
if not ps_usrtab-disname is initial.
ld_node_text = ps_usrtab-disname.
else.
ld_node_text = ps_usrtab-bname.
endif.
* Displaying friends list
if p_friend EQ ' '.
* Check if friend is online
read table it_usrtab into wa_usrtab
with key bname = ps_usrtab-bname.
if sy-subrc NE 0.
ls_item_layout-style = cl_gui_column_tree=>STYLE_INACTIVE.
concatenate ld_node_text '(offline)' into ld_node_text.
endif.
endif.
* Append node/item layout settings the layout table
append ls_item_layout to lt_item_layout.
* Add node to ALV tree
call method gd_userlist->add_node
EXPORTING
i_relat_node_key = p_relate_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = ld_node_text
is_outtab_line = ps_usrtab
it_item_layout = lt_item_layout
IMPORTING
e_new_node_key = p_node_key.
endform. " ADD_EKPO_LINE
*&---------------------------------------------------------------------*
*& Form register_events
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM register_events .
*&---------------------------------------------------------------------*
*& REGISTER_EVENTS
*&---------------------------------------------------------------------*
* define the events which will be passed to the backend
data: lt_events type cntl_simple_events,
l_event type cntl_simple_event.
* define the events which will be passed to the backend
l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>EVENTID_LINK_CLICK.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_double_click.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_header_click.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
append l_event to lt_events.
call method gd_userlist->set_registered_events
EXPORTING
events = lt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
if sy-subrc <> 0.
message x208(00) with 'ERROR'. "#EC NOTEXT
endif.
* set Handler
data: l_event_receiver type ref to lcl_tree_event_receiver.
create object l_event_receiver.
set handler l_event_receiver->handle_node_ctmenu_request
for gd_userlist.
set handler l_event_receiver->handle_node_ctmenu_selected
for gd_userlist.
set handler l_event_receiver->handle_item_ctmenu_request
for gd_userlist.
set handler l_event_receiver->handle_item_ctmenu_selected
for gd_userlist.
set handler l_event_receiver->handle_item_double_click
for gd_userlist.
set handler l_event_receiver->handle_link_click
for gd_userlist.
set handler l_event_receiver->handle_header_click
for gd_userlist.
set handler l_event_receiver->handle_item_keypress
for gd_userlist.
ENDFORM. " register_events
*&---------------------------------------------------------------------*
*& Form get_all_users_online
*&---------------------------------------------------------------------*
* Get all user currently online
*----------------------------------------------------------------------*
FORM get_all_users_online TABLES P_USR_TAB STRUCTURE it_USRTAB.
refresh: it_usrtab, it_allusers.
clear: it_usrtab, it_allusers.
call 'ThUsrInfo' id 'OPCODE' field OPCODE_LIST
id 'TAB' field it_allusers-*sys*.
wa_allusers-bname = sy-uname.
append wa_allusers to it_allusers.
sort it_allusers by bname.
delete adjacent duplicates from it_allusers comparing bname.
loop at it_allusers into wa_allusers.
move-corresponding wa_allusers to wa_usrtab.
select single disname
from zmessoptions
into wa_usrtab-disname
where uname eq wa_allusers-bname.
append wa_usrtab to it_usrtab.
clear: wa_usrtab.
endloop.
ENDFORM. " get_all_users_online
*&---------------------------------------------------------------------*
*& Form update_conversation
*&---------------------------------------------------------------------*
* Update conversation for selected contact
*----------------------------------------------------------------------*
FORM update_conversation USING P_TALKINGTO like sy-uname
p_task type c.
data: ld_node type LVC_NKEY.
data: ld_disname type ZMESSOPTIONS-disname.
data: ld_talkdisname type ZMESSOPTIONS-disname,
ld_subrc type sy-subrc,
ld_disurl(200) type c.
* if sy-xcode eq 'FCT_R'.
* break-point.
* endif.
if p_task EQ 'S'. "Stop
gd_stoprfc = 1.
SET PARAMETER ID 'ZMESSAGE' field gd_stoprfc.
endif.
if p_task EQ 'X' or p_task EQ 'U'.
* refresh User List
CALL METHOD gd_userlist->delete_all_nodes.
* get active messages
perform retrieve_unread_messages.
* create ALVtree Hierarchy
PERFORM create_alvtree_hierarchy.
***** CALL METHOD cl_gui_cfw=>flush.
* CALL METHOD gd_userlist->get_top_node
* IMPORTING
* e_node_key = ld_node.
* CALL METHOD gd_userlist->EXPAND_NODE
* EXPORTING
* I_NODE_KEY = ld_node.
endif.
GET PARAMETER ID 'ZMESSAGE' field gd_stoprfc.
if p_task EQ 'X' and gd_stoprfc is initial .
gd_task = gd_task + 1.
*** free memory.
*** SET UPDATE TASK LOCAL.
**********************
*Version 2, change
** Execute program asyncronously while still continuing following code
* call function 'Z_ENQUE_SLEEP'
* starting new task gd_task " 'WAIT'
* performing when_finished on end of task
* EXCEPTIONS
* COMMUNICATION_FAILURE = 1
* SYSTEM_FAILURE = 2
* RESOURCE_FAILURE = 3.
IF ti_container IS INITIAL.
CREATE OBJECT ti_container
EXPORTING container_name = 'TI_CONTAINER'.
CREATE OBJECT timer EXPORTING parent = ti_container.
SET HANDLER event_handler->on_finished FOR timer.
* 4) and start your timer
timer->interval = timeout.
CALL METHOD timer->run.
ENDIF.
if sy-subrc ne 0.
break-point.
endif.
endif.
IF gv_html_help_container IS INITIAL.
CREATE OBJECT gv_html_help_container
EXPORTING
container_name = 'CC_CONVERSATION'
EXCEPTIONS
others = 1.
CASE sy-subrc.
WHEN '0'.
* everything is fine here.
WHEN OTHERS.
RAISE cntl_error.
ENDCASE.
ENDIF.
IF gv_html_help IS INITIAL.
CREATE OBJECT gv_html_help
EXPORTING
parent = gv_html_help_container.
IF sy-subrc NE 0.
RAISE cntl_error.
ENDIF.
ENDIF.
* Registering for the events.
wa_events-eventid = gv_html_help->m_id_sapevent.
wa_events-appl_event = 'X'.
APPEND wa_events TO events.
* CALL METHOD gv_html_help->set_registered_events
* EXPORTING
* events = events.
* doc_url = 'C:/TEMP/TEST.TXT'.
if not gd_talkingto is initial.
* Retrieve users display name if one is setup
perform get_name_for_display changing ld_disname ld_talkdisname.
* Build html document for conversation window
perform populate_message_file using ld_disname ld_talkdisname
changing ld_subrc.
* Check new file has been created.
ld_disurl = gd_openurl.
CALL METHOD gv_html_help->show_data
EXPORTING
url = ld_disurl "doc_url
EXCEPTIONS
cntl_error = 1.
IF sy-subrc = 1.
RAISE cntl_error.
ENDIF.
endif.
* updates display box which shows user who they are talking too
perform update_whos_in_conversation using ld_talkdisname.
* call method cl_gui_cfw=>flush.
ENDFORM. " update_conversation
*&---------------------------------------------------------------------*
*& Form populate_message_file
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM populate_message_file using p_disname p_talkdisname
changing p_subrc.
data: ld_newmess type c.
DATA: e_file TYPE STRING.
clear: p_subrc, it_datatab, ld_newmess.
refresh it_datatab.
* Retrieve messages from current user
perform get_messages_from_user tables it_messtab.
* Generate HTML document
it_datatab-row = ''.
append it_datatab.
it_datatab-row = ''.
append it_datatab.
it_datatab-row = ''.
append it_datatab.
loop at it_messtab into wa_messtab.
if sy-uname eq wa_messtab-touser.
wa_messtab-torecieved = 'X'.
elseif sy-uname eq wa_messtab-fromuser.
wa_messtab-fromrecieved = 'X'.
endif.
if wa_messtab-fromuser EQ sy-uname.
concatenate
'<font color="#999999" size ="1" face="Times New Roman">'
p_disname
':</font> <font size ="2" face="Times New Roman">'
wa_messtab-message
'</font><br>'
into it_datatab-row.
else.
concatenate
'<font color="#999999" size ="1" face="Times New Roman">'
p_talkdisname
':</font> <font size ="2" face="Times New Roman">'
wa_messtab-message
'</font><br>'
into it_datatab-row.
endif.
* it_datatab-row = wa_messtab-message.
append it_datatab.
modify zmesstab from wa_messtab.
endloop.
if sy-subrc eq 0.
ld_newmess = 'X'.
it_datatab-row = '</body>'.
append it_datatab.
it_datatab-row = '</html>'.
append it_datatab.
endif.
read table it_messtalk into wa_messtalk
with key uname = gd_talkingto.
if sy-subrc ne 0 or ld_newmess eq 'X'.
perform download_conversation_file using gd_openurl 'X'
changing p_subrc.
endif.
ENDFORM. " populate_message_file
*&---------------------------------------------------------------------*
*& Form populate_table
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GD_TALKINGTO text
* -->P_SY_UNAME text
* -->P_SC_MESSAGE1 text
*----------------------------------------------------------------------*
FORM populate_table USING P_touser
P_fromuser
P_MESSAGE.
* select messnum
* up to 1 rows
* from zmesstab
* into wa_messtab-messnum
* where touser eq p_touser and
* fromuser eq p_fromuser
* order by messnum DESCENDING.
* endselect.
select messnum
up to 1 rows
from zmesstab
into wa_messtab-messnum
where ( touser eq p_touser and
fromuser eq p_fromuser ) or
( touser eq p_fromuser and
fromuser eq p_touser )
order by messnum DESCENDING.
endselect.
if sy-subrc eq 0.
wa_messtab-messnum = wa_messtab-messnum + 1.
else.
wa_messtab-messnum = 1.
endif.
clear: wa_messtab-torecieved, wa_messtab-fromrecieved.
wa_messtab-touser = P_touser.
wa_messtab-fromuser = p_fromuser.
wa_messtab-message = p_message.
insert zmesstab from wa_messtab.
* commit work.
ENDFORM. " populate_table
*&---------------------------------------------------------------------*
*& Form get_who_user_is_talking_too
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM get_who_user_is_talking_too .
data: ld_filepath like gd_filepath.
clear: ld_filepath, gd_ucomm.
select single talkingto filepath DISNAME ucomm
from zmessoptions
into (gd_talkingto,ld_filepath,gd_myname,gd_ucomm)
where uname eq sy-uname.
if not ld_filepath is initial.
gd_filepath = ld_filepath.
endif.
if gd_myname is initial.
gd_myname = sy-uname.
endif.
if not gd_ucomm is initial.
update zmessoptions set ucomm = ' '
where uname eq sy-uname.
endif.
* Setup file path/name to store conversation files
perform setup_global_filenames.
concatenate doc_url gd_talkingto '.HTM' into gd_openurl.
ENDFORM. " get_who_user_is_talking_too
*&---------------------------------------------------------------------*
*& Form initialise_conversation
*&---------------------------------------------------------------------*
* Sets up conversation with new contact
*----------------------------------------------------------------------*
FORM initialise_conversation .
* Processing for when user double clicks on ALVtree
DATA: ls_sflight TYPE sflight.
DATA: lt_selected_node TYPE lvc_nkey,
lt_fieldname TYPE lvc_fname.
DATA: l_selected_node TYPE lvc_nkey,
lt_outtab_line(100) TYPE c,
lt_node_text TYPE lvc_value,
ld_file type string,
ld_subrc type sy-subrc.
* DATA: lt_selected_node TYPE lvc_t_nkey.
* call method gd_userlist->select_nodes
* exporting
* node_key_table = lt_selected_node. "lt_sel_nodes.
clear: ld_subrc.
* Retrieve selected Node ID
CALL METHOD gd_userlist->get_selected_item
IMPORTING
e_selected_node = lt_selected_node
e_fieldname = lt_fieldname.
* Retrieve Selected Node + Row contents
CALL METHOD gd_userlist->get_outtab_line
EXPORTING
i_node_key = lt_selected_node
IMPORTING
e_outtab_line = lt_outtab_line
e_node_text = lt_node_text
EXCEPTIONS
NODE_NOT_FOUND = 1.
check sy-subrc eq 0.
gd_talkingto = lt_outtab_line+0(8).
SC_TALKINGTO = gd_talkingto.
* create blank file
concatenate doc_url gd_talkingto '.HTM' into gd_openurl.
refresh it_datatab.
** read table it_messtalk into wa_messtalk
** with key uname = gd_talkingto.
** if sy-subrc ne 0.
** perform download_conversation_file using gd_openurl ' '
** changing ld_subrc.
** endif.
if ld_subrc EQ 0.
update zmessoptions set talkingto = gd_talkingto
where uname eq sy-uname.
if sy-subrc ne 0.
wa_messopt-uname = sy-uname.
wa_messopt-talkingto = gd_talkingto.
modify zmessoptions from wa_messopt.
endif.
else.
clear: gd_talkingto.
endif.
ENDFORM. " initialise_conversation
*&---------------------------------------------------------------------*
*& Form update_whos_in_conversation
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM update_whos_in_conversation using p_disname .
IF gv_html_who_container IS INITIAL.
CREATE OBJECT gv_html_who_container
EXPORTING
container_name = 'CC_TALKINGTO'
EXCEPTIONS
others = 1.
CASE sy-subrc.
WHEN '0'.
* everything is fine here.
WHEN OTHERS.
RAISE cntl_error.
ENDCASE.
ENDIF.
IF gv_html_who IS INITIAL.
CREATE OBJECT gv_html_who
EXPORTING
parent = gv_html_who_container.
IF sy-subrc NE 0.
RAISE cntl_error.
ENDIF.
ENDIF.
* Registering for the events.
* wa_events-eventid = gv_html_who->m_id_sapevent.
* wa_events-appl_event = 'X'.
* APPEND wa_events TO events.
* CALL METHOD gv_html_help->set_registered_events
* EXPORTING
* events = events.
* doc_url = 'C:/TEMP/TEST.TXT'.
* create file to display whos in conversation
perform populate_talkingto_file using p_disname.
CALL METHOD gv_html_who->show_data
EXPORTING
url = who_url
EXCEPTIONS
cntl_error = 1.
IF sy-subrc = 1.
RAISE cntl_error.
ENDIF.
ENDFORM. " update_whos_in_conversation
*&---------------------------------------------------------------------*
*& Form populate_talkingto_file
*&---------------------------------------------------------------------*
* Create file with list of users in conversation
*----------------------------------------------------------------------*
FORM populate_talkingto_file using p_disname.
DATA: begin of it_datatab occurs 0,
row(500) type c,
end of it_datatab.
DATA: e_file TYPE STRING.
concatenate 'Conversation:' p_disname into it_datatab-row
separated by space.
append it_datatab.
e_file = who_url.
call function 'GUI_DOWNLOAD'
EXPORTING
filename = e_file
filetype = 'ASC'
TABLES
data_tab = it_datatab[]
EXCEPTIONS
file_open_error = 1
file_write_error = 2
others = 3.
ENDFORM. " populate_talkingto_file
*&---------------------------------------------------------------------*
*& Form retrieve_unread_messages
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM retrieve_unread_messages .
refresh: it_messtab.
select *
from zmesstab
into table it_messtab
where touser eq sy-uname and
torecieved eq ' '.
ENDFORM. " retrieve_unread_messages
*&---------------------------------------------------------------------*
*& Form add_buttons
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM add_buttons .
*&---------------------------------------------------------------------*
*& CHANGE_TOOLBAR
*&---------------------------------------------------------------------*
data: toolbar_event_receiver type ref to lcl_toolbar_event_receiver.
* get toolbar control
call method gd_userlist->get_toolbar_object
IMPORTING
er_toolbar = mr_toolbar.
check not mr_toolbar is initial.
call method mr_toolbar->delete_button
EXPORTING
fcode = '&CALC'.
call method mr_toolbar->delete_button
EXPORTING
fcode = '&LOAD'.
call method mr_toolbar->delete_button
EXPORTING
fcode = '&EXPAND'.
call method mr_toolbar->delete_button
EXPORTING
fcode = '&COLLAPSE'.
call method mr_toolbar->delete_button
EXPORTING
fcode = '&FIND'.
call method mr_toolbar->delete_button
EXPORTING
fcode = '&PRINT_BACK'.
* add seperator to toolbar
* CALL METHOD mr_toolbar->add_button
* EXPORTING
* fcode = ''
* icon = ''
* butn_type = cntb_btype_sep
* text = ''
* quickinfo = 'This is a Seperator'. "#EC NOTEXT
* add Standard Button to toolbar (for Delete Subtree)
call method mr_toolbar->add_button
EXPORTING
fcode = 'CONT'
icon = '@A0@'
butn_type = CNTB_BTYPE_DROPDOWN "cntb_btype_button
text = ''
quickinfo = 'Friends List'. "#EC NOTEXT
** add seperator to toolbar
* call method mr_toolbar->add_button
* exporting
* fcode = ''
* icon = ''
* butn_type = cntb_btype_sep
* text = ''
* quickinfo = 'This is a Seperator'. "#EC NOTEXT
*
** add Standard Button to toolbar (for Delete Subtree)
* call method mr_toolbar->add_button
* exporting
* fcode = 'DELETE' "Function code of button
* icon = '@18@' "Icon ID (see )
* butn_type = cntb_btype_button "Button type
* text = '' "Button text
* quickinfo = 'Delete subtree'. "Quick info text
*
** add Dropdown Button to toolbar (for Insert Line)
* call method mr_toolbar->add_button
* exporting
* fcode = 'INSERT_LC' "Function code of button
* icon = '@17@' "Icon ID (see )
* butn_type = cntb_btype_dropdown "Button type
* text = '' "Button text
* quickinfo = 'Insert Line'. "Quick info text
* set event-handler for toolbar-control
* data: toolbar_event_receiver type ref to lcl_toolbar_event_receiver.
create object toolbar_event_receiver.
set handler toolbar_event_receiver->on_function_selected
for mr_toolbar.
set handler toolbar_event_receiver->on_toolbar_dropdown
for mr_toolbar.
ENDFORM. " add_buttons
*&---------------------------------------------------------------------*
*& Form get_friends_list
*&---------------------------------------------------------------------*
FORM get_friends_list .
refresh: it_messfriends.
select friend
from zmessfriends
into corresponding fields of table it_messfriends
where uname eq sy-uname.
wa_messfriends-friend = sy-uname.
append wa_messfriends to it_messfriends.
loop at it_messfriends into wa_messfriends.
select single disname
from zmessoptions
into wa_messfriends-disname
where uname eq wa_messfriends-friend.
modify it_messfriends from wa_messfriends.
endloop.
ENDFORM. " get_friends_list
*&---------------------------------------------------------------------*
*& Form get_name_for_display
*&---------------------------------------------------------------------*
* Retrieve users display name if one is setup
*----------------------------------------------------------------------*
* <--P_DISNAME Name text for display purposes
*----------------------------------------------------------------------*
FORM get_name_for_display CHANGING P_DISNAME p_talkdisname.
If p_friend EQ ' '.
read table it_messfriends
into wa_messfriends with key FRIEND = gd_talkingto.
if sy-subrc eq 0 and not wa_messfriends-disname is initial.
p_talkdisname = wa_messfriends-disname.
else.
p_talkdisname = gd_talkingto.
endif.
read table it_messfriends
into wa_messfriends with key FRIEND = sy-uname.
if sy-subrc eq 0 and not wa_messfriends-disname is initial.
p_disname = wa_messfriends-disname.
else.
p_disname = sy-uname.
endif.
ELSE.
read table it_usrtab
into wa_usrtab with key BNAME = gd_talkingto.
if sy-subrc eq 0 and not wa_usrtab-disname is initial.
p_talkdisname = wa_usrtab-disname.
else.
p_talkdisname = gd_talkingto.
endif.
read table it_usrtab
into wa_usrtab with key BNAME = sy-uname.
if sy-subrc eq 0 and not wa_usrtab-disname is initial.
p_disname = wa_usrtab-disname.
else.
p_disname = sy-uname.
endif.
endif.
ENDFORM. " get_name_for_display
*&---------------------------------------------------------------------*
*& Form get_messages_from_user
*&---------------------------------------------------------------------*
* * Retrieve messages from current user
*----------------------------------------------------------------------*
* -->P_IT_MESSTAB text
*----------------------------------------------------------------------*
FORM get_messages_from_user TABLES P_MESSTAB STRUCTURE ZMESSTAB.
refresh p_messtab.
select *
from zmesstab
into table p_messtab
where ( touser eq sy-uname and
fromuser eq gd_talkingto ) or
( touser eq gd_talkingto and
fromuser eq sy-uname ).
loop at p_messtab into wa_messtab. " where recieved ne 'X'.
if wa_messtab-touser eq sy-uname and wa_messtab-torecieved EQ 'X'.
delete p_messtab.
if wa_messtab-fromrecieved eq 'X'.
DELETE zmesstab from wa_messtab.
endif.
endif.
if wa_messtab-fromuser eq sy-uname and
wa_messtab-fromrecieved EQ 'X'.
delete p_messtab.
* removed otherwise two users could try and delete same database entry
* if wa_messtab-torecieved eq 'X'.
* DELETE zmesstab from wa_messtab.
* endif.
endif.
endloop.
if sy-subrc ne 0.
refresh p_messtab.
endif.
sort p_messtab by messnum.
ENDFORM. " get_messages_from_user
*&---------------------------------------------------------------------*
*& Form display_feedback_html_text
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM display_feedback_html_text .
data: ld_disurl(200) type c.
IF gv_html_feedback_container IS INITIAL.
CREATE OBJECT gv_html_feedback_container
EXPORTING
container_name = 'CC_FEEDBACK'
EXCEPTIONS
others = 1.
CASE sy-subrc.
WHEN '0'.
* everything is fine here.
WHEN OTHERS.
RAISE cntl_error.
ENDCASE.
ENDIF.
IF gv_html_feedback IS INITIAL.
CREATE OBJECT gv_html_feedback
EXPORTING
parent = gv_html_feedback_container.
IF sy-subrc NE 0.
RAISE cntl_error.
ENDIF.
ENDIF.
* Build html document for conversation window
perform populate_feedback_file changing ld_disurl.
CALL METHOD gv_html_feedback->show_data
EXPORTING
* use if internet connection is available
url = 'www.sapdevelopment.co.uk/saptalk/feedback/feedback.htm'
* Use this if no internet connection is available
* url = ld_disurl
EXCEPTIONS
cntl_error = 1.
ENDFORM. " display_feedback_html_text
*&---------------------------------------------------------------------*
*& Form populate_feedback_file
*&---------------------------------------------------------------------*
FORM populate_feedback_file changing p_disurl .
DATA: begin of it_datatab occurs 0,
row(500) type c,
end of it_datatab.
DATA: e_file TYPE STRING.
* Generate HTML document
it_datatab-row = '<html>'.
append it_datatab.
it_datatab-row = '<head></head>'.
append it_datatab.
it_datatab-row = '<body bgcolor="#FFFFFF">'.
append it_datatab.
concatenate '<font size ="2" face="Times New Roman">'
'Any feedback regarding issues or development suggestions would<br>'
'be gratefully received.<br><br>'
'Please send to'
':</font> <font size ="2" face="Times New Roman">'
'<a HREF="mailto:webmaster@sapdev.co.uk">webmaster@sapdev.co.uk </a>'
'<br> Or visit website: '
'<a Target="MAIN" href="http:\\www.sapdev.co.uk">www.sapdev.co.uk</a>'
'</font><br>'
into it_datatab-row separated by space.
append it_datatab.
modify zmesstab from wa_messtab.
it_datatab-row = '</body>'.
append it_datatab.
it_datatab-row = '</html>'.
append it_datatab.
concatenate gd_filepath 'FEEDBACK.HTM' into p_disurl.
e_file = p_disurl .
call function 'GUI_DOWNLOAD'
EXPORTING
filename = e_file
filetype = 'ASC'
TABLES
data_tab = it_datatab[]
EXCEPTIONS
file_open_error = 1
file_write_error = 2
others = 3.
ENDFORM. " populate_feedback_file
*&---------------------------------------------------------------------*
*& Form set_parameter_id
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0027 text
* -->P_GD_STOPRFC text
*----------------------------------------------------------------------*
FORM set_parameter_id USING VALUE(P_PID)
P_value.
SET PARAMETER ID p_pid field p_value.
ENDFORM. " set_parameter_id
*&---------------------------------------------------------------------*
*& Form setup_global_filenames
*&---------------------------------------------------------------------*
FORM setup_global_filenames .
concatenate gd_filepath sy-uname into doc_url.
ENDFORM. " setup_global_filenames
*&---------------------------------------------------------------------*
*& Form download_conversation_file
*&---------------------------------------------------------------------*
FORM download_conversation_file USING P_FILE TYPE STRING
VALUE(P_APPEND)
CHANGING p_subrc.
DATA: rc TYPE sy-ucomm,
ld_file type rlgrap-filename.
if p_append eq 'X' or p_append eq ' ' .
call function 'GUI_DOWNLOAD'
EXPORTING
filename = p_file
filetype = 'ASC'
append = 'X'
TABLES
data_tab = it_datatab[]
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
if sy-subrc ne 0.
ld_file = p_file.
* CALL FUNCTION 'WS_DOWNLOAD'
* EXPORTING
** BIN_FILESIZE = ' '
** CODEPAGE = ' '
* FILENAME = ld_file
** FILETYPE = 'ASC'
** MODE = ' '
** WK1_N_FORMAT = ' '
** WK1_N_SIZE = ' '
** WK1_T_FORMAT = ' '
** WK1_T_SIZE = ' '
** COL_SELECT = ' '
** COL_SELECTMASK = ' '
** NO_AUTH_CHECK = ' '
** IMPORTING
** FILELENGTH =
* TABLES
* DATA_TAB = it_datatab[]
** FIELDNAMES =
* EXCEPTIONS
* FILE_OPEN_ERROR = 1
* FILE_WRITE_ERROR = 2
* INVALID_FILESIZE = 3
* INVALID_TYPE = 4
* NO_BATCH = 5
* UNKNOWN_ERROR = 6
* INVALID_TABLE_WIDTH = 7
* GUI_REFUSE_FILETRANSFER = 8
* CUSTOMER_ERROR = 9
* NO_AUTHORITY = 10
* OTHERS = 11.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
FILENAME = p_file
FILETYPE = 'ASC'
APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = it_datatab[]
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
IF SY-SUBRC <> 0.
message i000(zumess) with 'Error downloading file, Please check'
'file path in' 'user settings!'.
p_subrc = 4.
endif.
endif.
* Build list of active conversations
wa_messtalk-uname = gd_talkingto.
append wa_messtalk to it_messtalk.
* else.
** ld_file = p_file.
** CALL FUNCTION 'WS_QUERY'
** EXPORTING
** query = 'FE' "File Exist?
** filename = ld_file
** IMPORTING
** return = rc.
*
* IF rc NE 0. "If File alread exists
** perform download_conversation_file using p_file 'X' p_subrc.
* else.
* call function 'GUI_DOWNLOAD'
* EXPORTING
* filename = p_file
* filetype = 'ASC'
* append = 'X'
* TABLES
* data_tab = it_datatab[]
* EXCEPTIONS
* file_open_error = 1
* file_write_error = 2
* others = 3.
* if sy-subrc ne 0.
* message i000(zumess) with 'Error downloading file, Please check'
* 'file path in' 'user settings!'.
* p_subrc = 4.
* endif.
* endif.
endif.
ENDFORM. " download_conversation_file
*&---------------------------------------------------------------------*
*& Form get_users_filepath
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM get_users_filepath .
data: ld_filepath like gd_filepath.
clear: ld_filepath.
select single filepath DISNAME
from zmessoptions
into (ld_filepath,gd_myname)
where uname eq sy-uname.
if not ld_filepath is initial.
gd_filepath = ld_filepath.
endif.
if gd_myname is initial.
gd_myname = sy-uname.
endif.
ENDFORM. " get_users_filepath
*&---------------------------------------------------------------------*
*& Form set_status_online
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ONLINE Set whether user is online
*----------------------------------------------------------------------*
FORM set_status_online USING VALUE(P_ONLINE).
update zmessoptions set isonline = p_online
where uname eq sy-uname.
if sy-subrc ne 0.
wa_messopt-uname = sy-uname.
wa_messopt-isonline = p_online.
modify zmessoptions from wa_messopt.
endif.
ENDFORM. " set_status_online
*&---------------------------------------------------------------------*
*& Form send_popup_message_if_required
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM send_popup_message_if_required .
data: ld_isonline type c,
ld_message type SM04DIC-POPUPMSG.
* build popup message to send to user direct
ld_message = sc_message.
concatenate gd_talkingto 'says:' ld_message(57) into ld_message
separated by space.
concatenate ld_message '...' into ld_message.
if sy-tcode is initial.
concatenate ld_message
'(Please use transaction ZTALK to reply to this message)'
into ld_message separated by space.
else.
concatenate ld_message
'(Please use transaction' sy-tcode 'to reply to this message)'
into ld_message separated by space.
endif.
* check if user is online (logged into SAP)
read table it_usrtab with key bname = gd_talkingto.
if sy-subrc eq 0.
* check if user is logged into saptalk(executing program)
select single isonline
into ld_isonline
from zmessoptions
where uname eq gd_talkingto.
if ld_isonline ne 'X'.
* Send preview message
* call function 'WS_MSG'
* exporting msg_type = 'I' " 'I'-Info, 'A'-Alert, 'E'-Emergency
* text = ld_message
* titl = 'Message preview'(242).
* Send popup message to user.
CALL FUNCTION 'TH_POPUP'
EXPORTING
CLIENT = sy-mandt
USER = gd_talkingto
MESSAGE = ld_message
* MESSAGE_LEN = 0
* CUT_BLANKS = ' '
EXCEPTIONS
USER_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
ENDIF.
endif.
endif.
ENDFORM. " send_popup_message_if_required
*&---------------------------------------------------------------------*
*& Form recall_transaction
*&---------------------------------------------------------------------*
* reset all process by recalling transaction
*----------------------------------------------------------------------*
FORM recall_transaction USING VALUE(P_option).
case p_option.
when 'X'.
update zmessoptions set ucomm = sy-ucomm
where uname eq sy-uname.
leave to transaction 'ZTALK'.
when 'C'.
leave to transaction 'ZMESSCLEARUP'.
endcase.
ENDFORM. " recall_transaction
*&---------------------------------------------------------------------*
*& Form add_user_to_friends_list
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM add_user_to_friends_list .
DATA: lt_selected_node TYPE lvc_nkey,
lt_fieldname TYPE lvc_fname.
DATA: l_selected_node TYPE lvc_nkey,
lt_outtab_line(100) TYPE c,
lt_node_text TYPE lvc_value.
* ld_file type string,
* ld_subrc type sy-subrc.
* Retrieve selected Node ID
CALL METHOD gd_userlist->get_selected_item
IMPORTING
e_selected_node = lt_selected_node
e_fieldname = lt_fieldname.
* Retrieve Selected Node + Row contents
CALL METHOD gd_userlist->get_outtab_line
EXPORTING
i_node_key = lt_selected_node
IMPORTING
e_outtab_line = lt_outtab_line
e_node_text = lt_node_text
EXCEPTIONS
NODE_NOT_FOUND = 1.
check sy-subrc eq 0.
zmessfriends-uname = sy-uname.
zmessfriends-friend = lt_outtab_line+0(8).
modify zmessfriends.
ENDFORM. " add_user_to_friends_list
*&---------------------------------------------------------------------*
*& Form del_user_from_friends_list
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM del_user_from_friends_list .
DATA: lt_selected_node TYPE lvc_nkey,
lt_fieldname TYPE lvc_fname.
DATA: l_selected_node TYPE lvc_nkey,
lt_outtab_line(100) TYPE c,
lt_node_text TYPE lvc_value.
* ld_file type string,
* ld_subrc type sy-subrc.
* Retrieve selected Node ID
CALL METHOD gd_userlist->get_selected_item
IMPORTING
e_selected_node = lt_selected_node
e_fieldname = lt_fieldname.
* Retrieve Selected Node + Row contents
CALL METHOD gd_userlist->get_outtab_line
EXPORTING
i_node_key = lt_selected_node
IMPORTING
e_outtab_line = lt_outtab_line
e_node_text = lt_node_text
EXCEPTIONS
NODE_NOT_FOUND = 1.
check sy-subrc eq 0.
zmessfriends-uname = sy-uname.
zmessfriends-friend = lt_outtab_line+0(8).
delete zmessfriends.
delete it_messfriends where friend eq lt_outtab_line+0(8).
perform update_conversation using gd_talkingto 'U'.
ENDFORM. " del_user_from_friends_list
*&---------------------------------------------------------------------*
*& Form execute_user_command
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM execute_user_command .
if not gd_ucomm is initial.
CALL FUNCTION 'SAPGUI_SET_FUNCTIONCODE'
EXPORTING
FUNCTIONCODE = gd_ucomm
EXCEPTIONS
FUNCTION_NOT_SUPPORTED = 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.
clear: gd_ucomm.
endif.
ENDFORM. " execute_user_command*INCLUDE ZSAPTALKI01
*----------------------------------------------------------------------*
***INCLUDE ZMESSANGERI01 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
DATA: return TYPE REF TO cl_gui_event,
ld_output LIKE btcxpm OCCURS 0 WITH HEADER LINE.
* save_ok = ok_code.
case ok_code.
when 'EXIT' or 'BACK' or 'CANC'.
* Exit program
update zmessoptions set talkingto = ' '
where UNAME eq sy-uname.
* call clearup program to remove all created conversation files,
* also stops any refresh processing instantly
if not gd_talkingto is initial.
* call clearup tranasction (leave to trans...)
perform recall_transaction using 'C'.
else.
leave to screen 0.
endif.
when 'OPT'. "display users options/settings
leave to screen 200.
when 'FCT_R'. "RFC/refresh process
* automatic refresh of conversation window
if gd_task le 40. "changed from 10
perform update_conversation using gd_talkingto 'X'.
else.
* maximum screen calls reached!!! recall transaction to reset
clear gd_task.
SET PARAMETER ID 'ZMESS' field p_friend. "rememebr current opts
* recall tranasction (leave to trans...)
perform recall_transaction using 'X'.
endif.
when 'BSEND'. "send message to user
if gd_talkingto is initial.
* no user has be selected for conversation
message i000(zumess) with 'Please select a user to talk to!'.
else.
* set RFC/refresh process flag to stop while message is input
perform update_conversation using gd_talkingto 'S'.
if sy-xcode ne 'FCT_R'.
* Display popup via function module to allow user to input
* message text.
CALL FUNCTION 'Z_SEND_MESSAGE'
IMPORTING
MESSAGE = SC_MESSAGE
EXCEPTIONS
CANCELED = 1
OTHERS = 2.
IF SY-SUBRC EQ 0.
* populate message table with message
perform populate_table using gd_talkingto
sy-uname
SC_MESSAGE.
* set flag to restart refesh functionality
clear: gd_stoprfc.
SET PARAMETER ID 'ZMESSAGE' field gd_stoprfc.
* send popup mess if user is logged into SAP but not saptalk
perform send_popup_message_if_required.
perform update_conversation using gd_talkingto 'X'.
ENDIF.
clear: gd_stoprfc.
SET PARAMETER ID 'ZMESSAGE' field gd_stoprfc.
else.
* RFC(refresh process) and online process have got mixed up,
* reset by recalling transaction, Will lose users current input!
ok_code = 'BSEND'.
* recall tranasction (leave to trans...)
perform recall_transaction using 'X'.
endif.
endif.
when 'FEED'. "display feedback information
if sy-xcode ne 'FCT_R'.
CALL SCREEN 150 STARTING AT 10 10 ENDING AT 100 25.
else.
ok_code = ' '.
perform recall_transaction using 'X'.
endif.
when others. "there are no others but here it is anyway
* call method cl_gui_cfw=>get_current_event_object
* receiving
* event_object = return.
* call method cl_gui_cfw=>dispatch.
endcase.
CLEAR ok_code.
CALL METHOD cl_gui_cfw=>flush.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0150 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0150 INPUT.
save_ok = ok_code.
case ok_code.
when 'EXIT' or 'BACK' or 'CANC'.
leave to screen 0.
endcase.
ENDMODULE. " USER_COMMAND_0150 INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0200 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0200 INPUT.
save_ok = ok_code.
case ok_code.
when 'EXIT' or 'BACK' or 'CANC'.
leave to screen 100.
when 'SAVE' or 'OPT'.
wa_messopt-uname = sy-uname.
wa_messopt-disname = sc200_disnam.
wa_messopt-filepath = sc200_filepath.
modify zmessoptions from wa_messopt.
gd_filepath = sc200_filepath.
concatenate gd_filepath sy-uname into doc_url.
endcase.
ENDMODULE. " USER_COMMAND_0200 INPUT*INCLUDE ZSAPTALKO01
*----------------------------------------------------------------------*
***INCLUDE ZSAPTALKO01 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100_USERLIST OUTPUT.
SET PF-STATUS 'ULIST'.
SET TITLEBAR 'SC100'.
IF gd_userlist IS INITIAL.
* get active messages
perform retrieve_unread_messages.
* create container for alv-tree
PERFORM create_alvtree_container.
* create tree control
PERFORM create_object_in_container.
* create empty ALVtree control ready for first display
PERFORM create_empty_alvtree_control.
* create ALVtree Hierarchy
PERFORM create_alvtree_hierarchy.
* add buttons to alvtree
perform add_buttons.
* register user interaction events for ALV tree(i.e. double click)
perform register_events.
endif.
ENDMODULE. " STATUS_0100_USERLIST OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0150 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0150 OUTPUT.
SET PF-STATUS 'FEEDBACK'.
* SET TITLEBAR 'xxx'.
perform display_feedback_html_text.
ENDMODULE. " STATUS_0150 OUTPUT
*&---------------------------------------------------------------------*
*& Module CONVERSATION_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100_TALK OUTPUT.
if not gd_ucomm is initial.
perform execute_user_command.
else.
if not gd_talkingto is initial.
perform update_conversation using gd_talkingto 'X'.
else.
perform update_conversation using gd_talkingto ' '.
endif.
endif.
ENDMODULE. " STATUS_0100_TALK OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0200 OUTPUT.
SET PF-STATUS 'OPTIONS'.
SET TITLEBAR 'SC200'.
select single disname filepath
from zmessoptions
into (sc200_disnam,sc200_filepath)
where uname EQ sy-uname.
ENDMODULE. " STATUS_0200 OUTPUT*&---------------------------------------------------------------------*
*& Include ZMESSAGESCR *
*&---------------------------------------------------------------------*
Parameter: p_friend type c NO-DISPLAY MEMORY ID zmess.*INCLUDE ZSAPTALKTOP
*&---------------------------------------------------------------------*
*& Include ZMESSENGERTOP Module poo*
*& *
*&---------------------------------------------------------------------*
TYPE-POOLS: slis. "ALV Declarations
*TYPE-POOLS: icon.
TABLES: ZMESSTAB, ZMESSOPTIONS, zmessfriends.
DATA: ok_code like sy-ucomm, "OK-Code
save_ok like sy-ucomm,
SC_MESSAGE1(200) type c,
SC_MESSAGE type string,
gd_task(10) type N,
gd_myname type sy-uname,
gd_talkingto type sy-uname,
gd_filepath(200) type c VALUE 'C:\TEMP\CONV\',
doc_url(200) TYPE c,
who_url(200) TYPE c VALUE 'C:\TEMP\WHO.TXT',
gd_openurl TYPE string,
SC_TALKINGTO type sy-uname,
SC200_UNAME type sy-uname,
SC200_DISNAM(12) type c,
sc200_filepath(200) type c,
gd_stoprfc type c,
gd_test(10) type c.
*ALV data declarations
DATA: fieldcatalog TYPE lvc_t_fcat WITH HEADER LINE.
DATA: gd_fieldcat TYPE lvc_t_fcat,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv.
*ALVtree data declarations
CLASS cl_gui_column_tree DEFINITION LOAD.
CLASS cl_gui_cfw DEFINITION LOAD.
DATA: gd_userlist TYPE REF TO cl_gui_alv_tree,
gd_hierarchy_header TYPE treev_hhdr,
gd_report_title TYPE slis_t_listheader,
gd_logo TYPE sdydo_value,
gd_variant TYPE disvariant,
mr_toolbar type ref to cl_gui_toolbar.
*Create container for alv-tree
DATA: gd_tree_container_name(30) TYPE c,
gd_custom_container TYPE REF TO cl_gui_custom_container.
*table and work area to store and process all users
TYPES: BEGIN OF T_ALLUSRS.
INCLUDE STRUCTURE UINFO.
TYPES: END OF T_ALLUSRS.
DATA: it_allusers type standard table of T_ALLUSRS initial size 0
with header line,
wa_allusers type T_ALLUSRS.
*table and work area to store and process all users online
TYPES: BEGIN OF USR_TABL,
BNAME type UINFO-bname,
DISNAME type ZMESSOPTIONS-disname,
END OF USR_TABL.
DATA: it_usrtab type standard table of USR_TABL initial size 0
with header line,
it_emptytab type standard table of usr_tabl,
wa_usrtab type USR_TABL.
*table and work area to store and process user messages
TYPES: begin of t_messtab.
include structure ZMESSTAB.
types: end of t_messtab.
data: it_messtab type standard table of t_messtab initial size 0,
wa_messtab type t_messtab.
*table and work area to store and process talked to users
TYPES: begin of t_messtalk,
uname type sy-uname,
end of t_messtalk.
data: it_messtalk type standard table of t_messtalk initial size 0,
wa_messtalk type t_messtalk.
*table and work area to store and process users options/settings
TYPES: begin of t_messopt.
include structure ZMESSOPTIONS.
types: end of t_messopt.
data: it_messopt type standard table of t_messopt initial size 0,
wa_messopt type t_messopt.
*table and work area to store and process users from friends list
TYPES: begin of t_messfriends,
FRIEND type UINFO-bname,
DISNAME type ZMESSOPTIONS-disname,
* include structure ZMESSFRIENDS.
end of t_messfriends.
data: it_messfriends
type standard table of t_messfriends initial size 0,
wa_messfriends type t_messfriends.
*table to build message, conversation and info files
DATA: begin of it_datatab occurs 0,
row(500) type c,
end of it_datatab.
************************************************
*Display document on scree (i.e. txt, html etc)*
* From program EXAMPLE_ENTRY_SCREEN
DATA: gv_html_help_container TYPE REF TO cl_gui_custom_container,
gv_html_help TYPE REF TO cl_gui_html_viewer,
gv_html_who_container TYPE REF TO cl_gui_custom_container,
gv_html_who TYPE REF TO cl_gui_html_viewer,
gv_html_feedback_container TYPE REF TO cl_gui_custom_container,
gv_html_feedback TYPE REF TO cl_gui_html_viewer,
gv_html_index TYPE REF TO cl_gui_html_viewer,
* gv_evt_receiver TYPE REF TO lcl_event_handler,
gv_doc_id TYPE char30 VALUE 'BIBS_CHB_SHORT'.
* variables for the event processing and registering.
DATA: events TYPE cntl_simple_events,
wa_events TYPE cntl_simple_event.
************************************************
************************************************
*Automatic update
DATA: g_ref_from_timer,
gd_ucomm type syucomm.
************************************************
* Returns liist of connected users (SM04)
CONSTANTS: OPCODE_LIST TYPE X VALUE 2.
* Class definitions
*----------------------------------------------------------------------*
* INCLUDE BCALV_TREE_EVENT_RECEIVER *
*----------------------------------------------------------------------*
CLASS lcl_tree_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS handle_node_ctmenu_request
FOR EVENT node_context_menu_request OF cl_gui_alv_tree
IMPORTING node_key
menu.
METHODS handle_node_ctmenu_selected
FOR EVENT node_context_menu_selected OF cl_gui_alv_tree
IMPORTING node_key
fcode.
METHODS handle_item_ctmenu_request
FOR EVENT item_context_menu_request OF cl_gui_alv_tree
IMPORTING node_key
fieldname
menu.
METHODS handle_item_ctmenu_selected
FOR EVENT item_context_menu_selected OF cl_gui_alv_tree
IMPORTING node_key
fieldname
fcode.
METHODS handle_item_double_click
FOR EVENT item_double_click OF cl_gui_alv_tree
IMPORTING node_key
fieldname.
METHODS handle_button_click
FOR EVENT button_click OF cl_gui_alv_tree
IMPORTING node_key
fieldname.
METHODS handle_link_click
FOR EVENT link_click OF cl_gui_alv_tree
IMPORTING node_key
fieldname.
METHODS handle_header_click
FOR EVENT header_click OF cl_gui_alv_tree
IMPORTING fieldname.
METHODS handle_item_keypress
FOR EVENT header_click OF cl_gui_alv_tree
IMPORTING fieldname.
ENDCLASS. "lcl_tree_event_receiver DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_tree_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
CLASS lcl_tree_event_receiver IMPLEMENTATION.
* handle request for context menu(right click) on actual node
METHOD handle_node_ctmenu_request.
* break-point.
* append own functions
CALL METHOD menu->add_function
EXPORTING
fcode = 'SENDCT'
text = 'Start Conversation'.
CALL METHOD menu->add_function
EXPORTING
fcode = 'ADDFRIEND'
text = 'Add to friends list'.
CALL METHOD menu->add_function
EXPORTING
fcode = 'DELFRIEND'
text = 'Delete from friends list'.
ENDMETHOD. "handle_node_ctmenu_request
* process context menu selection for actual node
METHOD handle_node_ctmenu_selected.
data: ld_talkingto like gd_talkingto.
CASE fcode.
WHEN 'SENDCT'.
perform initialise_conversation.
* start/refresh conversation window (X)
if ld_talkingto is initial.
perform update_conversation using gd_talkingto 'X'.
* recall tranasction (leave to trans...)
perform recall_transaction using 'X'.
else.
* recall tranasction (leave to trans...)
perform recall_transaction using 'X'.
* perform update_conversation using gd_talkingto 'U'.
endif.
WHEN 'ADDFRIEND'.
perform add_user_to_friends_list.
WHEN 'DELFRIEND'.
perform del_user_from_friends_list.
ENDCASE.
ENDMETHOD. "handle_node_ctmenu_selected
* handle context menu option chosen for item(node text)
METHOD handle_item_ctmenu_request .
data: lt_fcodes type ui_functions.
* delete statndard buttons/options from context menu
append cl_gui_alv_tree=>mc_fc_help to lt_fcodes.
append cl_gui_alv_tree=>MC_FC_FIND to lt_fcodes.
call method menu->hide_functions
EXPORTING
fcodes = lt_fcodes.
* append own functions
CALL METHOD menu->add_function
EXPORTING
fcode = 'SENDCT'
text = 'Start Conversation'.
CALL METHOD menu->add_function
EXPORTING
fcode = 'ADDFRIEND'
text = 'Add to friends list'.
CALL METHOD menu->add_function
EXPORTING
fcode = 'DELFRIEND'
text = 'Delete from friends list'.
ENDMETHOD. "handle_item_ctmenu_request
*process context menu option for item(node text)
METHOD handle_item_ctmenu_selected.
data: ld_talkingto like gd_talkingto.
CASE fcode.
WHEN 'SENDCT'.
perform initialise_conversation.
* start/refresh conversation window (X)
if ld_talkingto is initial.
perform update_conversation using gd_talkingto 'X'.
* recall tranasction (leave to trans...)
perform recall_transaction using 'X'.
else.
* recall tranasction (leave to trans...)
perform recall_transaction using 'X'.
* perform update_conversation using gd_talkingto 'U'.
endif.
WHEN 'ADDFRIEND'.
perform add_user_to_friends_list.
WHEN 'DELFRIEND'.
perform del_user_from_friends_list.
ENDCASE.
ENDMETHOD. "handle_item_ctmenu_selected
* process when users double clicks
METHOD handle_item_double_click.
data: ld_talkingto like gd_talkingto.
* Stop refresh process (S)
* perform update_conversation using gd_talkingto 'S'.
ld_talkingto = gd_talkingto.
* Set conversation to selected contact
perform initialise_conversation.
* start/refresh conversation window (X)
if ld_talkingto is initial.
* clear: gd_stoprfc.
* SET PARAMETER ID 'ZMESSAGE' field gd_stoprfc.
perform update_conversation using gd_talkingto 'X'.
else.
perform update_conversation using gd_talkingto 'U'.
endif.
ENDMETHOD. "handle_item_double_click
METHOD handle_button_click.
* Processing when user clicks button
ENDMETHOD. "handle_button_click
METHOD handle_link_click.
ENDMETHOD. "handle_link_click
METHOD handle_header_click.
* Processing for when user clicks on ALVtree column headers
ENDMETHOD. "handle_header_click
METHOD handle_item_keypress.
ENDMETHOD. "handle_item_keypress
ENDCLASS. "lcl_tree_event_receiver IMPLEMENTATION
************************************************************************
* BUTTON CLASS *
************************************************************************
*----------------------------------------------------------------------*
* INCLUDE ZTEST_TOOLBAR_EVENT_RECEIVER *
*----------------------------------------------------------------------*
CLASS lcl_toolbar_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS: on_function_selected
FOR EVENT function_selected OF cl_gui_toolbar
IMPORTING fcode,
on_toolbar_dropdown
FOR EVENT dropdown_clicked OF cl_gui_toolbar
IMPORTING fcode
posx
posy.
ENDCLASS. "lcl_toolbar_event_receiver DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_toolbar_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
CLASS lcl_toolbar_event_receiver IMPLEMENTATION.
* process user actions.
METHOD on_function_selected.
DATA: ls_sflight TYPE sflight.
DATA: lt_list_commentary TYPE slis_t_listheader,
l_logo TYPE sdydo_value.
* Processing for user defined tollbar button goes here
CASE fcode.
WHEN 'CONT'.
if p_friend eq ' '.
p_friend = 'A'.
set parameter ID 'ZMESS' field p_friend.
else.
p_friend = ' '.
set parameter ID 'ZMESS' field p_friend.
endif.
WHEN 'FRIEND'.
p_friend = ' '.
set parameter ID 'ZMESS' field p_friend.
WHEN 'ALL'.
p_friend = 'A'.
set parameter ID 'ZMESS' field p_friend.
ENDCASE.
* if gd_talkingto is initial.
* perform update_conversation using gd_talkingto 'X'.
* else.
* perform update_conversation using gd_talkingto 'U'.
* endif.
* recall tranasction (leave to trans...)
perform recall_transaction using 'X'.
* update frontend
CALL METHOD gd_userlist->frontend_update.
ENDMETHOD. "on_function_selected
* process on toolbar drop down (add options to drop down)
METHOD on_toolbar_dropdown.
* create dropdown menu
DATA: l_menu TYPE REF TO cl_ctmenu,
l_fc_handled TYPE as4flag.
CREATE OBJECT l_menu.
CLEAR l_fc_handled.
* Setup Insert buttons so options are displayed as drop down menu
CASE fcode.
WHEN 'CONT'.
l_fc_handled = 'X'.
* insert as last child
CALL METHOD l_menu->add_function
EXPORTING
fcode = 'FRIEND'
text = 'Display from Friends List'. "#EC NOTEXT
* insert as first child
CALL METHOD l_menu->add_function
EXPORTING
fcode = 'ALL'
text = 'Display all Online Users'. "#EC NOTEXT
ENDCASE.
* show dropdown box
IF l_fc_handled = 'X'.
CALL METHOD mr_toolbar->track_context_menu
EXPORTING
context_menu = l_menu
posx = posx
posy = posy.
ENDIF.
ENDMETHOD. "on_toolbar_dropdown
ENDCLASS. "lcl_toolbar_event_receiver IMPLEMENTATION
********************************************
********************************************New refresh method
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS: on_finished FOR EVENT finished OF cl_gui_timer.
ENDCLASS. "lcl_event_handler DEFINITION
DATA ti_container TYPE REF TO cl_gui_custom_container.
DATA timer TYPE REF TO cl_gui_timer.
DATA event_handler TYPE REF TO lcl_event_handler.
DATA timeout TYPE i VALUE '10'.
*DATA: GD_TEST type i.
CLASS lcl_event_handler IMPLEMENTATION.
METHOD on_finished.
* Start Timer again
timer->interval = timeout.
CALL METHOD timer->run.
* cause PAI
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'FCT_R'.
g_ref_from_timer = 'X'.
* Trigger an event to run the at user-command
set user-command 'FCT_R'.
ok_code = 'FCT_R'.
save_ok = 'FCT_R'.
GET PARAMETER ID 'ZMESSAGE' field gd_stoprfc.
check gd_stoprfc is initial.
leave to screen 100.
ENDMETHOD. "on_finished
ENDCLASS. "lcl_event_handler IMPLEMENTATIONPROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.*******************************************************************
* System-defined Include-files. *
*******************************************************************
INCLUDE LZMESSTOP. " Global Data
INCLUDE LZMESSUXX. " Function Modules
*******************************************************************
* User-defined Include-files (if necessary). *
*******************************************************************
* INCLUDE LZMESSF... " Subprograms
INCLUDE LZMESSO01. " PBO-Modules
INCLUDE LZMESSI01. " PAI-Modules
*INCLUDE LZMESSI01.
*INCLUDE LZMESSO01.FUNCTION-POOL ZMESS. "MESSAGE-ID ..
data: ok_code like sy-ucomm,
save_ok like sy-ucomm,
sc_messagetxt(200) type c.*****************************************************************
* THIS FILE IS GENERATED BY THE FUNCTION LIBRARY. *
* NEVER CHANGE IT MANUALLY, PLEASE! *
*****************************************************************
INCLUDE LZMESSU01.
"Z_ENQUE_SLEEP
INCLUDE LZMESSU02.
"Z_SEND_MESSAGE
INCLUDE LZMESSU03.
"Z_ENQUE_DONTSLEEP*----------------------------------------------------------------------*
***INCLUDE LZMESSO01 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MESS'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT*----------------------------------------------------------------------*
***INCLUDE LZMESSI01 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
save_ok = ok_code.
case ok_code.
when 'EXIT' or 'BACK' or 'CANC'.
leave to screen 0.
when 'SEND' or ' '.
leave to screen 0.
endcase.
ENDMODULE. " USER_COMMAND_0100 INPUTPROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.*******************************************************************
* System-defined Include-files. *
*******************************************************************
INCLUDE LZMESSTOP. " Global Data
INCLUDE LZMESSUXX. " Function Modules
*******************************************************************
* User-defined Include-files (if necessary). *
*******************************************************************
* INCLUDE LZMESSF... " Subprograms
INCLUDE LZMESSO01. " PBO-Modules
INCLUDE LZMESSI01. " PAI-Modules
*INCLUDE LZMESSI01.
*INCLUDE LZMESSO01.PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.*******************************************************************
* System-defined Include-files. *
*******************************************************************
INCLUDE LZMESSTOP. " Global Data
INCLUDE LZMESSUXX. " Function Modules
*******************************************************************
* User-defined Include-files (if necessary). *
*******************************************************************
* INCLUDE LZMESSF... " Subprograms
INCLUDE LZMESSO01. " PBO-Modules
INCLUDE LZMESSI01. " PAI-Modules
*INCLUDE LZMESSI01.
*INCLUDE LZMESSO01.*----------------------------------------------------------------------*
***INCLUDE LZMESSI01 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
save_ok = ok_code.
case ok_code.
when 'EXIT' or 'BACK' or 'CANC'.
leave to screen 0.
when 'SEND' or ' '.
leave to screen 0.
endcase.
ENDMODULE. " USER_COMMAND_0100 INPUT*----------------------------------------------------------------------*
***INCLUDE LZMESSO01 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MESS'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUTFUNCTION-POOL ZMESS. "MESSAGE-ID ..
data: ok_code like sy-ucomm,
save_ok like sy-ucomm,
sc_messagetxt(200) type c.*call function 'ENQUE_SLEEP'
* exporting
* seconds = 15.
wait up to 10 seconds.CALL SCREEN 100 STARTING AT 10 10 ENDING AT 100 15.
if save_ok EQ 'SEND' or
save_ok is initial.
message = sc_messagetxt.
clear: sc_messagetxt.
else.
raise canceled.
endif.*call function 'ENQUE_SLEEP'
* exporting
* seconds = 15.
*wait up to 10 seconds.*&---------------------------------------------------------------------*
*& Report ZMESSCLEARUP *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZMESSCLEARUP .
DATA: begin of it_datatab occurs 0,
row(500) type c,
end of it_datatab.
DATA: e_file TYPE STRING,
ld_filepath type zmessoptions-filepath.
*parameter: p_fpath(200) type c.
************************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
select single filepath
from zmessoptions
into (ld_filepath)
where uname eq sy-uname.
if ld_filepath is initial.
ld_filepath = 'C:\TEMP\CONV\'.
endif.
update zmessoptions set isonline = ' '
where uname eq sy-uname.
************************************************************************
*END-OF-SELECTION.
END-OF-SELECTION.
concatenate sy-uname '*.htm' into it_datatab-row.
concatenate 'del' it_datatab-row into it_datatab-row separated by space.
*it_datatab-row = 'del *.htm'.
append it_datatab.
concatenate ld_filepath 'deletefiles.bat' into e_file.
call function 'GUI_DOWNLOAD'
EXPORTING
filename = e_file
filetype = 'ASC'
TABLES
data_tab = it_datatab[]
EXCEPTIONS
file_open_error = 1
file_write_error = 2
others = 3.
DELETE FROM zmesstab where TOUSER eq sy-uname.
CALL FUNCTION 'WS_EXECUTE'
EXPORTING
* DOCUMENT = ' '
CD = ld_filepath
* COMMANDLINE = 'del *.htm '
* INFORM = ' '
PROGRAM = 'deletefiles.bat'
* STAT = ' '
* WINID = ' '
* OSMAC_SCRIPT = ' '
* OSMAC_CREATOR = ' '
* WIN16_EXT = ' '
* EXEC_RC = ' '
* IMPORTING
* RBUFF =
* EXCEPTIONS
* FRONTEND_ERROR = 1
* NO_BATCH = 2
* PROG_NOT_FOUND = 3
* ILLEGAL_OPTION = 4
* GUI_REFUSE_EXECUTE = 5
* OTHERS = 6
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.