‎2007 Apr 18 2:31 PM
Hi ,
I have an internal table as given below. I need to display the O/P by Sorting according to POSNR.
Before sorting :_
POSNR MATNR FLAG LFIMG VRKME MAKTX
120 |000000000000716740| B |10 |ST |Pallet (Euro)
40 |000000000000716740| B |10 |ST |Pallet (Euro)
50 |000000000000716790| B |10 |ST |Pallet (BPD)
130 |000000000000716809| B |10 |ST |Pallet (BPD)
60 |000000000000716809| B |10 |ST |Pallet (BPD)
70 |000000000000716810| B |10 |ST |Container
80 |000000000000716812| B |10 |ST |RIC
Am using statement - SORT t_empties BY POSNR.
After Sorting:-
POSNR MATNR FLAG LFIMG VRKME MAKTX
120 |000000000000716740 |B |10 |ST |Pallet ro)
130 |000000000000716809 |B |10 |ST |Pallet (BPD)
40 |000000000000716740 |B |10 |ST |Pallet (Euro)
50 |000000000000716790 |B |10 |ST |Pallet (BPD)
60 |000000000000716809 |B |10 |ST |Pallet (BPD)
70 |000000000000716810 |B |10 |ST |Container
80 |000000000000716812 |B |10 |ST |RIC
Can any one ples let me know why its not getting sorted correctly
regards
Avi
‎2007 Apr 18 2:43 PM
try this
loop at itab into wa_itab.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_itab-posnr.
IMPORTING
output = wa_itab-posnr.
modify itab from wa_itab.
endloop.<b>SORT ITAB BY POSNR.</b>
‎2007 Apr 18 2:35 PM
By default it should sort on ascending, may be tru to use ASCENDING key word in SORT statement and see.
‎2007 Apr 18 2:36 PM
Hi
Keep the POSNR as first field in the internal Table and then it will come correctly
reward if useful
regards,
Anji
‎2007 Apr 18 2:40 PM
How is the field POSNR defined? It needs to be numeric for the sort to work the way that you want it to. It looks to me like the sort is treating POSNR as a character field, with the values being left-justified (the 1 in 120 comes before the 4 in 40).
- April King
‎2007 Apr 18 2:43 PM
try this
loop at itab into wa_itab.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_itab-posnr.
IMPORTING
output = wa_itab-posnr.
modify itab from wa_itab.
endloop.<b>SORT ITAB BY POSNR.</b>
‎2007 Apr 18 2:47 PM
Hi ..
it is considering the POSNR according to the starting number..
do one thing..take <b>POSNR field data type as N</b>.
thhis will solve ur problem..
Ram
‎2007 Apr 18 3:00 PM
hi Alexander,
I tried with keeping ASCENDING . Its not working.
hi Anji,
Its the FIRST Field of internal table
hi April King,
The internal table is defined according to a Structure created
inside the strcuture its defined as:-
POSNR Component Type = POSNR, Data Type = NUMC
Regards
Avi....
‎2007 Apr 18 3:03 PM
‎2007 Apr 18 3:09 PM
There are two things I would suggest trying.
1) You could define POSNR as TYPE N instead of NUMC.
or
2) When you are moving values to POSNR, fill the leading characters with zeroes. This will effectively right justify your field and should result in the correct sort order.
- April
‎2007 Apr 18 3:21 PM