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: 

fetching duplicate record entries

Former Member
0 Kudos

Hi all,

I am having some data in a DB table, and i am trying to upload some records into the DB table using an excel sheet. I must find the duplicate records if any from the excel sheet ,ased on the primary key alone,and send those records as a mail to the user.

Please,if ny of you people could provide me with a logic to go ahead.

Thanks in advance,

Winnie.

1 ACCEPTED SOLUTION

vinod_vemuru2
Active Contributor
0 Kudos

Hi,

Check this logic.

Upload data to itab1.

SORT: itab1 BY primary key.

itab2[] = itab1[].

DELETE ADJACENT DUPLICATES FROm itab2 COMPARING primary key.

LOOP AT itab1 INTO wa.

READ TABLE itab2 WITH KEY primary keys BINARY SEARCH TRANSPORTING NO FIELDS .

If sy-subrc IS INITIAL.

update data base table.

ELSE.

APPEND that record to internal table. After end loop send this internal table as mail.

ENDIF.

ENDLOOP.

Thanks,

Vinod.

4 REPLIES 4

Former Member
0 Kudos

Hi,

Use GUI_UPLOAD function module to upload the records from presentation server to Internal table.

Now delete the duplicate records from internal table using delete adjacent duplicate statement.

then insert the records from internal table to DB table.

regards,

Sujit

0 Kudos

sujit,

I hav done all what you hav said, but i require those duplicate entry records, cant just delete them. i need to identify them, and move them to another int. table. My problem is how to identify them.

thanks

0 Kudos

Hi,

Suppose the table sflight.

try this way-

Loop at itab1 into wa1.
  Loop at itab1 into wa2 where carrid = wa1-carrid
                                             connid = wa1-connid.
   Append wa2 to tab2.
 endloop.
Endloop.

Now internal table itab2 has the duplicate records if there are any.

vinod_vemuru2
Active Contributor
0 Kudos

Hi,

Check this logic.

Upload data to itab1.

SORT: itab1 BY primary key.

itab2[] = itab1[].

DELETE ADJACENT DUPLICATES FROm itab2 COMPARING primary key.

LOOP AT itab1 INTO wa.

READ TABLE itab2 WITH KEY primary keys BINARY SEARCH TRANSPORTING NO FIELDS .

If sy-subrc IS INITIAL.

update data base table.

ELSE.

APPEND that record to internal table. After end loop send this internal table as mail.

ENDIF.

ENDLOOP.

Thanks,

Vinod.