I have dataset DS1 which has records say
1
2
3
4
5
...
...
etc
And also I have second dataset DS2 whcih has records
1
3
4
5
6
8
..
...
Both the files are sorted and now I want to compare these files and write it into the third files if the records are matching.
Answer Posted / leo
Using matching logic:
perform following code until either of EOF is found.
EVALUATE TRUE
WHEN KEY1> KEY2
READ FILE2
WHEN KEY2> KEY1
READ FILE1
WHEN KEY1=KEY2
WRITE FILE3 (WHATEVER FORMAT YOU WANT)
READ FILE1
READ FILE 2
END-EVALUATE
You can perform above code until both EOF found, incase you
need to create another file for non matching records. for
matching records only performing until either of EOF will
work.
~LEO
Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
what is the use of outrecord?
What is Pic 9v99 Indicates in COBOL?
How do you reference the following file formats from cobol programs?
What is the utilization of copybook in cobol? Could we utilize a similar copybook?
Which division and paragraphs are mandatory for a COBOL program?
what happens if parmparameter passes zero bytes to the program
how to access the file from prodution from changeman tool and to submit a file to production
What is the difference between comp and comp-3?
what is difference bt COND, REGION & TIME parameters at JOB & EXEC. give an exp.
There are 5 fields and 1000 records in a file. Unload it into an array. Write the syntax for declaration and how will you unload it.
Difference between array and sub-script ?
State the various causes of s0c1, s0c5 and s0c7.
What is amode(31)
What are the different rules of SORT operation?
Discuss about changing dataset name in proc.