cancel
Showing results for 
Search instead for 
Did you mean: 

Changing the order of the nodes using the RS_TREE FMs

Former Member
0 Kudos

Dear developer community,

I'm generating a standard SAP tree structure using the

Function Modules RS_TREE_CREATE, RS_TREE_ADD_NODE and

RS_TREE_LIST_DISPLAY. The result looks good. The only thing that bothers me and prevents me from calling this job finished is that the sorting order on each hierarchy level is exactly top-down, the nodes added at last are displayed first and vice versa. In the FM-parameters as well as in the node-datastructures I don't find anything that seems to offer me to take influence on the sorting order. Anyway: Due to the very special way we collect the information that finally is supposed to be displayed hierarchically, changing the order of the node-generation unfortunetaly is not an option !

Does anybody have experience with this group of FMs who could tell me how this can be achieved ?

Thanks in advance

Andreas

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi andreas,

1. what i do is

2. in the internal table

SNODETEXT,

there is a field NAME

3. In that field, i pass

a counter (data type i)

and i keep on increasing the counter,

every time i add a node to the tree.

4. thats all.

regards,

amit m.

Former Member
0 Kudos

Hello Amit,

filling an own counter-value into the name doesn't

change much, but after doing so it is possible to

apply the FM RS_TREE_SORT_CHILDREN to it.

I granted points for a helpful answer - thanks a lot.

(Meanwhile I found out that this FM can also be applied to the field "ID" of all "parents" in SNODETEXT which sets the display order back to the initial order in which the nodes had been added to the structure - which is exactly what I wanted!.

regards

Andreas

Former Member
0 Kudos

Hello,

in use the CL_COLUMN_TREE_MODEL class to build the column tree, then you can do it this way:

lt_nodes-node_key = 'XXXXX'

lt_nodes-relatship = cl_column_tree_model=>relat_last_child.

...

This will insert the node as the last node of the parent node (lt_nodes-relatkey).

There is a similar parameter "relationship" at the mentioned function model. I don't know exactly, but I can image that it works the same way.

Best regards,

Stefan

Answers (0)