‎2008 Nov 05 8:22 AM
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.
‎2008 Nov 05 9:07 AM
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
‎2008 Nov 05 8:25 AM
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
‎2008 Nov 05 8:38 AM
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.
‎2008 Nov 05 8:33 AM
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.
‎2008 Nov 05 8:37 AM
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...
‎2008 Nov 05 8:50 AM
‎2008 Nov 05 9:07 AM
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