Skip to Content

set relation in cl_simple_tree_model for existing node

Hi there!

I am struggeling with inserting a node at a specific position using the cl_simple_tree_model.

I build up a tree structure. No big deal.

Let's say I display customer orders and the order items as child nodes.

Then the user changes the customer order and changes, adds or deletes items. I don't want to make fuzz about every single item and check if it's still there, has been deleted or added or if the text has changed or status has changed and so on.

My idea was to simply delete the node of the customer order and rebuild it completely. That's also possible and I can add the new nodes using method ADD_NODES and ADD_ITEMS.

BUT: I can only add the nodes using the relationships

  • First/ Next/ Last child
  • First/ Next/ Last sibling

So an order "in the middle" will be placed at the top (first child) or bottom (last child) of the structure.

How can I place the "updated" node at exactly the same position as before?

thanks for any idea!


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Feb 09, 2018 at 02:56 PM

    It's so easy... *head->table*

    Method ADD_NODE and ADD_NODES have the importing parameter "RELATIVE_NODE_KEY".

    If you want to "Update" the current node you just have to add the updated nodes with RELATIVE_NODE_KEY = new_node_key and RELATIONSHIP = next_sibling or prev_sibling. Then you delete the old node.

    If you have unique node-keys, like order number, or material number, then you first have to check NODE_GET_PREV_SIBLING, then delete the old node and afterwards add the new nodes with RELATIVE_NODE_KEY = prev_sibling_of_old_node and RELATIONSHIP = next_sibling.

    If there is no previous sibling, then you have to find out the parent NODE_GET_PARENT and set relationship to first_child.

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 08, 2018 at 05:43 PM


    I always rebuild the tree completely on any change, so I only have to deal with inserts, updates, deletes, sortorder, ... in my ITab(s) and dont really care about this in Tree build methods.

    And since the tree is UI (mostly with user interaction) I try to keep it short and readable and therefore had nevere any performance issues regarding tree rebuild or GUI transfer!

    If anyone has a better (delta) solution - I would use it!



    Add comment
    10|10000 characters needed characters exceeded

    • Hi

      Yea, I do understand - that's why I try to keep the tree "short and readable"

      User only need 5, 10 maybe 20 orders on one screen, so you could add some filter or search criteria?

      I often use a hyperlink in the 1st root item to add an filter via a popup.