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

regarding sorting the field.

Former Member
0 Likes
985

Hi Team.

i have a requirement as below mentioned.

POSNR TYPE STRING.

value comes as follows 80 90 100 20 ...so on

i want to sorting this field but i am getting output as follows

100 20 80 90 . but this is wrong i want output as follows 20 80 90 100 . we can't change type string to any . is there any method to sort to posnr value .

Please suggest me.

Thanks in Advance.

Puneet.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
939

Hi,

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = I_POSNR

IMPORTING

OUTPUT = O_POSNR.

convert the posnr using the above FM.then append it to the internal table.

now you can SORT by POSNR. if you want the original value like 10,20 you can have additional field posnr1

for sorting or you can use FM CONVERSION_EXIT_ALPHA_OUTPUT for restore.

Regards

R

6 REPLIES 6
Read only

Former Member
0 Likes
939

Hi Puneet,

Can you show us the statement for the sorting of the internal table.

As of now I am writting you the sample statement for this.


SORT ITAB BY POSNR.

Try this statement just remove itab and enter your internal table name.

Thanks,

Chidanand

Read only

0 Likes
939

hi team,

I have tried with SORT itab by posnr. but it's string so taking sort with first character and based on first character due to sorting output comes as follows : 100 20 80 90.

Read only

Former Member
0 Likes
939

Its a string field and not a numeric field. Hence your result is like that.

Since you can't change the type from string to something like a type N, You could try to add leading zeroes to each value and sort then, Just choose a certain max length to do so.

Example.

Assume your position number will not exceed a length of 6 positions, then 6 is your max length.

When you add leading zeroes, the values will turn into:

000100

000080

000090

000110

and so on.

Btw. i haven't tried this out myself.

Read only

Former Member
0 Likes
939

Hi,

U can add another field in that internal table of type POSNR and copy this posnr values to that field...

Then sort on that field...

Read only

Former Member
0 Likes
939

Hi,

Refer to this thread

Regards

Manasa

Read only

Former Member
0 Likes
940

Hi,

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = I_POSNR

IMPORTING

OUTPUT = O_POSNR.

convert the posnr using the above FM.then append it to the internal table.

now you can SORT by POSNR. if you want the original value like 10,20 you can have additional field posnr1

for sorting or you can use FM CONVERSION_EXIT_ALPHA_OUTPUT for restore.

Regards

R