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 |
how to access vsam files in cobol and how to differentiate that this is ESDS file
How do you differentiate between cobol and cobol-ii?
in a indexed file what is procedure for read the records from 12 to 18. please give the code example
What do you feel makes a good program?
What are the different types of condition in cobol and write their forms.
How to covert given string into ASCII value in COBOL/MF COBOL
input:- A 10 20 30 40 B 5 7 10 14 C 8 12 14 16.... output:- A = 100,B=36,C=50. Here spaces are considered between numbers. When we give input as above, the numbers should be added n displayed.So please help me out.
what is the default print format? in cobol
01 a pic x(4) value 'abcd' 01 b pic 9(3) can we move from a to b.if possible what would be stored in b.
What are the various section in data division and briefly explain them.
what are decleratives in cobol?
what happens if parmparameter passes zero bytes to the program