2008 Nov 14 2:07 PM
Hi,
I have an internal table
itab
a b
40 44
40 55
I want to delete the duplicates of column A
I need row 2 because it is having hghest value in column B
Hi,
I have an internal table
itab
a b
40 44
40 55
I want to delete the duplicates of column A
I need row 2 because it is having hghest value in column B
2008 Nov 14 2:09 PM
F1 is a good tool to start with.
Plus You already have the keywords with you.
pk
2008 Nov 14 2:11 PM
2008 Nov 14 2:12 PM
Hi
SORT ITAB BY A ASCENDING B DESCENDING.
In this way the firt row as soon as the value of A is changed is the row you need:
LOOP AT ITAB.
IF ITAB-A = OLD_A.
DELETE ITAB.
ENDIF.
OLD_A = ITAB-A.
ENDLOOP.Max
2008 Nov 14 2:27 PM
Alternatively you can also
Use
SORT itab by A ascending B descending
DELETE adjacent duplicates comparing A.
This will help.
Regards,
Prashant
2008 Nov 14 2:33 PM
>
> Hi,
>
>
> I have an internal table
>
> itab
>
> a b
> 40 44
> 40 55
>
> I want to delete the duplicates of column A
> I need row 2 because it is having hghest value in column B
Hi Shilpa,
Lets analyse the problem first. You need to delete the duplicate entries from an internal table provided that the entry which remains, is the entry with highest value for field B.
Thus we can use the ABAP keyword SORT. You can sort the table in descending order and the use the ABAP ststement DELETE DUPLICATE. Here is the code:-
* The below code sorts the table in such a way that the table looks like follows:-
* A B
*40 55
*40 44
SORT itab by a b descending.
*Next delete duplicates
DELETE ADJACENT DUPLICATES FROM itab COMPARING A .Regards,
Ravi.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |