Skip to Content
Technical Articles
Author's profile photo Shantanu Sharma

Deletion of Nodes in Column Tree

This blog post is to share how our team (UI Data Protection Masking for SAP S/4HANA) was able to solve a problem uniquely.

As part of our Policy Builder, we needed a column tree to provide a better UI for the user. We used the class ‘ CL_GUI_COLUMN_TREE’ to create the tree.

To provide a better sense, our display looks like this :

Our aim is to allow the user to delete a Node (eg: Block: SE16 or Block: PA30) from the tree. Scanning through the documentation of the class (CL_GUI_COLUMN_TREE). We found the method  DELETE_NODE.

This method worked fine for a single node, but when we had multiple nodes, we got a short dump :



The analysis of the dump revealed that the reconstruction of the column tree is not handled implicitly through the method. We tried to look for a solution through SAP blog posts and question. (s).

We could not find a fix for this and all the blog posts gave us little hope on how well the COLUMN_TREE as a data structure is suited for deletion. So, we came up with a solution of our own.

As a fix, we modified our mappings before calling this method.

To avoid the need for reconstruction, we saved the NODE_ID of the node which was selected for deletion and implicitly moved it to the bottom of the Column tree and then re-adjusting our database table accordingly.  This allowed the standard method to always delete a leaf node from the tree and circumvent the scenario which was failing.

      IF lv_answer = 1 AND lv_node_id NE lv_last_node_id.
        "Move the node to the last node first and then delete it.
        WHILE lv_count <> ( lv_last_node_id - lv_selected_node_id ).
              iv_operation   = 'D'
              iv_node_key    = lv_node_id
              iv_item_name   = lv_item_name
              ct_policy_rule = ct_policy_rule
          lv_node_id = lv_node_id + 1.
          lv_count = lv_count + 1.
          CONDENSE lv_node_id.

          node_key          = lv_node_id
          failed            = 1
          node_not_found    = 2
          cntl_system_error = 3
          OTHERS            = 4


I feel, our out-of-the-box thinking will have two advantages –

  1. Provide developers a way to perform deletion in their column tree.
  2. Motivate others to solve problems through an experimental approach.


We also welcome any thoughts of a better approach to handle such scenarios.


Image sources: Screenshots.



Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Egor Malov
      Egor Malov

      Hi, Shantanu, thank you, that’s an interesting approach!

      Some random thoughts:

      • I think I had a similar dump with CL_GUI_SIMPLE_TREE. I also tried to make the node to be deleted a leaf node before actual deletion, but the idea was to delete all the hierarchy below  (can be implemented with recursive code)
      • This online documentation of delete_node explicitly states that “If the node is a folder, all of its child nodes will be deleted as well”,so, maybe, the proper solution is to find and apply some SAP note/correction? (
      • I looked through some standard code and I found an interesting example: they first call delete_all_items_of_nodes and then delete_nodes. I wonder, maybe it is the presence of these ‘items’ that is the real cause of the dump, and not the child nodes?


      Author's profile photo Shantanu Sharma
      Shantanu Sharma
      Blog Post Author

      Hi Egor,

      • I am unsure about how basic functions work in the CL_GUI_SIMPLE_TREE. If you have some interesting cases please share it with me. We are still looking to add a few functionalities to this UI.


      • Through this approach, we are able to delete the folder and its children, I will have to check if an SAP note/correction exists already.


      • Items are essentially the descriptions we have in the tree. In an ideal scenario, delete should work irrespective of their presence.
      Author's profile photo Sandra Rossi
      Sandra Rossi

      I have a remark about the title: the term "ALV column tree" is not wrong, but the most-used name is just "ALV tree", as it's always based on the basic "column tree" control; but your post is about column trees, which are not always ALV trees. So maybe you could remove the word "ALV" from the title.

      I second what has said Egor, that if DELETE_NODE makes the frontend fail, it's just that the ABAP code which does DELETE_NODE is buggy. What is also important to add is that if the deleted node was a unique child node and its parent node was declared as a folder. To avoid this short dump, you also need to check that case, and change its parent node to not be a folder.

      Author's profile photo Shantanu Sharma
      Shantanu Sharma
      Blog Post Author

      Hi Sandra,

      Thanks for your suggestions. I agree that this blog post is for Column Trees in general. I have made the changes to the title.

      We are using this Tree as part of an editable UI to build customized security policies. Besides the root node, we can never be too sure of how a user manipulates(inserts/deletes/edits nodes) the tree. Although, we do have to ensure that the parent-child relationship is maintained and is uniform throughout.