09-23-2008 7:17 PM
Meaning, ascending descending will not work, lets say itab_A has the order O-H-W-G-I-A, and I want it to write it to itab_B to the correct order, G-H-O-I-A-W.
I know I can do loop at itab_A where for each one and write it, but is their a better way?
Thank-You
09-23-2008 8:07 PM
if you know the correct order play with index in the itab_A and append to itab_B
loop at itab_A index X.
blah.. blah..
endloop.
or
itab_temp [] = itab_A[].
delete itab_temp where index <> 'X'.
append itab_temp to itab_B.
refresh itab_temp[].
itab_temp [] = itab_A[].
delete itab_temp where index <> 'Y'.
append lines of itab_temp to itab_B.
refresh itab_temp[].
09-23-2008 7:37 PM
09-23-2008 7:47 PM
You could add a separate field to the internal table and fill it with the sort order according to your requirements and sort on that.
Rob
09-23-2008 8:07 PM
if you know the correct order play with index in the itab_A and append to itab_B
loop at itab_A index X.
blah.. blah..
endloop.
or
itab_temp [] = itab_A[].
delete itab_temp where index <> 'X'.
append itab_temp to itab_B.
refresh itab_temp[].
itab_temp [] = itab_A[].
delete itab_temp where index <> 'Y'.
append lines of itab_temp to itab_B.
refresh itab_temp[].
09-23-2008 8:11 PM
The SET LOCALE command can affect sort order if it's language related but I don't think that's the case here.
You could use loops and translate.
Loop at itab_A.
translate itab_A-field using 'OGHHWOGIIAAW'.
Endloop.
sort itab_A.
Loop at itab_A.
translate itab_A-field using 'GOHHOWIGAIWA'.
Endloop.
itab_b[] = itab_a[].