cancel
Showing results for 
Search instead for 
Did you mean: 

Hi everyone

Former Member
0 Kudos

can any body tell me how to remove identical records from an internal table.

I have 12450 records in an internal table which are read from excel sheet and when i tried to move them into a db table i get only 12449.

please let me know if you guys have an idea.

suchitra

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

first sort that internal table.then use this command

DELETE ADJACENT DUPLICATES from itab BY COMPARING 'field1' or

DELETE ADJACENT DUPLICATES FROM itab BY COMPARING ALL FIELDS.

Cheers,

Bujji

Answers (8)

Answers (8)

Former Member
0 Kudos

First of all, sort the internal table, and after use the sentence:

DELETE ADJACENT DUPLICATES FROM itab BY COMPARING ALL FIELDS.

Former Member
0 Kudos

Hi suchitra,

You have 12450 records in an internal table and in DB only 12449 get copied.

U might be using Insert statement to insert the record.

1 record might be a duplicate record ie 2 records have similar key fields.

U need to remove the duplicate record..

U can use

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING <key fields>.

That would ensure 12449 records are there in ur internal table and are copied to DB..

Caution: However, ur 2nd duplicate record having different data for non key fields would be lost!

Regards,

Tanveer.

<b>Please mark helpful answers</b>

former_member188685
Active Contributor
0 Kudos

may be there a duplicate key record.

Regards

vijay

Former Member
0 Kudos

Hi suchitra,

i think of the 12450 records, two records may be identical.so,try using delete adjacent duplicates before inserting them into the db table .

Award some points if helpful.

regards,

keerthi.

Former Member
0 Kudos

Hello Suchitra,

Sort the internal table by key field and use delete adjacentdupliacte from internal table as follows :

Sorty it1 by k1 k2....

Delete adjacent duplicate from it1 comparing k1.

Cheers,

Nilesh

Message was edited by: Nilesh Kshirsagar

Former Member
0 Kudos

hii

use delete adjacent entries

If you want to delete duplicate rows based on duplicate values in only certain fields, then sort itab by those fields and then use COMPARING field1 field2 etc.

SORT itab BY field1 fiel2.

DELETE ADJACENT DUPLICATES FROM itab COMPARING field1 field2.

hope this helps

Thanks & regards

Naresh

rahulkavuri
Active Contributor
0 Kudos

<b>U can use the following but take care that u sort before doing that</b>

delete adjacent duplicates COMPARING field1 field2

also refer to this pgm

Former Member
0 Kudos

Hi,

INSERT DB-TABLE from ITAB.

IF sy-subrc = 0.

Commit work.

ELSE.

Rollback work.

Endif.

Here if record already exists with key field in DB-TABLE then your sy-subrc will be 4.

If not it will be inserted and sy-subrc will be 0.

Check if the record already there in DB-table.

You can remove identical records from internal table ....

Delete adjacent duplicates from ITAB comparing f1 f2 f3.

Thanks.

If this helps you reward with points.

Message was edited by: KDeepak

Former Member
0 Kudos

Hi,

If you want to remove identical records from the internal table then you need to first sort your internal table with the key/ basis on which you claim they are identical, then you can use delete adjacent entries.If you do not want duplicate entries in the database table then I think you can use Deepaks procedure.

regards

Vick