tags:

views:

676

answers:

1

How to compare two files in Cobol, both files having duplicate records. can any1 give pseudo code. The code has to work in duplicate record condition

+2  A: 

I'm not sure exactly what you're after (e.g. what you are hoping to report out of the comparison) but one idea might be to proceed as follows:

  • Create two new (temporary) files with the data from your targets plus a sequential row number; key the new files off the row number
  • Step through the two files by row number, gleaning what data you data you need.
  • If record_1 is "less" than record_2 by the old key, advance file_1
  • If it is greater, advance file_2
  • If they are equal, advance both

On EOF on one file you'll need to check for trailing unique records in the remaining file which may or may not be at EOF.

MarkusQ
I implemented that with DCL :-)
Luc M