how will you write a logic for this in cobol?
I have 3 files . 2 files have millions of records.These 2 files have one ( empnumber) common record field. i want to put those records in 3rd file , such that which records having same number in key field (empnumber)in these two files ?
How will you write a logic for this in cobol?
One way is:
Read file1 until EOF1 or EOF2
Read File2 Until EOF2 or File1-Key >File2-key
If File1-key = File2-key
Write .....
End-If
End-Read
End-Read.
But READ stmt dont have UNTIL.
So it is to be done thru PERFORM stmt.
Can u write a full logic in cobol?
/* This question was asked by savvy */
Re: how will you write a logic for this in cobol?
1.First, convert both the files into Indexed Sequential with Empno as key.
2. Now ;
Perform Write-File-para thru Write-File-para-Exit until EOF = 'y'.
....
Write-File-para.
Move Rec-1-Emp-no to Rec-2-Emp-no.
Read File-2 key is Rec-2-Emp-no
invalid key go to Write-File-para-Exit.
Move spaces to Rec-3 <* Initialize record
String Rec-1 Rec-2 into Rec-3 delimited by size.
Write-file-para-exit.
Read File-1 next at end move 'Y' to EOF.