09-26-2012 11:12 AM
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?
09-26-2012 12:24 PM
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.
09-26-2012 12:24 PM
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.
09-27-2012 9:58 AM
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.
09-27-2012 10:18 AM
10-05-2012 7:49 AM
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