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.
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / harsha
Use following JCL
//STEP010 EXEC PGM=ICETOOL
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//FILEIN DD DSN=XXXXXXXXXXXXXX,DISP=SHR
//TOOLIN DD *
SELECT FROM(FILEIN) TO(UNIQFL) -
ON(1,73,CH) NODUPS
SELECT FROM(FILEIN) TO(DUPFL) -
ON(1,73,CH) ALLDUPS
/*
//*
//DUPFL DD SYSOUT=*
//UNIQFL DD SYSOUT=*
//*
Label DUPFL will show all duplicate records
Label UNIQFL will show all unique records
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / 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 |
Answer / ganesh
Okay Agree with above solution. Now tell me how to do using COBOL Read statement logic.
| Is This Answer Correct ? | 0 Yes | 0 No |
what is redefines? where it can be effectively use for the purpose of memory utilization? give an example?
file status 00 is checked after opening the file or reading the file
can we use full outer join with cursors declared in cobol program?
Syntax for JCLLIB & JOBLIB???
Give some advantages of REDEFINES clause?
how to transfer the file from pc to mainframe??
write a cobol logic. i have file that has 10 records .1 record go to first output file and second record goes to 2 output and etc
how to change picture class of copy book variable inside program?
What is the difference beetween Arrays and Tables in Cobol? please dont give the answer that arrays in cobol terminology is called tables......
maximum of how many screens we can open in emulator
What is R-mode and A-mode?
what happens when a copybook variables are declared using include statement ?