09-09-2008 11:58 AM
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.
09-09-2008 12:36 PM
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.
09-09-2008 12:03 PM
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
09-09-2008 12:06 PM
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
09-09-2008 12:27 PM
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.
09-09-2008 12:36 PM
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.