Page 1 of 1

Question about Files matching logic

Posted: Mon Jul 11, 2011 1:27 pm
by shankarurs
Hi,
i had faced an interesting interview question in COBOL. i.e If i have two files with matching records in both files. I have to get only matching records present in both files to the new file. How can we get by using COBOL program? can anybody knows about it? please help me? thank you

Posted: Mon Jul 11, 2011 3:28 pm
by Gurugars
Hi,
i have two files with matching records in both files. I have to get only matching records present in both files to the new file
This is the one way that i know,

Code: Select all

Perform until eof-file1 or eof-file2

Start-loop:
READ file-1
READ file-2

Check-loop:
If first-file-record-key > second-file-record-key
   READ file-2
   Go to check-loop
else 
   if first-file-record-key < second-file-record-key
      READ file-1
      Go to check-loop
   else 
      WRITE to matching-record-file
            Go to start-loop
   end-if
end-if
end-perform.

Posted: Mon Jul 11, 2011 7:10 pm
by shankarurs
Thank you for your valuable reply :D

Topic deleted by Admin

Posted: Mon Feb 01, 2016 10:05 pm
by academyindia4
<< Content deleted By Admin >>