Application Development and Automation 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: 
Read only

sort text internale table

Former Member
0 Likes
797

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 ‘TR’‘10’‘9’, for example,

this the order i got now ‘TR’‘9’‘10’, 'cause by byte compare 9 is greater that 1.

so how to sort this kind of table, is there any FM?

thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
682

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

5 REPLIES 5
Read only

Former Member
0 Likes
682

CATT_SORT_TABLE

use this FM...may it help u

Read only

0 Likes
682

too complicated FM,hehe~~~

Read only

Former Member
0 Likes
683

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

Read only

0 Likes
682

Chester Drawers

thanks, gave u the points

as text is not working~~~

Read only

varma_narayana
Active Contributor
0 Likes
682

Hi

Try this..

SORT ITAB BY <FIELD> AS TEXT.

<b>reward if Helpful</b>