2006 Nov 23 10:20 AM
HI,
i have one query for the cdpos table of abap.
What i am looking is i want the latest CHANENR of the cdpos for that
objectid and tabname and fname in my internal table.
what i thought of doing was to sort my internal table with objectid changnr tabname fname in descending order
and than use delete adjacent duplicates command
BUt that is not sorting based on all field , its sorting on changnr only
please let me know what can i do
2006 Nov 23 10:24 AM
hi,
instead of using delete adjacent duplicates..read the first line since you are sorting descendig by using read from itam index 1.u will get the value
2006 Nov 23 10:24 AM
try this..
sort itab by changnr descending.
delete adjacent duplicates from itab.
2006 Nov 23 10:35 AM
I think better sort it on objectid tabname fname changenr descending.
Regards
Anurag
2006 Nov 23 10:38 AM
no, that is not what i am looking at,
I am saying say i have internal table cdpos
OBJECTCLAS OBJECTID CHANGENR TABNAME FNAME
RECN_RECN |0100TEST1 0000384409| VICN01 |RECNEND
RECN_RECN 0100TEST1 0000383462 VICN01 RECNLIFNR
RECN_RECN 0100TEST1 0000360190 VICN01 RECNEND
RECN_RECN 0100TEST1 0000340630 VICN01 RECNEND
this is my debug output after sorting on objectid changenr tabname fname in descending
i wanted line 2nd to be at last so when i use delete adjacent command i can get 2 line item i.e 1st and 2nd line ...
2006 Nov 23 10:48 AM
HI ANURAG,
THANKS ITS WORKING
I HAVE ONE QUERY ON SORT COMMAND
IS IT THAT SORT HAPPENS ONLY ON KEY FIELD. THE WAY U DEFINE WHILE
DECLARING THE INTERNAL TABLE
2006 Nov 23 10:51 AM
The entries in the internal table are sorted in ascending order using the key from the table definition (DATA, TYPES).
2006 Nov 23 11:58 AM
It is nice to understand the soln works..if so please assign points to all helpful answers.
As for your query, if you just use SORT it would do it on the key fields but it is possible to define your sort using nonkey fields even.
Regards
Anurag