Skip to Content

From following Parts 1-7 of this tutorial:

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.

****

But now that we have eliminated all but our three target libraries from the left-hand tray-set, we can make this method a lot cleaner.  And once it’s been cleaned-up, we can more easily modify it so that when some Logical Database node “xxx” is selected in the right-hand tree view, three trays will display with different kinds of information on this node:

Where-Clause Columns in “Put” Select for Node xxx

Columns Retrieved by “Put” Select for Node xxx

Retrieved Columns Used by Lower Level “Put” Selects

Plus, if the user should inadvertently select the topmost node of the right-hand tree, we’ll want to suppress the display of the last two trays and use the title of the first tray to display the mesage:

Please select a lower-level LDB node to obtain information on it

The following code acccomplishes all of the above (once one has declared some class variables that we’ll get to in a moment):

***
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,
id type string,
text type string,

v_ldbnode(30) type c,

idf type string,
idw type string,
idu type string,

v_cnt type i.

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.

      if lr_child->id cs mc_where_id or lr_child->id cs mc_ftchd_id or lr_child->id cs mc_used_id.

        m_parent_container->remove_child( id = lr_child->id ).

      endif.

    endloop.

    clear m_where_tray.

    clear m_fetched_tray.

    clear m_used_tray.

  • save the selected context element of the hierarchy tree

  m_hier_tree_selected_element = i_hier_tree_selected_element.

  CASE m_library_name.

    WHEN ‘LGCLDBS’.

      concatenate m_prefix mc_where_id into idw.

      concatenate m_prefix mc_ftchd_id into idf.

      concatenate m_prefix mc_used_id  into idu.

      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.

      m_where_tray = add_tray_to_container(

                     i_id               = idw

                     i_parent_container = m_parent_container

                     i_header_text      = text ).

      IF v_cnt = 0.

        concatenate text-019 ` ` v_ldbnode into text.

        m_fetched_tray = add_tray_to_container(

                         i_id               = idf

                         i_parent_container = m_parent_container

                         i_header_text      = text ).

        text = text-020.

        m_used_tray = add_tray_to_container(

                        i_id               = idu

                        i_parent_container = m_parent_container

                        i_header_text      = text ).

      ENDIF.

    WHEN OTHERS.

  ENDCASE.

endmethod.

****

As will be seen above, there are “m” variables not declared within this method.  Rather, they have to be declared in the

protected

section of

ZCL_WDR_ALL_IN_ONE_UI_ELEM

:

constants MC_WHERE_ID type STRING value ‘WHERE’. “#EC NOTEXT
constants MC_FTCHD_ID type STRING value ‘FTCHD’. “#EC NOTEXT
constants MC_USED_ID type STRING value ‘USED’. “#EC NOTEXT

data M_WHERE_TRAY type ref to CL_WD_TRAY .
data M_FETCHED_TRAY type ref to CL_WD_TRAY .
data M_USED_TRAY type ref to CL_WD_TRAY .

And, of course, one will have to associate four text-elements with the new

on_select_view_element

method shown above:

text-017: Where-Clause Columns in “Put” Select for Node

text-019: Columns Retrieved by “Put” Select for Node

text-020: Retrieved Columns Used by Lower Level “Put” Selects

text-018: Please select a lower-level LDB node to obtain information on it

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