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: 

Sorting an ALV Tree Developed using cl_gui_alv_tree_simple

Former Member
0 Kudos

I have developed an ALV tree using cl_gui_alv_tree_simple and I want to sort on a field displayed in the table rather than a node of the tree.

ie. the branch is material-type. Open the branch and the associated material numbers display as nodes. However, I don't want to sort the display by material number, I wish to sort by material description. I have tried setting up material description as part of the sort table but it then displays as a node which I don't want. I have tried setting sort-no_out but this has no effect.

Has anyone ever achieved this? Is it even possible?

1 ACCEPTED SOLUTION

former_member392866
Active Participant
0 Kudos

Hi Kevin,

Don't sort any field in settings of sort including description field also.

After getting final data to ITAB , at the time only sort that ITAB by description field.

I hope this will fix you issue.

Regards,

BALAJI.

4 REPLIES 4

former_member392866
Active Participant
0 Kudos

Hi Kevin,

Don't sort any field in settings of sort including description field also.

After getting final data to ITAB , at the time only sort that ITAB by description field.

I hope this will fix you issue.

Regards,

BALAJI.

0 Kudos

Thanks for your offering Balaji. I did manage to sort this out for myself.

I set up two sort fields with the same position. The sort works, but the field declared second does not display.

CLEAR it_sort.
REFRESH it_sort.

wa_sort-spos = 1.
wa_sort-fieldname = 'MTART'.          " material type
APPEND wa_sort TO it_sort.

wa_sort-spos = 2.
wa_sort-fieldname = 'MATNR'.        " material number
APPEND wa_sort TO it_sort.

wa_sort-spos = 2.
wa_sort-fieldname = 'MAKTX'.         " material description
wa_sort-no_out = 'X'.                       " has no effect!
APPEND wa_sort TO it_sort.

When this table is passed to method set_table_for_first_display, the sort is by MTART then MAKTX. MTART displays as the top level node, MATNR as the second level node, MAKTX does not display. Note that setting no_out does not have any effect.

I don't know why this works and it isn't a very tidy solution, but it has worked.

0 Kudos

Kevin,

Are you tried with my solution?

Regards,

BALAJI.

0 Kudos

hi,

its better to give like

  ls_sort-up or

  ls_sort-down fields also

and

may i know y u r using the two fields with same spos

are there any prior checks?

while sorting try to maintaine the fields only on which you want to sort..

write the code in optimized way it resolves many issues...

Regards,

Vasantha