‎2008 Jul 17 2:02 PM
Hi experts,
I have a SAP Tree made using the class cl_simple_tree_model.
I add nodes to it calling the method add_node.
That is working, but the order of nodes of level one has been inverted. That is, the first node that is added appear in the last position of tree.
That occurs only with the nodes of level one.
How can I solve this?
Regards,
Charles
‎2008 Jul 17 2:10 PM
l_nodekey = object->nodekey( ).
l_node_name = object->name( ).
call method object_tree->add_node
exporting
node_key = l_nodekey
relative_node_key = root_node_title
isfolder = abap_false
text = l_node_name.
l_object_ref_wa-name = l_nodekey.
l_object_ref_wa-reference = object.
append l_object_ref_wa into table object_table.
are you using Append or Insert.
Use APPEND , instead of Insert. Append will add the nodes one by one. But in your case insert may be adding at the first. i m not sure. If you can show the add_node logic then i can tell you.
Regards
Vijay Babu Dudla
‎2008 Jul 17 2:10 PM
l_nodekey = object->nodekey( ).
l_node_name = object->name( ).
call method object_tree->add_node
exporting
node_key = l_nodekey
relative_node_key = root_node_title
isfolder = abap_false
text = l_node_name.
l_object_ref_wa-name = l_nodekey.
l_object_ref_wa-reference = object.
append l_object_ref_wa into table object_table.
are you using Append or Insert.
Use APPEND , instead of Insert. Append will add the nodes one by one. But in your case insert may be adding at the first. i m not sure. If you can show the add_node logic then i can tell you.
Regards
Vijay Babu Dudla
‎2008 Jul 17 2:35 PM
Hi Vijay,
I´m using append. Although I´m sure that if I was using insert the result would be the same.
Here is the logic:
IF v_relative_node_key = 0.
CALL METHOD g_tree->add_node
EXPORTING
node_key = l_node_key
text = l_text
isfolder = l_isfolder
EXCEPTIONS
OTHERS = 1.
ELSE.
CALL METHOD g_tree->add_node
EXPORTING
node_key = l_node_key
text = l_text
relative_node_key = l_relative_node_key
relationship = l_relationship
isfolder = l_isfolder
EXCEPTIONS
OTHERS = 1.
ENDIF.
‎2008 Jul 17 2:47 PM
Sorry - we clearly cross-posted.
In your method call for the first level , you do not supply the parameter relationship. This means that its default value of zero is used. However, zero is also the value of the constant cl_simple_tree_model=>relat_first_child, which means that the last node inserted is at the top of the branch.
To append a new node to the bottom of the current level, your method call should include the parameter
relationship = cl_simple_tree_model=>relat_last_sibling.
Hope this helps
Jon.
‎2008 Jul 17 2:52 PM
‎2008 Jul 17 2:37 PM