2007 Jan 11 8:20 AM
While sorting the internal table I'm getting one of the columns not sorted .... why is that? for example
A B C
9 2 11
4 9 10
8 3 7
using ---> sort itab by A B C. gives me this
A B C
4 2 7
8 9 10
9 3 11
please help?
2007 Jan 11 8:30 AM
are you sure ? because it gives me
4 | 9 | 10
8 | 3 | 7
9 | 2 | 11
like this and it is the correct one.
regards
shiba dutta
hi Essa,
It would be better if you could sort it with key fields .. and more over the order in which you might have used the sort statement is
sort ITAB by B A C.
Note : Please close your previous theread by marking helpful answers
Regards,
Santosh
2007 Jan 11 8:23 AM
hi Essa,
It would be better if you could sort it with key fields .. and more over the order in which you might have used the sort statement is
sort ITAB by B A C.
Note : Please close your previous theread by marking helpful answers
Regards,
Santosh
2007 Jan 11 8:25 AM
Hi,
When you sort, sort operation will follow the order you give the columns if you give SORT by A B C that order will be taken if you give B A C then that order will be followed.
SO thats why you see that result.
Regards,
Sesh
2007 Jan 11 8:30 AM
are you sure ? because it gives me
4 | 9 | 10
8 | 3 | 7
9 | 2 | 11
like this and it is the correct one.
regards
shiba dutta
2007 Jan 11 8:35 AM
Hi,
check this code,
REPORT ZEX31 .
data : begin of itab occurs 0,
f1 type i,
f2 type i,
f3 type i,
end of itab.
itab-f1 = 9 .
itab-f2 = 2.
itab-f3 = 11 .
append itab.
clear itab.
itab-f1 = 4 .
itab-f2 = 9.
itab-f3 = 10 .
append itab.
clear itab.
itab-f1 = 8 .
itab-f2 = 3.
itab-f3 = 7 .
append itab.
clear itab.
loop at itab.
write : / itab-f1 , itab-f2 , itab-f3.
endloop.
sort itab by f1 f2 f3.
skip 2.
loop at itab.
write : / itab-f1 , itab-f2 , itab-f3.
endloop.
sorting will be based on the order u give,
if u give order f1 f2 f3 then first f1 will be checked and sorted in the order of it.
o/p will be
4 9 10
8 3 7
9 2 11
2007 Jan 11 8:38 AM
Thank you very much for this great explanation and now it's working.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |