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 / vivek c

A simple way to take the matching records if there are no duplicates in both the files.

1. Merge both the files and take the duplicates in separate file using XSUM.

//S010 EXEC PGM=SORT
//SORTIN DD DSN=DSN1
// DD DSN=DSN2
//SORTOUT DD DSN=DSNOUT
//XSUM DD DSN=DSN.MATCH
//SYSIN DD *
SORT FIELDS=(1,1,CH,A)
SUM FIELDS=NONE,XSUM

The output DSN.MATCH will have the matched records.

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between a binary search and a sequential search what are the pertinent cobol?

725


How do we get current date from system with century in COBOL?

793


what is amode(24), amode(31), rmode(24) and rmode(any)?

688


What is rmode(24)

676


Why did you choose to work with ibm mainframe cobol programming?

625






How can i load all the data from a file to Table (array) in cobol.How i manage the occurs clause with out reading the file.Any options avilable ? Please can any one help me it is urgent?

2091


Write a cobol program making use of the redefine clause.

723


INREC AND OUTREC? HOW TO SPLIT 5K RECORDS TO DIFFERENT FILES IN A FILE IN COBOL? RESTART IN COBOL-DB2? ISOLATION LEVELS?

408


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

914


Which is the default, TEST BEFORE or TEST AFTER for a PERFORM statement?

810


How are the next sentence and continue different from each other?

756


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

8148


What is the difference between Structured COBOL Programming and Object Oriented COBOL programming?

670


For rewrite, why is it mandatory that file needs to be opened?

616


Define cobol?

856