2008 Aug 26 10:48 PM
Hello,
I have a senario like this. I have internal table with 3 fields and my internal table is papulated like
A B C
123 X1 01/02/2007
123 X3 02/01/2007
126 X1 02/01/2007
123 X1 04/02/2007
123 X1 06/02/2007
123 X3 06/01/2007
126 X1 08/01/2007
Now I wanted have a output like
A B C
123 X1 06/02/2007
123 X3 06/01/2007
126 X1 08/01/2007
Any body tell me how can I achive this output.
Thanks & Regards
Venkat
Hello,
I have a senario like this. I have internal table with 3 fields and my internal table is papulated like
A B C
123 X1 01/02/2007
123 X3 02/01/2007
126 X1 02/01/2007
123 X1 04/02/2007
123 X1 06/02/2007
123 X3 06/01/2007
126 X1 08/01/2007
Now I wanted have a output like
A B C
123 X1 06/02/2007
123 X3 06/01/2007
126 X1 08/01/2007
Any body tell me how can I achive this output.
Thanks & Regards
Venkat
2008 Aug 26 10:53 PM
SORT itab BY A B ascending C descending.
DELETE ADJACENT DUPLICATES FROM itab COMPARING A B.
2008 Aug 27 2:56 AM
Hello
SORT TABLE BY A B Ascending and C Descending.
delete adjacent duplicates from TABLE COmapring A B C.
Praveen
2008 Aug 27 3:22 AM
2008 Aug 27 3:51 AM
Hello Venkat,
The method provided by Alvaro and Praveen is not bad. But the main question is: what TYPE is your field C? When it is a date type, the recommended sort and delete works. But when C is a character field, it doesn't work. Let's say you have a table record looking like 126 X1 09/01/2006, the you will get an output
A B C
123 X1 06/02/2007
123 X3 06/01/2007
126 X1 09/01/2006And I guess that's not what you want!?
When your C field is not of TYPE D, you have to convert it first and then the recommended statements work.
Cheers,
Heinz
2008 Aug 27 3:56 AM
it seemed that you want the latest data.
in this case, sort data and compare date.
do like this.
data: wa_itab like line of itab,
l_check.
sort itab by a b c.
loop at itab,
at new c.
l_check = 'X'.
endat.
if l_check = 'X'.
move-corresponding itab to wa_itab.
clear: l_check.
endif.
if itab-c LE wa_itab-c.
delete itab.
endif.
endloop.
I hope this would help you
2008 Aug 27 3:58 AM
Hi Venkat,
SORT t_itab BY A B ascending.
DELETE ADJACENT DUPLICATES FROM t_itab COMPARING A B.
DELETE ADJACENT DUPLICATES delete the duplicate adjacent records by comparing the values of A and B with the previous record.
Regards,
Chandra Sekhar
2008 Aug 27 4:00 AM
Hi Venkat,
Use the below code to fulfill your requirement
.
SORT it_fina BY A B ascending C descending.
delete adjacent duplicate comparing A.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |