‎2007 Feb 01 2:48 AM
Hi everyone,
I would just like to know if it is possible to sort 2 fields using slis_sortinfo_alv. If yes, how do I write the code? This is my code for the slis_sortinfo_alv. Please help me.
ls_sort-fieldname = 'KHINR'.
ls_sort-fieldname = 'KOSTL'.
ls_sort-subtot = 'X'.
ls_sort-tabname = 'ITAB'.
APPEND ls_sort TO lt_sort.
Thanks a lot in advance.
Anna Bechayda
‎2007 Feb 01 5:25 AM
Yes it is possible.
ls_sort-fieldname = 'KOSTL'.
ls_sort-subtot = 'X'.
ls_sort-tabname = 'ITAB'.
ls_sort-up = 'X'.
APPEND ls_sort TO lt_sort.
‎2007 Feb 01 2:55 AM
Yes, but you need to write two records to the internal table.
clear ls_sort.
ls_sort-fieldname = 'KHINR'.
ls_sort-subtot = 'X'.
ls_sort-up = 'X'.
ls_sort-tabname = 'ITAB'.
APPEND ls_sort TO lt_sort.
clear ls_sort.
ls_sort-fieldname = 'KOSTL'.
ls_sort-subtot = 'X'.
ls_sort-up = 'X'.
ls_sort-tabname = 'ITAB'.
APPEND ls_sort TO lt_sort.Regards,
Rich Heilman
‎2007 Feb 01 3:10 AM
Thanks for your reply sir. But my other problem is that I need to subtotal the field "KHINR" sorting KOSTL. Below is the sample output. Is this possible sir? Thanks so much in advance.
FXNAL Group RC # Basic Salary
BOARDTRUST 100 366,864.00
BOARDTRUST 101 191,304.00
BOARDTRUST 102 209,982.00
BOARDTRUST 103 187,737.00
BOARDTRUST 104 192,109.00
BOARDTRUST 105 108,129.00
BOARDTRUST 106 144,929.00
BOARDTRUST 107 191,412.00
BOARDTRUST 108 187,737.00
BOARDTRUST 110 986,307.00
BOARDTRUST 114 240,153.00
BOARDTRUST Total 3,006,663.00
‎2007 Feb 01 3:16 AM
This is a much better example of the sample. Thanks in advance.
Thanks for your reply sir. But my other problem is that I need to subtotal the field "KHINR" sorting KOSTL. Below is the sample output. Is this possible sir? Thanks so much in advance.
KHINR KOSTL Basic Salary
BOARDTRUST 100 366,864.00
BOARDTRUST 101 191,304.00
BOARDTRUST 102 209,982.00
BOARDTRUST 103 187,737.00
BOARDTRUST 104 192,109.00
BOARDTRUST 105 108,129.00
BOARDTRUST 106 144,929.00
BOARDTRUST 107 191,412.00
BOARDTRUST 108 187,737.00
BOARDTRUST 110 986,307.00
BOARDTRUST 114 240,153.00
BOARDTRUST Total 3,006,663.00
Message was edited by: Anna
Anna Bechayda
‎2007 Feb 01 3:33 AM
It is a little tricky, try.....
clear ls_sort.
ls_sort-fieldname = 'KHINR'.
ls_sort-up = 'X'.
ls_sort-subtotal = 'X'.
ls_sort-tabname = 'ITAB'.
APPEND ls_sort TO lt_sort.
clear ls_sort.
ls_sort-fieldname = 'KOSTL'.
ls_sort-up = 'X'.
ls_sort-tabname = 'ITAB'.
APPEND ls_sort TO lt_sort.
Regards,
Rich Heilman
‎2007 Feb 01 5:00 AM
Hi again. Is it possible for the field "KHINR" not to be sorted? What needs to be sorted only is the "KOSTL" and then the field "KHINR" will be sub-totalled. Is this possible?
‎2007 Feb 01 5:25 AM
Yes it is possible.
ls_sort-fieldname = 'KOSTL'.
ls_sort-subtot = 'X'.
ls_sort-tabname = 'ITAB'.
ls_sort-up = 'X'.
APPEND ls_sort TO lt_sort.
‎2007 Feb 01 5:43 AM
Hi Ms Sadiqulla,
Thanks for your reply. The thing is if I try to sort it by field "KOSTL", it is not sub-totalled by field "KHINR" but by "KOSTL", when what i need for the sub-total is by "KHINR" but sorted by "KOSTL". Is this possible? I tried doing this code as well:
ls_sort-fieldname = 'KHINR'.
ls_sort-up = 'X'.
ls_sort-subtot = 'X'.
ls_sort-tabname = 'ITAB'.
APPEND ls_sort TO lt_sort.
clear ls_sort.
ls_sort-fieldname = 'KOSTL'.
ls_sort-up = 'X'.
ls_sort-tabname = 'ITAB'.
APPEND ls_sort TO lt_sort.
But it sorted by KHINR. And if I do this code:
clear ls_sort.
ls_sort-fieldname = 'KOSTL'.
ls_sort-up = 'X'.
ls_sort-tabname = 'ITAB'.
APPEND ls_sort TO lt_sort.
clear ls_sort.
ls_sort-fieldname = 'KHINR'.
ls_sort-up = 'X'.
ls_sort-subtot = 'X'.
ls_sort-tabname = 'ITAB'.
APPEND ls_sort TO lt_sort.
It sub-totalled by KOSTL.
Please help me.
Thanks in advance.
Message was edited by: Anna
Anna Bechayda
‎2007 Feb 01 5:49 AM
You try passing do_sum parameter in fieldcat.
fieldcat_temp-col_pos = 2.
fieldcat_temp-fieldname = 'KHINR'.
fieldcat_temp-do_sum = 'X'.
append fieldcat_temp to fieldcat.
‎2007 Feb 01 5:52 AM
if you want subtotal for khinr then this code is correct
ls_sort-fieldname = 'KHINR'.
*ls_sort-up = 'X'.
ls_sort-subtot = 'X'.
ls_sort-tabname = 'ITAB'.
APPEND ls_sort TO lt_sort.
clear ls_sort.
ls_sort-fieldname = 'KOSTL'.
ls_sort-up = 'X'.
ls_sort-tabname = 'ITAB'.
APPEND ls_sort TO lt_sort.
but if you dont want to sort khinr comment that as per my above code but i dont know why you required this because it may give some thing unusual.
regards
shiba dutta
‎2007 Feb 01 5:52 AM
‎2007 Feb 01 7:08 AM