After setting up some appropriate metadata in Is there a better way than the meta way? (Dynamic RoadMaps: Part 9) of this tutorial:
Is there a better way than the meta way? (Dynamic RoadMaps: Part 9)
If a house is well-built, its details can be readily rearranged (DynamicRoadMaps:Part 😎
"Complex-looking" code is sometimes the "simplest" (Dynamic RoadMaps:Part 6)
"Complex-looking" code is sometimes the "simplest" (Dynamic RoadMaps:Part 6)
When in doubt, de-multiplex! (Part 5 of Dynamic RoadMap Tutorial)
Class-Data May be Cheating, but Who Cares? (Part 4 of Dynamic Road Map Tutorial)
SAP UI Element Metadata: Gold or Fool's Gold? (Part 3 of Dynamic RoadMap Tutorial)
But how does the thermos bottle know? (Part 2 of Dynamic Road Map Tutorial)
Exposing Critical SAP Code Paths as WebDynpro(ABAP) RoadMaps: One Case Where Dynamic UI Element Gene...
it only took a little bit of tinkering to achieve objectives (1a-b) stated in If a house is well-built, its details can be readily rearranged (DynamicRoadMaps:Part 😎.
In particular, our custom component
ZWDR_TEST_UI_ELEMENTS
now behaves in two entirely different ways, depending on which lefthand side library the customer selects an action link from.
When the customer selects an action link from the
Logical Database
tray, e.g. the link
Vendor Database
, then the component generates a display like this:
Figure A:</b>
But when the customer selects an action link from the
Programming Trees
tray, e.g. the link
Document Numbers by Cost Center
, then the component generates a display like this:
Figure B:</b>
Note!!:
In
Figure B
, you can see that there is no initial display of any
RoadMap
, unlike in the display generated by the SAP component
WDR_TEST_UI_ELEMENTS
when the action link
Road Map
is selected. The reason for this is that we only want to display a
RoadMap
to show further detail when a lower-level node of the navigation tree is selected, as per
Objective 2
stated in
If a house is well-built, its details can be readily rearranged (DynamicRoadMaps:Part 😎.
Before completing this tutorial by exhibiting the code required to achive
Objective 2
, it is worth reviewing what we had to do to get our component to generate a display like that in
Figure B
as well as a display like that in
Figure A
. Although not much coding had to be done to achieve this result, we did have to touch three of the four critical methods that fire when an
action link
is selected in the SAP component
WDR_TEST_UI_ELEMENTS
. And therefore, a review of exactly how we "hacked"
WDR_TEST_UI_ELEMENTS
will help to illustrate the structure of this wonderful component, as well as its flow-of-control.
When an action link is selected from a Library in
WDR_TEST_UI_ELEMENTS
or our custom copy
ZWDR_TEST_UI_ELEMENTS
, here is the sequence of methods that executes:
Figure C:
!https://weblogs.sdn.sap.com/weblogs/images/36447/10_2.gif|height=400|alt=image|width=350|src=https:/...!In the second method of the sequence above, we set two new global variables:
Figure D</b>:
so that we will have two pairs of global variables to use for two different purposes: ℹ when we want to invoke code dealing with aspects of UI Elements, we can set the original global variables to whatever we want, e.g. we can set the
library
global to
Standard
and the
element (action link)
global to
RoadMap
; ii) when we need to identify one of our custom libraries and elements (action links), e.g.
Programming Trees
and
Document Numbers by Cost
, we can use our new global variables.
In the third method of the sequence in
Figure C
, all we have to do is make sure that when we call the
create
method of our custom class
ZCL_WDR_ALL_IN_ONE_UIELEM
, we include the values of our two new global variables:
Figure E</b>:
In the fourth method of the sequence in
Figure C
, we have to take care of several different matters:
Figure F</b>:
In the code-block labelled -treenode.
replace '.' with '' into v_treenode.
condense v_treenode no-gaps.
concatenate m_prefix mc_aggr_explaination_id v_treenode into node_name.
lr_aggregation_node_info = create_aggregation_node( i_node_name = node_name i_parent_node_info = m_root_node_info ).
lr_aggregation_node = m_root_node->get_child_node( node_name ).
lr_context_element = lr_aggregation_node->create_element( ).
lr_context_element->set_attribute( name = 'LIBRARY_NAME' value = bind_element( new_item = lr_context_element set_initial_elements = abap_false ).
lr_hier_tree_context_node = m_hier_tree_context_element->get_child_node( 'UI_ELEMENT_HIER_REC' ).
lr_hier_tree_context_element = lr_hier_tree_context_node->create_element( ).
lr_hier_tree_context_node->bind_element( new_item = lr_hier_tree_context_element set_initial_elements = abap_false ).
IF set_attribute( name = 'ICON' value = icon ).
index = sy-tabix.
lr_aggregation_node->set_lead_selection_index( index ).
lr_hier_tree_context_element->get_attribute( EXPORTING name = 'HAS_CHILDREN' IMPORTING value = v_hasch ).
IF v_hasch = abap_true.
lr_save_tree_context_element = m_hier_tree_context_element.
m_hier_tree_context_element = lr_hier_tree_context_element.
create_prgtr_nodes( ).
m_hier_tree_context_element = lr_save_tree_context_element.
ENDIF.
endloop.
endmethod.