08-03-2009 6:29 AM
Dear All ...
i want to sort by table with some field. which some of the field in assending n some in desending.
example: this my table itab .
1.1.09 a H
1.1.09 c H
1.1.09 c S
1.1.09 a S
after sort become
1.1.09 a S
1.1.09 a H
1.1.09 c S
1.1.09 c H
from above sample ....... 1st n 2nd value is sort in assending , but 3th sort in desending ....
any idea ?
08-03-2009 6:38 AM
HI,
You can use following code
Sort table itab <first field> <second field> <third field> descending
Hope it helps
08-03-2009 6:33 AM
HI.
Give three field while doing stor your internal tanle.I hope so u didnt added your 3rd field .
Eg:
SORT <itab> BY <f1> <f2> <f3>.
Regards,
jay
08-03-2009 6:34 AM
Hi,
My humble feeling is that its not possible in single sort statement.
Regards,
Ravi shankar
08-03-2009 6:37 AM
Hi,
Just sort the itab as given below, you will get the desired output.
sort itab by field4 descending.
sort itab by field1 field2 field3 ascending.
Regards,
Vik
08-03-2009 6:38 AM
HI,
You can use following code
Sort table itab <first field> <second field> <third field> descending
Hope it helps
08-03-2009 6:45 AM
Hi,
Try this,
DATA: BEGIN OF itab OCCURS 0,
f1(15) TYPE c,
f2(15) TYPE c,
f3(15) TYPE c,
END OF itab.
itab-f1 = 1.
itab-f2 = 'a'.
itab-f3 = 'H'.
APPEND itab.
itab-f1 = 1.
itab-f2 = 'c'.
itab-f3 = 'H'.
APPEND itab.
itab-f1 = 1.
itab-f2 = 'c'.
itab-f3 = 'S'.
APPEND itab.
itab-f1 = 1.
itab-f2 = 'a'.
itab-f3 = 'S'.
APPEND itab.
SORT itab by f1 f2 f3 DESCENDING.
LOOP AT itab.
WRITE:/ itab-f1, itab-f2, itab-f3.
ENDLOOP.
08-03-2009 6:46 AM
ya .... but how i going to make the 3th value in descending ? once i sort the 1st n 2nd, 3rd will change the sequence also ..
08-03-2009 7:01 AM
Hi,
This can be done in a single sort statement as below
sort itab descending by f1 f2 f3 ascending f4.
Regards,
Vik
Edited by: vikred on Aug 3, 2009 11:36 AM
08-03-2009 6:52 AM
HI
use the following code
SORT ITAB BY FIELD ASCENDING.
SORT ITAB BY FIELD1 FIELD2 FIELD3 DESCENDING.
~linganna