Req:compare 2 files and write it to match and nomatch
Moderators: Frank Yaeger, Moderator Group
Req:compare 2 files and write it to match and nomatch
Hi,
Here is my requirement....
I have 2 input files of 5200 length. A 7 byte key is used to compare both the files, if there is a match than it needs to be written to match file but while writing to match file i need few fields from infile1 and all other fields from infile2.
If there is no match than write to no match output file.
Is it possible to do it in sort...i know it can be easily done using COBOL pgm but just want to know in sort/icetool/iceman/EZTRIEVE....
Can someone help me....
Thanks in advance,
Deepu
Here is my requirement....
I have 2 input files of 5200 length. A 7 byte key is used to compare both the files, if there is a match than it needs to be written to match file but while writing to match file i need few fields from infile1 and all other fields from infile2.
If there is no match than write to no match output file.
Is it possible to do it in sort...i know it can be easily done using COBOL pgm but just want to know in sort/icetool/iceman/EZTRIEVE....
Can someone help me....
Thanks in advance,
Deepu
matching file using SORT
Option 1) Use syncsort as shown below.
Using REFORMAT , you can define your output layout.
Option 2) Use DFSORT - SPLICE
Option 3) Use easytrieve IF MATCHED condition.
It is easy compare than COBOL program.
Code: Select all
//STEP001 EXEC PGM=SORT
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SORTJNF1 DD *
1234567sdfsadfasdf
1244567 adsfsafasd
1254567asfdsadad
//SORTJNF2 DD *
1234567wewreeter
1254576werwerewr
1265567werwrewrwerw
//SORTOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(1,7,A)
JOINKEYS FILES=F2,FIELDS=(1,7,A)
REFORMAT FIELDS=(F1:1,5200,F2:10,3)
SORT FIELDS=COPY
Option 2) Use DFSORT - SPLICE
Option 3) Use easytrieve IF MATCHED condition.
It is easy compare than COBOL program.
Natarajan
Chennai
Chennai
Thank you very much for the quck reply Natarajan...
Is it possible for you to elaborate your concept a bit...can you plz explain..
//SORTJNF1 DD *
1234567sdfsadfasdf
1244567 adsfsafasd
1254567asfdsadad
//SORTJNF2 DD *
1234567wewreeter
1254576werwerewr
1265567werwrewrwerw
what the above statements will do....and i believe here i should specify my input files..
correct me if i am wrong...
Thank you..
Is it possible for you to elaborate your concept a bit...can you plz explain..
//SORTJNF1 DD *
1234567sdfsadfasdf
1244567 adsfsafasd
1254567asfdsadad
//SORTJNF2 DD *
1234567wewreeter
1254576werwerewr
1265567werwrewrwerw
what the above statements will do....and i believe here i should specify my input files..
correct me if i am wrong...
Thank you..
SORTJNF1 is the input file 1
SORTJNF2 is input file2
JOINKEYS FILES=F1,FIELDS=(1,7,A) <-- specify key of file 1
JOINKEYS FILES=F2,FIELDS=(1,7,A) <-- specify key of file 2
REFORMAT FIELDS=(F1:1,5200,F2:10,3) <-- specify what fields needs to be move
moved to output file from each file..
SORTJNF2 is input file2
JOINKEYS FILES=F1,FIELDS=(1,7,A) <-- specify key of file 1
JOINKEYS FILES=F2,FIELDS=(1,7,A) <-- specify key of file 2
REFORMAT FIELDS=(F1:1,5200,F2:10,3) <-- specify what fields needs to be move
moved to output file from each file..
Natarajan
Chennai
Chennai
SUM FIELDS = NONE is not working to remove dups...my SYSIN is...
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(43,7,A)
JOINKEYS FILES=F2,FIELDS=(43,7,A)
REFORMAT FIELDS=(F1:1,5,43,7,F2:58,4)
SORT FIELDS=COPY
SUM FIELDS=NONE
/*
it's not eliminating the DUPS.....and one more is to write the un matched records to an unmatch file which was not mentioned previously...
Thanks in Advance,
deepu.
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(43,7,A)
JOINKEYS FILES=F2,FIELDS=(43,7,A)
REFORMAT FIELDS=(F1:1,5,43,7,F2:58,4)
SORT FIELDS=COPY
SUM FIELDS=NONE
/*
it's not eliminating the DUPS.....and one more is to write the un matched records to an unmatch file which was not mentioned previously...
Thanks in Advance,
deepu.
Below code write the matched records to one file & records only on FILE 1 on to another file.
Regarding duplicates, have another step before the main step and remove the duplicates on input files.
Code: Select all
//SORT1 EXEC PGM=SORT
//SORTOF01 DD DSN=xxxx.xxx.OUT <-- give required space, dcb parameters
//SORTOF02 DD DSN=yyyy.yyy.out, <-- give required space, dcb parameters
//SORTJNF1 DD DSN=DEV.FILE1,DISP=SHR
//SORTJNF2 DD DSN=DEV.FILE1,DISP=SHR
//SYSOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(1,7,A)
JOINKEYS FILES=F2,FIELDS=(1,7,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,5200,F2:1,5200),FILL=X'FF'
OUTFIL FILES=01,INCLUDE=(5201,1,BI,EQ,X'FF'),
OUTREC=(1,5200)
OUTFIL FILES=02,INCLUDE=(5201,1,BI,NE,X'FF')
SORT FIELDS=COPY
Regarding duplicates, have another step before the main step and remove the duplicates on input files.
Natarajan
Chennai
Chennai
-
- Active Member
- Posts: 52
- Joined: Wed Mar 25, 2009 11:56 pm
- Location: Banglore
Try to use below code for eleminating duplicates.
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(43,7,A)
JOINKEYS FILES=F2,FIELDS=(43,7,A)
REFORMAT FIELDS=(F1:1,5,43,7,F2:58,4)
SORT FIELDS=(43,7,ch,a)
SUM FIELDS=NONE
/*
I assumed key is starting from 43 to (43+7).
When you are using SOrt fields =copy, it wont consider key, it will copy everything.
For eliminating duplicates, we need more information like record length of file & some sample data.
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(43,7,A)
JOINKEYS FILES=F2,FIELDS=(43,7,A)
REFORMAT FIELDS=(F1:1,5,43,7,F2:58,4)
SORT FIELDS=(43,7,ch,a)
SUM FIELDS=NONE
/*
I assumed key is starting from 43 to (43+7).
When you are using SOrt fields =copy, it wont consider key, it will copy everything.
For eliminating duplicates, we need more information like record length of file & some sample data.
Thanks
MaheshVamsi
MaheshVamsi
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page