Skip to Content

This will explain you about, how to compare the 2 hierarchies from top to bottom including the node level as well as the name of the node.

Normally we call the function module G_SET_TREE_IMPORT to import all the data in to a table,

call function ‘G_SET_TREE_IMPORT’


no_descriptions = ‘ ‘

no_rw_info = ‘X’

setid = p_setid1


set_hierarchy = lt_hier1

set_values = lt_val1.

After getting all the data in to the internal table we need to add the pointers to that internal table to set the hierarchies

call function ‘G_SET_TREE_ADD_POINTERS’


set_hierarchy = lt_hier1

set_values = lt_val1

set_hier_ptr = lt_hier_ptr1

set_val_ptr = lt_val_ptr1

set_hier_sort = lt_hier_sort1

set_val_sort = lt_val_sort1.

We need to call the above function modules twice to get the 2 hierarchies data, once the data in the internal table, then we need to loop first internal table and check the row in the second internal table data, we need to check the node level as well as the name of the node, here we need to take care of the node I mean whether is it a parent node or a child node.

First, we need to count the nodes in a hierarchy, If the no of nodes is not same then the 2 hierarchies aren’t same, if the number of Nodes are same then we need to check the nodes level with it names, in the above internal table we will get the Node level as well as the name of the node, we will check this data with the second internal table, if the data I mean the node is same then the Node level is correct, like this way we need to check the entire hierarchy with all the nodes and said that the 2 hierarchies or same or not.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. David Halitsky
    There’s another way to do the comparison which is based on the fact that any true tree is “N-free” in the poset sense and can therefore be uniquely rendered as a permutation of the integers 0…n simply by reading the tree in usual pre-order and then “reverse” pre-order (not post-order).  It may be that the two ordering operations on each of these two trees plus the comparison of the two resulting permuations may in fact be quicker, particular if the set is already pre-ordered (as it would be if entered in GS01), since there is then only one ordering operation on each tree instead of two.  Of course, no significant difference would arise unless the trees were fairly large.

Leave a Reply