Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

TREE: order of the nodes?

Former Member
0 Kudos

In the existing programm cl_gui_alv_tree is used. Nodes are displayed in the order of their keys. Now the goal is to change this order, i meen to sort nodes by their items texts. Is anybody know the solution, how to do this without changing the procedure of making tree hierarchy?

2 REPLIES 2

Former Member
0 Kudos

sort the internal table with the item text instead of the the item key and check it before passing the data into the node in the hierarchy creation.

Former Member
0 Kudos

Alek,

You must set the order in the SORT table.

call method l_tree_simple->set_table_for_first_display

exporting

it_list_commentary = lt_list_commentary

i_logo = l_logo

i_background_id = 'ALV_BACKGROUND'

i_save = g_save

i_default = g_default

is_variant = ls_variant

is_layout = ls_layout

it_toolbar_excluding = l_toolbar_excluding

it_grouplevel_layout = lt_grouplevel_layout

changing

it_sort = gt_sort " <==== HERE !!!!

it_outtab = gt_outtab

it_fieldcatalog = gt_fieldcatalog.

Set your sort order in a FORM like this:

form build_sort_table.

data ls_sort_wa type lvc_s_sort.

  • create sort-table

ls_sort_wa-spos = 1.

ls_sort_wa-fieldname = 'CARRID'.

ls_sort_wa-up = 'X'.

ls_sort_wa-subtot = 'X'.

append ls_sort_wa to gt_sort.

ls_sort_wa-spos = 2.

ls_sort_wa-fieldname = 'CONNID'.

ls_sort_wa-up = 'X'.

ls_sort_wa-subtot = 'X'.

append ls_sort_wa to gt_sort.

ls_sort_wa-spos = 3.

ls_sort_wa-fieldname = 'FLDATE'.

ls_sort_wa-up = 'X'.

append ls_sort_wa to gt_sort.

endform. " BUILD_SORT_TABLE