DELETE ADJACENT DUPLICATES FROM INTERNAL TABLE

Syntax of delete adjacent duplicates: -

      Delete adjacent duplicates  <it> from comparing <field1> <field2> .....


Note: - Before using the delete adjacent duplicates, to delete duplicates we must sort the table based               on comparing fields.
Ex: - Delete adjacent duplicates from IT comparing BUKRS. 





PROGRAM:

*&---------------------------------------------------------------------*
*& Report  ZR_DELETE_ADJACENT_DUPLICATES
*&
*&---------------------------------------------------------------------*
REPORT ZR_DELETE_ADJACENT_DUPLICATES.

data:begin of itab occurs 0,
     f1 
type i,
     f2 
type i,
     
end of itab.
data:c1 type i,
     c2 
type i.

itab
-f1 1.itab-f2 2.append itab.
itab-f1 
1.itab-f2 1.append itab.
itab-f1 
2.itab-f2 3.append itab.


loop at itab.
c1 
c1 + 1.
endloop.

sort itab.

delete adjacent duplicates from itab comparing f1.


loop at itab.
c2 
c2 + 1.
endloop.

write/ c1,c2.