on 05-10-2006 5:16 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First of all, sort the internal table, and after use the sentence:
DELETE ADJACENT DUPLICATES FROM itab BY COMPARING ALL FIELDS.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
may be there a duplicate key record.
Regards
vijay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.