Easiest way is in SQL
Select count(*), field1, field2, field3 from myfile
group by field1, field2, field3
having count(*) > 1
This would find matches on these three fields.
Programmatically you would open a cursor and fetch the results into a datastructure of
count(*), field1, field2, field3
But if you must do it in RPG - this will do it -- kind of -- it will find records that are identical and have the same key unless there are other records that have the same key and are not identical.
create two datastructures based on the file structure.
one of them should have a prefix such as h_
open the file as keyed
1. Read each record of the file
2. dow not eof
3. if the two datastructure's are equal
-- do whatever you want with the duplicated record
4. else
datastructure_h = datastructure
5 read next record
6 enddo
Phil
Last Wiki Answer Submitted: January 16, 2009 3:13 pm by philpl1jb44,630 pts.
All Answer Wiki Contributors: philpl1jb44,630 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
Use the reade opcode.
chain keyid recordname;
if %found;
reade keyid recordname;
if not %eof;
(we have a duplicate)
endif;
endif;