Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos
In this blog I would like to talk about a custom generic class created by me which can be used to handle user actions.In day to day operations in a production environment there are several actions which are performed by the user on a daily basis.This class can be used to consolidate those actions into an application which can be used by the user as a easy navigation tool.Each of these actions can be further divided based on the application area. This class can be typically used in "cockpit" type applications which involve integration of several applications.All the actions required to be performed by the user in each of these applications can be passed on to this class based on the application involved.A docking container containing all the application areas along with the actions is then displayed to the user.The user can click on any action and execute it as per his requirements.

Part 1 : Creation of class ZCL_ACTION_TOOLBOX PUBLIC SECTION class ZCL_ACTION_TOOLBOX definition public final create public . *"* public components of class ZCL_ACTION_TOOLBOX *"* do not include other source files here!!! public section. type-pools ICON . data NEW_CODE type SYUCOMM value 'CLICK' . data AT_SELECTED_ACTION type ZWA_ACTIONS . class CL_GUI_DOCKING_CONTAINER definition load . methods CONSTRUCTOR importing !REPID type SYREPID default SY-REPID !DYNNR type SYDYNNR default SY-DYNNR !SIDE type I default CL_GUI_DOCKING_CONTAINER=>DOCK_AT_LEFT !EXTENSION type I default 500 !NAME type STRING default 'ACTION_DOCKING' !ZACTIONS type ZACTIONS . methods TOGGLE importing !VISIBLE type C . PROTECTED SECTION *"* protected components of class ZCL_ACTION_TOOLBOX *"* do not include other source files here!!! protected section. data REF_DOCKING type ref to CL_GUI_DOCKING_CONTAINER . data REF_DRAWER type ref to CL_GUI_CONTAINER_BAR . methods ON_CLICK for event CLICKED of CL_GUI_CONTAINER_BAR importing !ID !CONTAINER !NAME . methods ON_ACTION_CLICK for event ICON_CLICKED of CL_WFD_HTML_ICONS importing !ID . PRIVATE SECTION *"* private components of class ZCL_ACTION_TOOLBOX *"* do not include other source files here!!! private section. data AT_ZACTIONS type ZACTIONS . METHODS : 1. CONSTRUCTOR METHOD constructor. DATA : wa_action TYPE swd_icon, lt_actions TYPE swd_icons, lwa_action TYPE swd_icon, lwa_actions TYPE zwa_actions, lt_captions TYPE sbptcaptns, lwa_captions TYPE sbptcaptn. IF ref_docking IS INITIAL. *Create the docking container CREATE OBJECT ref_docking EXPORTING * PARENT = repid = repid dynnr = dynnr side = side extension = extension * STYLE = * LIFETIME = lifetime_default * CAPTION = * METRIC = 0 * RATIO = * NO_AUTODEF_PROGID_DYNNR = name = name EXCEPTIONS cntl_error = 1 cntl_system_error = 2 create_error = 3 lifetime_error = 4 lifetime_dynpro_dynpro_link = 5 OTHERS = 6 . *Now add the Vertical tab container in the left splitter IF NOT zactions[] IS INITIAL. at_zactions[] = zactions[]. REFRESH lt_captions[]. LOOP AT at_zactions INTO lwa_actions. lwa_captions-caption = lwa_actions-act_tab_caption. lwa_captions-icon = lwa_actions-act_tab_icon. lwa_captions-name = lwa_actions-act_tab_name. APPEND lwa_captions TO lt_captions. ENDLOOP. SORT lt_captions BY name. DELETE ADJACENT DUPLICATES FROM lt_captions COMPARING name. CREATE OBJECT ref_drawer EXPORTING parent = ref_docking captions = lt_captions EXCEPTIONS max_number_of_cells_exceeded = 1 OTHERS = 2. *Register the click event SET HANDLER me->on_click FOR ref_drawer. *Set the active tab CALL METHOD ref_drawer->set_active EXPORTING id = 1. ENDIF. ENDIF. ENDMETHOD. 2. TOGGLE method TOGGLE. CALL METHOD ref_docking->set_visible EXPORTING visible = visible EXCEPTIONS CNTL_ERROR = 1 CNTL_SYSTEM_ERROR = 2 others = 3 . endmethod. 3. ON_CLICK METHOD on_click. DATA : wa_icon TYPE swd_icon, lt_icons TYPE swd_icons, lwa_actions TYPE zwa_actions, ref_actions TYPE REF TO cl_wfd_html_icons. REFRESH lt_icons[]. LOOP AT at_zactions INTO lwa_actions WHERE act_tab_name = name. MOVE-CORRESPONDING lwa_actions TO wa_icon. APPEND wa_icon TO lt_icons. ENDLOOP. CREATE OBJECT ref_actions EXPORTING parent = container icons = lt_icons. SET HANDLER me->on_action_click FOR ref_actions. ENDMETHOD. 4. ON_ACTION_CLICK METHOD on_action_click. DATA : lwa_actions TYPE zwa_actions. CALL METHOD cl_gui_cfw=>set_new_ok_code EXPORTING new_code = new_code. *Fill the "Selected Action" work area so that it can be accordingly used in the program. READ TABLE at_zactions INTO lwa_actions WITH KEY id = id. IF sy-subrc EQ 0. MOVE-CORRESPONDING lwa_actions TO at_selected_action. ENDIF. ENDMETHOD. Part 2 : Dictionary Structures 1.Create a table type ZACTIONS in SE11. 2.Create a line type type ZWA_ACTIONS in SE11. Structure of ZWA_ACTIONS is as follows : Part 3 : Test Program : ZACTION_TOOLBOX *&---------------------------------------------------------------------* *& Report ZACTION_TOOLBOX *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zaction_toolbox. TYPE-POOLS : icon. DATA : ref_toolbox TYPE REF TO zcl_action_toolbox, i_actions TYPE zactions, wa_actions TYPE zwa_actions, wa_actions_selected TYPE zwa_actions, v_new_code TYPE syucomm, v_repid TYPE sy-repid, v_dynnr TYPE sy-dynnr, ok_code TYPE syucomm, fcode TYPE syucomm, v_visible TYPE xfeld VALUE 'X'. START-OF-SELECTION. *Fill the actions in the table i_actions and pass them to the "ZCL_ACTION_TOOLBOX" class object *Actions in "ACTION_TAB1" wa_actions-act_tab_name = 'ACTION_TAB1'. wa_actions-act_tab_caption = 'This is Action tab 1'. wa_actions-act_tab_icon = icon_wizard. wa_actions-id = 1. wa_actions-icon = 'ICON_CHECK'. wa_actions-text = 'Check Action'. APPEND wa_actions TO i_actions. wa_actions-act_tab_name = 'ACTION_TAB1'. wa_actions-act_tab_caption = 'This is Action tab 1'. wa_actions-act_tab_icon = icon_wizard. wa_actions-id = 2. wa_actions-icon = 'ICON_GRAPHICS'. wa_actions-text = 'Graphics Action'. APPEND wa_actions TO i_actions. *Actions in "ACTION_TAB2" wa_actions-act_tab_name = 'ACTION_TAB2'. wa_actions-act_tab_caption = 'This is Action tab 2'. wa_actions-act_tab_icon = icon_display_text. wa_actions-id = 3. wa_actions-icon = 'ICON_SYSTEM_CUT'. wa_actions-text = 'System cut Action'. APPEND wa_actions TO i_actions. wa_actions-act_tab_name = 'ACTION_TAB2'. wa_actions-act_tab_caption = 'This is Action tab 2'. wa_actions-act_tab_icon = icon_display_text. wa_actions-id = 4. wa_actions-icon = 'ICON_OVERVIEW'. wa_actions-text = 'Overview Action'. APPEND wa_actions TO i_actions. wa_actions-act_tab_name = 'ACTION_TAB2'. wa_actions-act_tab_caption = 'This is Action tab 2'. wa_actions-act_tab_icon = icon_display_text. wa_actions-id = 5. wa_actions-icon = 'ICON_PERIOD'. wa_actions-text = 'Period Action'. APPEND wa_actions TO i_actions. CALL SCREEN 100. *&---------------------------------------------------------------------* *& Module STATUS_0100 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE status_0100 OUTPUT. SET PF-STATUS 'BASIC'. SET TITLEBAR '007'. v_repid = sy-repid. v_dynnr = sy-dynnr. *Create Object IF ref_toolbox IS INITIAL. CREATE OBJECT ref_toolbox EXPORTING repid = v_repid dynnr = v_dynnr side = cl_gui_docking_container=>dock_at_left extension = 300 name = 'ACTION_DOCKING' zactions = i_actions . ENDIF. *Display/Change CALL METHOD ref_toolbox->toggle EXPORTING visible = v_visible. ENDMODULE. " STATUS_0100 OUTPUT *&---------------------------------------------------------------------* *& Module exit-processing INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE exit-processing INPUT. fcode = ok_code. CLEAR ok_code. CASE fcode. WHEN 'BACK' OR 'EXIT' OR 'CANC'. SET SCREEN 0. LEAVE SCREEN. ENDCASE. ENDMODULE. " exit-processing INPUT *&---------------------------------------------------------------------* *& Module user_command_0100 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE user_command_0100 INPUT. fcode = ok_code. CLEAR ok_code. v_new_code = ref_toolbox->new_code. wa_actions_selected = ref_toolbox->at_selected_action. CASE fcode. WHEN v_new_code. *Do some processing here based on the workarea values wa_actions_selected WHEN 'TOG'. IF v_visible = 'X'. v_visible = space. ELSE. v_visible = 'X'. ENDIF. ENDCASE. ENDMODULE. " user_command_0100 INPUT PF STATUS “BASIC” Create a pf status having buttons "BACK","EXIT" and "CANC" in exit-command and a button "TOG" on the application toolbar for display/hide of the action toolbox. Screen 100 Flow Logic PROCESS BEFORE OUTPUT. MODULE status_0100. PROCESS AFTER INPUT. MODULE exit-processing AT EXIT-COMMAND. MODULE user_command_0100. Element List Screen layout Action List Demo Action Tab 1 Action Tab 2
3 Comments