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 |
Wat is the difference between NEXT and CONTINUE statement in cobol,can any one explain with example.
is it possible to declare index in cobol program? if it is not why its tell me pls
01 a pic s9(5) value '-12345' how it will be stored
What is the significance of the PROGRAM-ID paragraph? If this name doesnt match with the name of the COBOL program, does it make a difference? Is the name specified in the PROGRAM-ID paragraph used as a name for the load module or any such thing?
Why we need to use redefine clause when we can define the variable seperately... what is actual need....
What is difference between static and dynamic call in cobol?
What is 77 level used for ?
Is this allowed? 01 WS-TABLE. 03 FILLER-X PIC X(5) VALUE 'AAAAA'. 03 WS-EX REDEFINES FILLER-X OCCURS 5 TIMES PIC X(1). can redefines clause be used with occurs clause?
what are difference organizations in cobol and access mode in cobol? can you expalin what organization means while declaring for ksds,esds,rrds?
Difference between cobol and cobol-ii?
What do you do to resolve SOC-7 error?
How to get the last record in vsam file in cluster? And how can you get the kids file records into your cobol program?