Skip to Content
Although this tutorial now has sections from 1 to 6(a-b) as follows: Apache Struts/M2 and SAP WebDynpro/MVC: Can these paradigms alone guarantee separation of business and presentation logic? (Part 6b of Tutorial on WDR_TEST_UI_ELEMENTS) Part 6a of Event-Driven Tutorial on WDABAP Component WDR_TEST_UI_ELEMENTS If you’ve written something in SAP from scratch, you (probably) haven’t bothered to understand what someone else has already done (Part 5 of “Event-Driven” Tutorial on WD-ABAP Component WDR_TEST_UI_ELEMENTS) Part 4 of “Event-Driven” Tutorial on the WD-ABAP Component WDR_TEST_UI_ELEMENTS. “Procedural” Recap of What’s Been Learned So Far in “Experiential” (“Event-Driven”) Tutorial on WD-ABAP component WDR_TEST_UI_ELEMENTS The class infrastructure of WDR_UI_TEST_ELEMENTS is exquisite for lazy cloning and change-ups. Experiential vs Procedural Tutorials: “Breaking” WDR_TEST_UI_ELEMENTS to Learn From It. the last actual coding was done in Part 5. (Part 6a contains only an explanation of why this tutorial is shwoing how to clone the SAP-delivered component WDR_TEST_UI_ELEMENTS into one that displays information about SAP logical metadata, and Part 6b contains only some comments on whether presentation and business logic are sufficiently separated in WDR_TEST_UI_ELEMENTS. At the end of Part 5, the left-hand-side tray view of our clone component ZWDR_TEST_UI_ELEMENTS opened on the tray “Logical Databases” and the right-hand-side tree-view opened on the particulakr Logical Database “KDF” (Vendor Database). In particular, the display looks like this: image (This slide is from my SDN Day presentation – that’s why it has the title it does.) The next step is to try and get the “middle” detail view (between the tray-view and the tree-view) to display some useful information about whatever node of the Logical Database is selected in the right-hand tree-view. In particular, suppose that the Logical Database node “LFA1” is selected (see illustration above). Then it would be nice to have the middle detail view display two kinds of information about the node LFA1: i) the columns of LFA1 that are mentioned in the where-clause of the SELECT statement of the “put” for this node; ii) the columns of LFA1 that are actually retrieved by this SELECT statement and used in the nextt-lower “puts”l iii) an indication of whether these “hook fields” are key or index fields in these next-lower puts. From inspection and a little trial-and-error using the debugger, it is easy to learn that when a node of the tree in the right-hand tree-view is selected, the method that fires is the onaction_onselect_view_element of the Main view of the clone component ZWDR_TEST_UI_ELEMENTS: ** method onactionon_select_view_elem. * request the selection to be performed wd_this->m_handler->on_select_view_element( context_element ). endmethod. ***** This in turn invokes the method on_select_view_element of the handler class ZCL_WDR_ALL_IN_ONE_UTIL: ** method ON_SELECT_VIEW_ELEMENT . * forward it to the ui elem proxy m_cur_view_element->on_select_view_element( i_hier_tree_selected_element ). endmethod. ***** and this “handler method” invokes the corresponding method of the proxy class ZCL_WDR_ALL_IN_ONE_UIELEM: ** method on_select_view_element. data: lr_view_elem_helper like line of mt_aggregated_view_elements, lr_container type ref to cl_wd_uielement_container, lt_children type CL_WD_uielement=>tt_uielement, lr_child like line of lt_children. * save the selected context element of the hierarchy tree m_hier_tree_selected_element = i_hier_tree_selected_element. * in case we are the one to be displayed, do it if m_hier_tree_context_element = i_hier_tree_selected_element. * remove the old trays lt_children = m_parent_container->get_children( ). loop at lt_children into lr_child. if lr_child->id cs mc_settings_id or lr_child->id cs mc_events_id. m_parent_container->remove_child( id = lr_child->id ). endif. endloop. clear m_settings_tray. clear m_events_tray. * create new ones create_settings_tray( ). create_events_tray( ). else. * otherwise propagate it down the chain loop at mt_aggregated_view_elements into lr_view_elem_helper. lr_view_elem_helper->on_select_view_element( i_hier_tree_selected_element ). endloop. endif. endmethod. ***** Upon examination of this last method, it is clear that it can’t be used as is because the table mt_aggregated_view_elements has not been filled by the custom method create_lgcldb_nodes which was coded in Part 5 to replace the SAP-delivered method create_aggregatee. But that’s OK, because it turns out this table is not at all necessary in order to build the new detail view we’re trying to build. In other words, the presence of this table in the on_select_view_element method of CL_WDR_ALL_IN_ONE_UIELEM is another example of how this class mixes business with presentation logic in a way that obscures what a simple component it really is. The following code shows how the SAP-delivered method on_select_view_element can be changed in the clone component ZCL_WDR_ALL_IN_ONE_UIELEM so that this method builds a tray in the middle detail view with a title that indicates what the tray is for. (Note in particular the code in boldface, which is what has been added to the original method above.) **** method ON_SELECT_VIEW_ELEMENT. data: lr_view_elem_helper like line of mt_aggregated_view_elements, lr_container type ref to cl_wd_uielement_container, lt_children type CL_WD_uielement=>tt_uielement, lr_child like line of lt_children, v_ldbnode(30) type c, id type string, text type string. * save the selected context element of the hierarchy tree m_hier_tree_selected_element = i_hier_tree_selected_element. IF m_library_name <> ‘LGCLDBS’ AND m_library_name <> ‘RPTSTS’ AND m_library_name <> ‘PRGTRS’. * in case we are the one to be displayed, do it if m_hier_tree_context_element = i_hier_tree_selected_element. * remove the old trays lt_children = m_parent_container->get_children( ). loop at lt_children into lr_child. if lr_child->id cs mc_settings_id or lr_child->id cs mc_events_id. m_parent_container->remove_child( id = lr_child->id ). endif. endloop. clear m_settings_tray. clear m_events_tray. * create new ones create_settings_tray( ). create_events_tray( ). else. * otherwise propagate it down the chain loop at mt_aggregated_view_elements into lr_view_elem_helper. lr_view_elem_helper->on_select_view_element( i_hier_tree_selected_element ). endloop. endif. ELSE. i_hier_tree_selected_element->get_attribute( EXPORTING name = ‘TEXT’ IMPORTING value = v_ldbnode ). * remove the old trays lt_children = m_parent_container->get_children( ). loop at lt_children into lr_child. if lr_child->id cs mc_settings_id or lr_child->id cs mc_events_id. m_parent_container->remove_child( id = lr_child->id ). endif. endloop. clear m_settings_tray. clear m_events_tray. * NOTE: this SELECT and the following IF/ELSE is to set the text or caption of the new tray that’s going to be built. SELECT count( * ) FROM zwdy_ui_elem_def INTO v_cnt WHERE display_name = v_ldbnode. IF v_cnt = 0. concatenate text-017 ` ` v_ldbnode into text. ELSE. text = text-018. ENDIF. * NOTE!!! This code is lifted from the method create_settings_tray – it’s all we need from this method!! concatenate m_prefix mc_settings_id into id. m_settings_tray = add_tray_to_container( i_id = id i_parent_container = m_parent_container i_header_text = text ). ENDIF endmethod. **** The effect of this code is that when the Main view initially opens, the caption of the middle detail view will say: Please select a lower-level LDB node for information on it but when a lower-level node such as “LFA1” of the right-hand tree-view is selected, the caption of the middle detail view will say: Where-Clause Fields of “Put” Select for Node LFA1 So, all that remains to create the detail view we want for any Logical Database node is to add a couple more trays to the middle detail view and to add appropriate items within these trays. Part 8 of this tutorial will deal with these tasks, since some new metadata will be required as well as some new code.
To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply