‎2016 Jul 26 3:04 PM
Hey guys, I have an ALV Grid that needs to display a column of numbers with units at the end. the unit may change example Kg, mm, cm. Within the ALV, if they click on the sorting buttons, it does not sort correctly.It is because as a string it sorts differently from how numbers sort.. Example data: 1. 850,000 mm 2. 77,000 mm 3. 740,000 mm It sorts the data as : 1. 740,000mm 2.77,000 mm 3. 850,000 mm Instead it should sort data as: 1. 77,000mm 2.740,000 mm 3. 850,000 mm. Please help me. I have checked the following discussion, but was not helpful. https://scn.sap.com/thread/3429747 Regards Dilip S
‎2016 Jul 27 5:28 AM
Hi,
For your knowledge the sorting is done using the internal format of the field .
For demonstration I formatted a date field using FUNCTION 'CONVERSION_EXIT_SDATE_OUTPUT' .
And I get:
Note that the months are sorted based on the actual value.
So it seems that you can format you internal data into a "sortable" format .
Using the exit you can present the internal data to the user as required .
Regards.
Eitan.
‎2016 Jul 26 3:16 PM
Hi Dilip,
I would suggest adding an additional numeric column that represents each of the number values and then sort the ALV table by that field but make it a hidden field. Treating the output as String instead of numeric will affect how the data is sorted.
Regards,
Ryan Crosby
‎2016 Jul 26 3:23 PM
Hi Ryan,
Thanks for your quick response.
Adding one more column to the ALV is not feasible in my situation. It would be great , if there ais any other way.
Thanks in advance.
Regards
Dilip S
‎2016 Jul 26 3:29 PM
Hi,
I think that you can use Sorting Numeric Characters as numbers | SCN
as a base but in your case you need to format the data differently:
<unit measure> <SPACE> <numeric value> .
Regards.
‎2016 Jul 26 4:26 PM
It sorts the data as :
1. 740,000mm
2. 77,000 mm
3. 850,000 mm
Instead it should sort data as:
1. 77,000mm
2.740,000 mm
3. 850,000 mm
If the columns is of type QUAN for quantity field, it will sort as required.
Probably the ALV output field is type character.
Regards, Clemens
‎2016 Jul 26 4:48 PM
Dilip Kumar Subramaniam wrote:
I have checked the following discussion, but was not helpful. https://scn.sap.com/thread/3429747
(the thread is proposing a numeric field + a conversion routine)
May we know why you can't implement the solution in that thread, which is obviously the best choice?
Although I'm not fan of adding a column to the ALV, may we know why you can't add it?
I'd like to know, because it will avoid us proposing useless solutions again.
‎2016 Jul 27 5:28 AM
Hi,
For your knowledge the sorting is done using the internal format of the field .
For demonstration I formatted a date field using FUNCTION 'CONVERSION_EXIT_SDATE_OUTPUT' .
And I get:
Note that the months are sorted based on the actual value.
So it seems that you can format you internal data into a "sortable" format .
Using the exit you can present the internal data to the user as required .
Regards.
Eitan.