Code listing for ZSAPTALKTOP(include)
The below intructions / ABAP code is part of the SAPTAlk Instant messaging program for SAP.
*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. *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 IMPLEMENTATION
Related Articles
SapTALK User Messaging service
Example SAPTalk Screens
SAPTalk create screen 0100 with the following elements (see below screen shots for layout):
Create function module Z_SEND_MESSAGE
Create function module Z_ENQUE_SLEEP
Creation of GUI Status FEEDBACK
Creation of GUI Status 'MESS'
Creation of GUI Status 'OPTIONS'
Creation GUI Status 'ULIST'
SAPTalk - MSM messenger application for SAP
Code listings for SAPTALK includes
Code listing for ZSAPTALKF01(include)
Code listing for ZSAPTALKI01(include)
Code listing for ZSAPTALKO01(include)
SAPTalk selection screen parameters
SAPTALK - table creation
Code listing for ZMESSCLEARUP
ZMESS: Function group creation details
Code listings for SAPLZMESS(fgroup)
Code listings for SAPLZMESS includes
SAPLZMESS(fgroup ZMESS) - Screen creation
SapTALK: Report creation details
Code listing for SAPTALK
SAPTALK - Include creation
SAPTALK - Screen creation
SAPTALK - GUI Status creation
SAPTALK - GUI Title creation
SapTALK - Transaction creation
Create SAPTalk SAP tables
Create table ZMESSFRIENDS
Create table ZMESSOPTIONS
Create table ZMESSTAB
SAPLZMESS(fgroup)- Function module creation
Message Class and messages
SAPTalk Parameter ID's
SAPTAlk clearup tranasction code