Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Deleteing the Adjacent Dupilcates

Former Member
0 Kudos

Hi Experts,

I had declared an internal table for the year.

and base don the Usre input it is fetching the all the years in to table IT_YEAR. IF the usre enters from 2007 to 2010. I am getting nearly 212 records.

when I do the delet adjacent dupilcates it is removing 200 records and it is keeping some dupilcates in the internal table.

TYPES : BEGIN OF ty_year,

BDATJ TYPE BDATJ,

END OF ty_year.

DATA : wa_year TYPE ty_year,

it_year TYPE STANDARD TABLE OF ty_year.

SELECT bdatj FROM t009b INTO TABLE it_year WHERE bdatj IN s_gjahr.

DELETE ADJACENT DUPLICATES FROM it_year comparing bdatj.

can you look into this code.

4 REPLIES 4

former_member188685
Active Contributor
0 Kudos
sort it_year by bdatj.
DELETE ADJACENT DUPLICATES FROM it_year comparing bdatj.

do you have only one field in that it_year table. anyway sort the table before using Delete adjacent duplicates.

valter_oliveira
Active Contributor
0 Kudos

Before adjacent duplicates, sort the table.

Former Member
0 Kudos

Sort the table because you are deleting the records adjacents.

david_carballido
Active Participant
0 Kudos

Hi, before you should sort the internal table

SORT it_year BY bdatj.

DELETE ADJACENT DUPLICATES FROM it_year.

Or you also can do this:

SELECT DISTINCT( bdatj ) 
  FROM t009b 
    INTO TABLE it_year 
      WHERE bdatj IN s_gjahr.

Code 1 have more performance than the code 2 if your table t009b don't have a lot of registers.

Thanks and Regards.

David Carballido