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


Please Help Members By Posting Answers For Below Questions

How many bytes S(8) comp field occupy and its maximum value?

1634


How do u write test cases?

1638


Which mode is used to operate the sequential file?

669


Explain the configuration section of a cobol program with examples of syntax.

660


What is the difference between goback, stop run and exit program in cobol?

932






What is the difference between PIC 9.99 and PIC9v99?

782


What rules are followed by the search verb.

638


What is the default value(s) for an initialize? What keyword will allow for an override of the default?

661


Name the divisions, which are available in a cobol program?

685


What are the different rules to perform a Search?

619


Which division and paragraphs are mandatory for a COBOL program?

709


What is perform what is varying?

711


What is a report item?

741


How do define dynamic array in cobol.

672


What are various search techniques in cobol? Explain.

650