Joined: 14 Oct 2005 Posts: 1188 Location: Bangalore,India
You can use following logic.
PERFORM UNTIL END-OF-FILEA OR END-OF-FILEB
IF KEY OF FILEA= KEY OF FILEB
Populate RECORDC with RECORDA
IF KEY of FILEA < KEY of FILEB
Sorry i am replying bit and i dont know if your purpose is been solved or not but below is the solution. As you have posted the question in Cobol Forum i am giving you logic for Cobol Program.
You have file 1, file 2 as Input file and resultant file is 3.
File 1 contains 1,2,4,6,8 and
File 2 contains 1,6,3,2,7.
Assuming both the files are sorted (if you want to compare on key then sort both the files on that particular Key).
You read both the files first (Reading first record) then
You can use EVALUATE. So it would be like
WHEN Record-1 (Key-1) = Record-2 (Key-2)
Move Record-1 to Record-3 (this is output file record)
Write record into output fille.
WHEN Record-1 (Key-1) > Record-2 (Key-2)
WHEN Record-1 (Key-1) < Record-2 (Key-2)
Here the resultant file will only have matching records from both the files but primary requirement is both the files should be pre-sorted(if required they should be sorted on particular KEY).