2007 Sep 11 10:25 AM
hi guys,
now i have an internal table with a field of 10 character type length, i need to sort by this field descending and its value could be numeric or character.
this is order i want TR109, for example,
this the order i got now TR910, 'cause by byte compare 9 is greater that 1.
so how to sort this kind of table, is there any FM?
thanks
2007 Sep 11 10:49 AM
Hi Derek,
Can you use a conversion exit before population your internal table like below:
DATA : BEGIN OF tab OCCURS 10,
field TYPE char10,
END OF tab.
CALL 'CONVERSION_EXIT_ALPHA_INPUT' ID 'INPUT' FIELD '9'
ID 'OUTPUT' FIELD tab-field.
APPEND tab.
CALL 'CONVERSION_EXIT_ALPHA_INPUT' ID 'INPUT' FIELD 'TR'
ID 'OUTPUT' FIELD tab-field.
APPEND tab.
CALL 'CONVERSION_EXIT_ALPHA_INPUT' ID 'INPUT' FIELD '10'
ID 'OUTPUT' FIELD tab-field.
APPEND tab.
SORT tab DESCENDING.
LOOP AT tab.
WRITE:/ tab-field.
ENDLOOP.
Regards,
Chester
2007 Sep 11 10:29 AM
2007 Sep 11 10:49 AM
2007 Sep 11 10:49 AM
Hi Derek,
Can you use a conversion exit before population your internal table like below:
DATA : BEGIN OF tab OCCURS 10,
field TYPE char10,
END OF tab.
CALL 'CONVERSION_EXIT_ALPHA_INPUT' ID 'INPUT' FIELD '9'
ID 'OUTPUT' FIELD tab-field.
APPEND tab.
CALL 'CONVERSION_EXIT_ALPHA_INPUT' ID 'INPUT' FIELD 'TR'
ID 'OUTPUT' FIELD tab-field.
APPEND tab.
CALL 'CONVERSION_EXIT_ALPHA_INPUT' ID 'INPUT' FIELD '10'
ID 'OUTPUT' FIELD tab-field.
APPEND tab.
SORT tab DESCENDING.
LOOP AT tab.
WRITE:/ tab-field.
ENDLOOP.
Regards,
Chester
2007 Sep 11 11:08 AM
Chester Drawers
thanks, gave u the points
as text is not working~~~
2007 Sep 11 10:56 AM
Hi
Try this..
SORT ITAB BY <FIELD> AS TEXT.
<b>reward if Helpful</b>