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

what is the use of outrecord?

1759


What is Pic 9v99 Indicates in COBOL?

707


How do you reference the following file formats from cobol programs?

684


What is the utilization of copybook in cobol? Could we utilize a similar copybook?

700


Which division and paragraphs are mandatory for a COBOL program?

699






what happens if parmparameter passes zero bytes to the program

1648


how to access the file from prodution from changeman tool and to submit a file to production

6656


What is the difference between comp and comp-3?

686


what is difference bt COND, REGION & TIME parameters at JOB & EXEC. give an exp.

8117


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.

915


Difference between array and sub-script ?

1147


State the various causes of s0c1, s0c5 and s0c7.

652


What is amode(31)

710


What are the different rules of SORT operation?

686


Discuss about changing dataset name in proc.

751