Skip to Content

Hierarchical table

Hi experts,

I have a hierarchical table. This is a normal Table with a mastercolumn, and the mastercolumn is binded to a recursive context node. The context node has a supply function which reads the data when the tree is selected in the table.

My question is: Is there a was to expand all nodes of the table? As I see this cannot be done, because even if I call the supply function, with the parent element, I cant provide the "node" parameter of the supply function..

Am I right?

Thanks

N.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Dec 05, 2011 at 10:14 AM

    May be because it is recursive you were not able to do that.....Can you be more clear.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 16, 2011 at 10:31 AM

    Hello everyone,

    It's possible here is the solution (You start calling this recursive method form an action where you get the root of your tree):

    METHOD rec_subobj .
      DATA: ls_nodes      TYPE wdr_context_child,
            lt_nodes      TYPE wdr_context_child_map,
            lt_all_nodes  TYPE wdr_context_child_map,
            lt_elements   TYPE wdr_context_element_set,
            lref_element  TYPE REF TO if_wd_context_element,
            lt_subobj TYPE wd_this->elements_bonus_sub_obj,
            ls_subobj TYPE wd_this->element_bonus_sub_obj,
            lv_counter TYPE NUMC3.
    
    
      LOOP AT pt_nodes INTO ls_nodes.
    *    First set the expanded flag.
        CALL METHOD ls_nodes-node->get_static_attributes_table
          IMPORTING
            table = lt_subobj.
        LOOP AT lt_subobj INTO ls_subobj.
          ls_subobj-expanded = abap_true.
          MODIFY lt_subobj FROM ls_subobj.
        ENDLOOP.
        ls_nodes-node->bind_table( lt_subobj ).
    *   We've expanded on the current level, now colect the subobjects and recall this function
        CALL METHOD ls_nodes-node->get_elements
          RECEIVING
            set = lt_elements.
        LOOP AT lt_elements INTO lref_element.
          lref_element->get_static_attributes( IMPORTING    static_attributes = ls_subobj ).
          CALL METHOD lref_element->get_child_nodes
            RECEIVING
              child_nodes = lt_nodes.
    *     lt nodes is a hashed table
          LOOP AT lt_nodes INTO ls_nodes.
    *       lt_nodes is a hashed table, so we have to change the name :)
            CONCATENATE ls_nodes-name lv_counter INTO ls_nodes-name.
            INSERT ls_nodes  INTO TABLE lt_all_nodes.
            lv_counter = lv_counter + 1.
          ENDLOOP.
        ENDLOOP.
      ENDLOOP.
    
      IF lt_all_nodes IS NOT INITIAL.
        wd_this->rec_subobj(  pt_nodes =  lt_all_nodes    ).
      ENDIF.
    
    ENDMETHOD.
    

    I should be able to give points to myself 😊

    Add comment
    10|10000 characters needed characters exceeded