<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: CL_SALV_TREE key node problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-salv-tree-key-node-problem/m-p/4924667#M1149033</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are not doing exact same as the demo program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check Subroutine SUPPLY_DATA in the program SALV_DEMO_TREE_SIMPLE. First it fills the node for the CARRID. Than it fills the node for the CONNID using the key of the CARRID and after that it fills the data with relation to the node CONNID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are trying to use the key generated in the previous node for the current node. So, it will generate the Tree with the each record as a child of th previous node. &lt;/P&gt;&lt;P&gt;Like:&lt;/P&gt;&lt;P&gt;ROOT&lt;/P&gt;&lt;P&gt;.. Record1&lt;/P&gt;&lt;P&gt;.... Record2&lt;/P&gt;&lt;P&gt;...... Record3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.......... Recordn&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Dec 2008 14:46:40 GMT</pubDate>
    <dc:creator>naimesh_patel</dc:creator>
    <dc:date>2008-12-23T14:46:40Z</dc:date>
    <item>
      <title>CL_SALV_TREE key node problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-salv-tree-key-node-problem/m-p/4924666#M1149032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am strugling with class &lt;STRONG&gt;cl_salv_tree&lt;/STRONG&gt;. I want to build a tree based on entries from a table. Each entry should be related to its supernode as a child (so we had same number of nodes as number of rows in table). &lt;/P&gt;&lt;P&gt;I have the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: ref_nodes TYPE REF TO cl_salv_nodes,
          new_node  TYPE REF TO cl_salv_node,
          key_node  TYPE salv_de_node_key.
...

"get all nodes
ref_nodes = ref_table-&amp;gt;get_nodes( ).

LOOP AT gt_sflight INTO wa_sflight.
    IF sy-tabix = 1.
      key_node = space.   "first entry is child of root node
    endif.

    "here my problem starts...
    TRY.
        new_node = ref_nodes-&amp;gt;add_node(
                related_node   = key_node
                data_row       = wa_sflight
                relationship   = cl_gui_column_tree=&amp;gt;relat_last_child ).   "add row a child 

        "get new row's key
        key_node = new_node-&amp;gt;get_key( ).
      CATCH cx_salv_msg .
    ENDTRY.
  ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is that only first entry is added to tree, hence as a result I have one node which is child of ROOT node.&lt;/P&gt;&lt;P&gt;I am wondering where is the error. I look through demo &lt;STRONG&gt;SALV_DEMO_TREE_SIMPLE&lt;/STRONG&gt; but it seems my logic is correct here. Can you please help me to identify my bug?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Dec 2008 14:30:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cl-salv-tree-key-node-problem/m-p/4924666#M1149032</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2008-12-23T14:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: CL_SALV_TREE key node problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-salv-tree-key-node-problem/m-p/4924667#M1149033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are not doing exact same as the demo program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check Subroutine SUPPLY_DATA in the program SALV_DEMO_TREE_SIMPLE. First it fills the node for the CARRID. Than it fills the node for the CONNID using the key of the CARRID and after that it fills the data with relation to the node CONNID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are trying to use the key generated in the previous node for the current node. So, it will generate the Tree with the each record as a child of th previous node. &lt;/P&gt;&lt;P&gt;Like:&lt;/P&gt;&lt;P&gt;ROOT&lt;/P&gt;&lt;P&gt;.. Record1&lt;/P&gt;&lt;P&gt;.... Record2&lt;/P&gt;&lt;P&gt;...... Record3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.......... Recordn&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Dec 2008 14:46:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cl-salv-tree-key-node-problem/m-p/4924667#M1149033</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2008-12-23T14:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: CL_SALV_TREE key node problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-salv-tree-key-node-problem/m-p/4924668#M1149034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Namesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, you are right, but I want to achieve excatly what you shaped in your diagram: each new entry shoud be a child of previous node (I know strange case but this is how I want it to work).&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;The problem is that only first entry is added to the tree (when key_node = space). Later when &lt;STRONG&gt;key_node&lt;/STRONG&gt; stores new entry (of the previous node) it is not added anymore. As a result I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Record1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;without further substucture. &lt;/P&gt;&lt;P&gt;Moreover &lt;STRONG&gt;get_node&lt;/STRONG&gt; method returns key of newly created node, so it seems ok as far as the logic is concerned. Any clues?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Dec 2008 14:56:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cl-salv-tree-key-node-problem/m-p/4924668#M1149034</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2008-12-23T14:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: CL_SALV_TREE key node problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-salv-tree-key-node-problem/m-p/4924669#M1149035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh ok...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried by copying the SALV_DEMO_TREE_SIMPLE to Z report and changed the logic in the SUPPLY_DATA and it gave me what you are trying to achieve.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  loop at lt_outtab into ls_data.

    IF sy-tabix = 1.
      l_last_key = space.   "first entry is child of root node
    endif.

    perform add_complete_line using  ls_data
                                     l_last_key
                            changing l_last_key.
  endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not sure, how much deep hierarchy we could have. If you have much data than it would be a good idea to do it like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Dec 2008 15:09:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cl-salv-tree-key-node-problem/m-p/4924669#M1149035</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2008-12-23T15:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: CL_SALV_TREE key node problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-salv-tree-key-node-problem/m-p/4924670#M1149036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hehe funny situation, or rather stupid one.&lt;/P&gt;&lt;P&gt;The tree was populated right, but all I had to do was optimizing width of header line (lr_columns-&amp;gt;set_optimize( gc_true )), as I couldn't see &lt;STRONG&gt;hierarchy column&lt;/STRONG&gt; which was there, but hidden;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course Naimesh you helped me a lot. I copied standard program and compared it to mine, thus answering my query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you and regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Dec 2008 15:40:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cl-salv-tree-key-node-problem/m-p/4924670#M1149036</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2008-12-23T15:40:06Z</dc:date>
    </item>
  </channel>
</rss>

