At the end of Part 4 of this 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...
we were in the middle of examining how the method
create_settings
of the classCL_WDR_ALL_IN_ONE_UIELEM
processesROAD_MAP
property data in the SAP metadata tableWDY_UI_PROP_DEF
. In particular, we had reached the point in the main loop ofcreate_settings
where a value-set (perhaps null) has been assigned to each property of theROAD_MAP
UI element, and the next piece of code to execute is:But if you look at this piece of code, an obvious question immediately arises:
On the one hand, the main loop of
create_settings
is executing only on rows of the global itabmt_ui_prop_def
in whichlibrary_name
is'STANDARD'
anddefinition_name
isROAD_MAP
. (This is because the global variablesm_library_name
andm_definition_name
are currently set to these values.)"if"
executes only whenlibrary_name
is'DYNPRO_CONVERSION'
anddefinition_name
is'SELECT_OPTION_FIELD'
."if"
increate_settings
if it can never apply whenlibrary_name
is'STANDARD'
anddefinition_name
isROAD_MAP ???
create_settings
is a multi-purpose method that is calledmore than once
after anaction_link
has been selected from a lefthand tray displayed by WDR_TEST_UI_ELEMENTS. In particular,create_settings
is not only called in this flow-of-control:onActionDISPLAY_DETAIL (method of Main view of WDR_TEST_UI_ELEMENTS)
on_display_detail (method of CL_WDR_ALL_IN_ONE_UTIL)
switch_ui_element2 (method of CL_WDR_ALL_IN_ONE_UTIL)
create (method of CL_WDR_ALL_IN_ONE_UIELEM)
create_settings (method of CL_WDR_ALL_IN_ONE_UIELEM)
create
method ofCL_WDR_ALL_IN_ONE_UIELEM
in thisrecursive
flow-of-control:create (method of CL_WDR_ALL_IN_ONE_UIELEM)
create_aggregations (method of CL_WDR_ALL_IN_ONE_UIELEM)
create_aggregatee (method of CL_WDR_ALL_IN_ONE_UIELEM)
create (method of CL_WDR_ALL_IN_ONE_UIELEM)
create_settings
is called bycreate
in this recursive flow-of-control, it is required to processproperty
data for many metadata elements other thanRoad_Map
.create_settings
is this kind of multi-purpose method, it is a lot more difficult to understand than if it were just a method designed to help in the dynamic creation ofRoadMaps
. But inasmuch ascreate_settings
is called bycreate
withNO
parameters, we can very easily improve the comprehensibility ofcreate_settings
by:a
) copyingcreate_settings
to a new method "create_settings_roadmap
";b)
adding the following code at the very top of the original methodcreate_settings
:if m_library_name = 'STANDARD'
and m_definition_name = 'ROAD_MAP'.
create_settings_roadmap( ).
exit.
endif.
c)
removing from the new methodcreate_settings_roadmap
all code that does not apply to the dynamic creation ofRoadMaps
.WDR_TEST_UI_ELEMENTS
, the classCL_WDR_ALL_IN_ONE_UTIL
, and the classCL_WDR_ALL_IN_ONE_UIELEM
, and then make some minor changes to these local copies. So in an "Appendix" atthe bottom of this post
, I have again listed everything that has to be done in order to make the local copies work correctly, i.e what we originally did way back Class-Data May be Cheating, but Who Cares? (Part 4 of Dynamic Road Map Tutorial).)(a-b)
have been done, it's easy to accomplish objective(c)
by simplifying the newcreate_settings_roadmap
method so that it only contains code applying toRoadMaps
.1) Simpify this code:
to this code:
2) Simpify this code:
to this code:
3) Remove this code:
4) Simpify this code:
to this code:
5) Remove this code:
6) Simpify this code:
to this code:
When we make the changes (1-6) and re-activate, we know</b> we understand those aspects of the module <b>create_settings</b> that are relevant to <b>RoadMaps</b> because the component runs as if we didn't change anything at all.
So tomorrow, we'll take the same approach for the methods <b>create_aggregations</b> and <b>create_aggregatee</b>, which are even more multiplexed than <b>create_settings</b>.
<b>Appendix</b>
To make excecutable local copies of <b>WDR_TEST_UI_ELEMENTS</b> and its two supporting classes, here are the required steps (repeated from an earlier post for your convenience):
<b>1. Step 1:</b>
<b>What</b>: Copy the WD-ABAP component <b>WDR_TEST_UI_ELEMENTS</b> to <b>ZWDR_TEST_UI_ELEMENTS</b>.
<b>Why?</b>: So we don't muck with SAP-delivered code.
<b>Details</b>: Use the comnponent copy function of the WD-ABAP component editor in <b> Object Navigsator (SE80)</b>.
(Don't forget to create an application for the new clone component.)
<b>2. Step 2:</b>
<b>What</b>: Copy the two SAP-delivered classes <b>CL_WDR_ALL_IN_ONE_UTIL</b> and <b>CL_WDR_ALL_IN_ONE_UIELEM</b> to <b>ZCL_WDR_ALL_IN_ONE_UTIL</b> and <b>ZCL_WDR_ALL_IN_ONE_UIELEM</b>.
<b>Why?</b>: Because we have to change some typing and methods in these classes.
<b>Details</b>: Use the class copy function of the Class Editor (SE24) to create <b>ZCL_WDR_ALL_IN_ONE_UTIL</b> from <b>CL_WDR_ALL_IN_ONE_UTIL</b> and <b>ZCL_WDR_ALL_IN_ONE_UIELEM</b> from <b>CL_WDR_ALL_IN_ONE_UIELEM</b>
<b>3. Step 3:</b>
<b>What</b>: Get the new clone component <b>ZWDR_TEST_UI_ELEMENTS</b> just to compile and run by making any necessary changes in types and methods.
<b>Why?</b>: To make sure that we have a firm foundation before we continue.
<b>Details</b>:
<b>3a</b>: In the <b>Attributes</b> of the <b>Main</b> view of the clone component ZWDR_TEST_UI_ELEMENTS, change the type of the attribute <b>m_handler</b> to the new custom class <b>zcl</b>_wdr_all_in_one_utils.
<b>3b</b>: Change the <b>constructor</b> method of the new customer class zcl_wdr_all_in_one_utils so that it references the <b>init_meta_data</b> method of the <b>new</b> customer class <b>zcl_wdr_all_in_one_uielem</b>;
<b>3c</b>: In the attributes of the new custom class <b>ZCL_WDR_ALL_IN_ONE_UTIL</b>, change the type of <b>m_cur_view_element</b> to the new custom class <b>zcl</b>_wdr_all_in_one_uielem;
<b>3d</b>: in the protected section of <b>zcl_wdr_all_in_one_uielem</b>, change the type of <b>tt_me</b> to <b>zcl_wdr_all_in_one_uielem</b>;
<b>3e</b>: in the method <b>create_aggregatee</b> of the new class <b>zcl_wdr_all_in_one_uielem</b>, change the type of <b>lr_new_view_elem_helper</b> to <b>zcl</b>_wdr_all_in_one_uielem;
<b>3f</b>: in the method <b>create_container_default_aggr</b> of the new class <b>zcl_wdr_all_in_one_uielem</b> , do the same thing as in (f), i.e. change the type of <b>lr_new_view_elem_helper to zcl_wdr_all_in_one_uielem</b>;
<b>3g</b>: Make the following type changes in the method <b>init_view2</b> of the new class <b>ZCL_WDR_ALL_IN_ONE_UTIL</b>:
<font color="blue">method INIT_VIEW2.
...
data:
...
ui_elem_def_tmp like line of <b>zcl</b>_wdr_all_in_one_uielem=>mt_ui_elem_def_all,
...
ui_prop_def_tmp like line of <b>zcl</b>_wdr_all_in_one_uielem=>mt_ui_prop_def,
...
field-symbols:
<ui_elem_def> like line of <b>zcl</b>_wdr_all_in_one_uielem=>mt_ui_elem_def,
<ui_prop_def> like line of <b>zcl</b>_wdr_all_in_one_uielem=>mt_ui_prop_def,
<ui_library> like line of <b>zcl</b>_wdr_all_in_one_uielem=>mt_ui_library.
...</font><br><br>