2007 Jun 14 10:30 AM
Hi,
In an Internal table I want to sort one field by ascending and the very next field by descending.
for example: Internal table has fields MATNR and BUDAT.
MATNR by ascending and BUDAT by descending.
For the group of MATNR(should be in ascending order),i want to get all the BUDAT in descending order.
Can u pls help on this..
Regards,
Raja
2007 Jun 14 10:43 AM
Sorts the lines of the selection.
Syntax
... ORDER BY PRIMARY KEY |... <si> [ASCENDING|DESCENDING]...
Sorts the selection in ascending or descending order according to the primary key or the contents of the fields listed.
then
finaly sort with next field
SORT itab by second field
Girish
2007 Jun 14 10:35 AM
Hi,
You can do that as follows
SORT ITAB BY FIELD1 ASCENDING FIELD2 DESCENDING.
For your query you can use
GROUP BY MATNER
and
ORDER BY BUDAT in the select query itself.
Regards,
Sesh
2007 Jun 14 10:35 AM
Hi Raja..
If we assume the name of internal table as mat_tab then use the following code:
sort mat_tab by MATNR ascending BUDAT descending.
Rgds
Shalini
2007 Jun 14 10:35 AM
HI,
see this example
DATA:ITAB LIKE MARA OCCURS 0 WITH HEADER LINE.
SELECT * FROM MARA INTO TABLE ITAB.
LOOP AT ITAB.
WRITE:/ ITAB-MATNR,ITAB-MTART.
ENDLOOP.
SORT ITAB BY MTART ASCENDING matnr descending .
SKIP.
LOOP AT ITAB ."WHERE MTART = 'FERT'.
WRITE:/ ITAB-MATNR,ITAB-MTART.
ENDLOOP.
rgds,
bharat.
2007 Jun 14 10:35 AM
hi,
divide the fields from one internal table to 2tables with one key field then U can sort one assending and one desending...... while listing the records check the condition key fields should be satisfied.....
reward points if helpful,
Regards
Raghunath.S
2007 Jun 14 10:36 AM
Hi Bala,
Sort internal table by Budat first in descending order ,
then sort that internal table by Matnr in ascending order.
This will help U.
Regards,
Sree.
PS: reward points if Useful.
2007 Jun 14 10:43 AM
Sorts the lines of the selection.
Syntax
... ORDER BY PRIMARY KEY |... <si> [ASCENDING|DESCENDING]...
Sorts the selection in ascending or descending order according to the primary key or the contents of the fields listed.
then
finaly sort with next field
SORT itab by second field
Girish
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |