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
how do you reference the printer file formats from cobol programs
How many bytes S(8) comp field occupy and its maximum value?
Difference between array and sub-script ?
What is the utilization of copybook in cobol?
What is the difference between perform … with test after and perform … with test before?
Why occurs cannot be used in 01 level in COBOL?
How you can read the file from bottom?
Write a program to enter and display the names of students in a class using the occurs clause.
how do you reference the variable block file formats from cobol programs
Explain how will you differentiate between an internal and an external sort, the pros and cons, internal sort syntax etc
what is search and searchall?what is the diffrence between them?give an best example?
What is the difference between comp and comp-3?
If you are current on the owner of a set, what is the difference between obtain next and obtain first?
What is the difference between goback, stop run and exit program in cobol?
how to access the file from prodution from changeman tool and to submit a file to production