Part 4 of “Event-Driven” Tutorial on the WD-ABAP Component WDR_TEST_UI_ELEMENTS.
This post resumes the “experiential” or “event-driven” tutorial on how to use the SAP-delivered WD-ABAP component WDR_TEST_UI_ELEMENTS as a pattern for a
generic
component that displays
a detail view from a tree view from a tray view
. Although there have been three posts in this tutorial to-date:
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.
one need only read the most third and most recent (“Procedural Recap”) in order to understand what has been learned so far, i.e. what has been done so far and why. On the other hand, unless one takes the time and trouble to read the first and second posts as well, one really misses the essential point of this “experiential” or “event-driven” tutorial – namely – to learn how to do WD-ABAP without reading the documentation, going to class, or drilling through procedural tutorials.
JUST KIDDING !!!
Documentation, class, and procedural tutorials
ARE
all integral parts of the WD-ABAP learning experience, and one shouldn’t attempt the kind of “event-driven” self-tutorial I’m documenting here
until
one has gone thru the excellent WD-ABAP procedural tutorials already written by SAP and SDN folks. This is because going thru these procedural tutorials will make one’s fingers smart at WD-ABAP editor navigation, as well as providing a rough initial idea of how WD-ABAP actually works. In fact, it is a good idea to do
all seven
WD-ABAP procedural tutorials before trying an “event-driven” self-tutorial, if you are a bear of as little brain as me and have to be hit over the head by repetition before you really understand anything. (Note: the phrase “bear of little brain” is from the great children’s classic “Winnie-the-Pooh” – (re-)reading it is a great way of getting some relief from the pressures of seeing how quickly one can become effective in WD-ABAP.)
Anyway, at the end of the third post in this series, the clone WD-ABAP component ZWDR_TEST_UI_ELEMENTS had been successfully modified to display not only the SAP-delivered trays and links in the left-hand side tray view, but also the following “custom” trays (metadata libraries) and links (metadata library members):
Logical DataBases
(custom tray)
Vendor Database (custom link)
Open Item Balance Audit Trail (custom link)
Historitcal Balance Audit Trail (custom link)
Condition Record Selection (custom link
Programming Trees
(custom tray)
Document Numbers by Cost Center (custom link)
Projects to Activities (custom link)
Report Sets
(custom tray)
Balance Sheet/Income Statement (custom link)
Maintenance/Mechanical Services (custom link)
Manufacturing Operations (custom link)
And therefore, the next step in modifying
ZWDR_TEST_UI_ELEMENTS
is to get this clone component to display the correct right-hand-side tree-view when one of the custom links is selected. To make this objective clear, it is important to note that:
i) the SAP-delivered component
WDR_TEST_UI_ELEMENTS
opens with the
STANDARD
library selected and the
BUTTON
link selected, so that the right-hand side tree-view already displays the “aggregation” for “
Button
“.
ii) If one then clicks on a different link within the
STANDARD
tray (or if one opens a different tray and clicks on a link within it), the correct “aggregation” will appear in the right-hand-side tree view.
So in effect, what needs to be done is to modify the clone component
ZWDR_TEST_UI_ELEMENTS
so that the same thing happens as in (ii) above when any of the
custom
trays and links above are selected, e.g. the custom tray
Logical Databases
and the custom link
Vendor Database
.
As is always the case, the only way to figure out how to do this is to:
iii) set-up for external session debugging by strategically placing breakpoints within the code that executes when a link is selected from the left-hand-side tray view of the SAP-delivered component
WDR_TEST_UI_ELEMENTS
;
iv) run this component and let the break-points tell you what the code does;
v) be very,
very
patient.
If one is diligent about doing (iii-v), one will learn in a matter of an hour or so what’s already been mentioned in earlier posts within this series:
a) When a link is clicked in the left-hand tray view, the method
onActionDISPLAY_DETAIL
of the
Main
view of
WDR_TEST_UI_ELEMENTS
is invoked;
b) this method invokes the method
on_display_detail
of the SAP-delivered class
CL_WDR_ALL_IN_ONE_UTIL
(since this is the class that has been declared as the handler of the
Main
view of
WDR_TEST_UI_ELEMENTS
);
c) this method invokes the
swtich_ui_element2
method of
CL_WDR_ALL_IN_ONE_UTIL
;
d) this method invokes the
create
method of the SAP-delivered class
CL_WDR_ALL_IN_ONE_UI_ELEM
(because
m_view_cur_element
has been set to this class – see earlier posts.)
e) this method invokes the
create_settings
method of
CL_WDR_ALL_IN_ONE_UI_ELEM
;
and
most importantly
:
f)
aha!
: the create_settings method of
CL_WDR_ALL_IN_ONE_UI_ELEM
contains the code that displays the correct tree-root node at the top of the right-hand-side tree-view (i.e. “Button”, or “Tree”, or “Table”, etc., depending on what left-hand-side tray link has been selected.)
In particular, the code in
create_settings
that does this is:
*********************************************************************
-
create an instance of the new view element
concatenate ‘NEW_’ (method_name)
parameter-table
lt_method_params.
-
add it to the hierarchy tree
m_hier_tree_context_element = m_hier_tree_context_node->create_element( ).
m_hier_tree_context_node->bind_element( new_item = m_hier_tree_context_element set_initial_elements = abap_false ).
m_hier_tree_context_element->set_attribute( name = ‘EXPANDED’ value = abap_false ).
m_hier_tree_context_element->set_attribute( name = ‘HAS_CHILDREN’ value = abap_false ).
m_hier_tree_context_element->set_attribute( name = ‘TEXT’ value = set_attribute( name = ‘ICON’ value = icon ).
**************************************************************************
And therefore, all we have to do to achieve our objective is to modify the above code as follows:
****************************************************************************
-
create an instance of the new view element
-
add it to the hierarchy tree
m_hier_tree_context_element = m_hier_tree_context_node->create_element( ).
m_hier_tree_context_node->bind_element( new_item = m_hier_tree_context_element set_initial_elements = abap_false ).
m_hier_tree_context_element->set_attribute( name = ‘EXPANDED’ value = abap_false ).
m_hier_tree_context_element->set_attribute( name = ‘HAS_CHILDREN’ value = abap_false ).
m_hier_tree_context_element->set_attribute( name = ‘TEXT’ value =