View previous topic :: View next topic
|
Author |
Message |
loga_nathan_m
New User
Joined: 07 Jun 2007 Posts: 40 Location: India
|
|
|
|
Hi all,
I need to compare two files and write the unmatching records and new records into a new output file.
Example:
File1 contains 100 Records
File2 contains 110 records out of which 99 exactly matches with File1, so now i need rest 11 records to be written to a new file.
Note: File1 and File2 are of same format.
The comparison should be done based on the whole record, we don't have any key fields in the files.
I came to know this can be done by ICETOOL, i have not worked on it so could anyone kindly give the solution with brief example.
If the same can be achieved by anyother utility also its fine.
Thanks,
M.Loganathan |
|
Back to top |
|
|
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
Loganathan,
We can do that using a match Eztrieve also(EZTPA00 utility). |
|
Back to top |
|
|
loga_nathan_m
New User
Joined: 07 Jun 2007 Posts: 40 Location: India
|
|
|
|
Hi Anand,
I have not used EZTPA00 utility also.
But do send me the sample i'll try it out.
Thanks,
M.Loganathan |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Just you can do using a simple program. |
|
Back to top |
|
|
loga_nathan_m
New User
Joined: 07 Jun 2007 Posts: 40 Location: India
|
|
|
|
hi,
we have lot of utilites. using them is much easier then creating a progam.
so wish to learn those utilites.
Thanks,
M.Loganathan |
|
Back to top |
|
|
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
//XXXXXXXX JOB (X,XXX),'EZT',CLASS=0,MSGCLASS=X
//EZTCOM EXEC PGM=EZTPA00
//STEPLIB DD DSN=SYSTEMS.LINKLIB,DISP=SHR
// DD DSN=DB2D.SDSNLOAD,DISP=SHR
//EZTVFM DD SPACE=(CYL,(20,20)),UNIT=SYSDA,DCB=BUFNO=40
//SYSPRINT DD SYSOUT=*
//SYSPUNCH DD DUMMY
//SYSUDUMP DD SYSOUT=Y
//SYSOUT DD SYSOUT=*
//FILEA DD DISP=SHR,DSN=File1(I/P1)
//FILEB DD DISP=SHR,DSN=File2(I/P2)
//FILEC DD DSN=File3(MISMATCH)
//FILED DD DSN=File4(MISMATCH FROM I/P1)
//FILEE DD DSN=File5(MISMATCH FROM I/P2)
//SYSIN DD *
*
FILE FILEA
A-REC 1 80 A
A-KEY 1 80 A
*
FILE FILEB
B-REC 1 80 A
B-KEY 1 80 A
*
FILE FILEC
C-REC 1 80 A
*
FILE FILED
D-REC 1 80 A
*
FILE FILEE
E-REC 1 80 A
*
JOB INPUT ( FILEA KEY(A-KEY) +
FILEB KEY(B-KEY) ) FINISH EXIT-PARA
*
IF MATCHED
C-REC = A-REC
PUT FILEC
ELSE
IF FILEA
D-REC = A-REC
PUT FILED
ELSE
IF FILEB
E-REC = B-REC
PUT FILEE
END-IF
END-IF
END-IF
*
EXIT-PARA. PROC.
DISPLAY 'SUCCESSFUL RUN '
END-PROC.
/* |
|
Back to top |
|
|
loga_nathan_m
New User
Joined: 07 Jun 2007 Posts: 40 Location: India
|
|
|
|
hi,
Please find below the input and output.
File1:
aaaaaaaaaa
bbbbbbbbbb
cccccccccc
dddddddddd
eeeeeeeeee
File2:
aaaaxxxxxx
bbbbxxxbbb
cccccxcccc
gggggggggg
dddddddddd
eeeeeeeeee
ffffffffff
File3: Empty
File4:
aaaaaaaaaa
bbbbbbbbbb
cccccccccc
dddddddddd
eeeeeeeeee
File5:
aaaaxxxxxx
bbbbxxxbbb
cccccxcccc
gggggggggg
dddddddddd
eeeeeeeeee
ffffffffff
It is not matching the requirements. Could u kindly send me some reference document so that i can understand how the IF condition is working.
I have not changed you code added the files.
Thanks,
M.Loganathan |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
M.Loganathan,
I know about utilities. I myself used in our shop EZT, DFSORT and COBOL for comparison purposes. For his requirment COBOL is enough as number of records are less. |
|
Back to top |
|
|
loga_nathan_m
New User
Joined: 07 Jun 2007 Posts: 40 Location: India
|
|
|
|
hi,
Actual file contains millions of records.
Just for understanding i gave that example. |
|
Back to top |
|
|
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
Loganathan,
Have you sorted the two files before this step. if you sort and match definitely you will get the result you want. |
|
Back to top |
|
|
loga_nathan_m
New User
Joined: 07 Jun 2007 Posts: 40 Location: India
|
|
|
|
Hi Anand,
Still the same output i get |
|
Back to top |
|
|
murugan_mf
Active User
Joined: 31 Jan 2008 Posts: 148 Location: Chennai, India
|
|
|
|
Loganathan,
Try this, i have sorted the file before comparing.
Code: |
//STEP010 EXEC PGM=EZTPA00
//FILEA DD DSN = ID.XXX.FILE1,DISP=SHR
//FILEB DD DSN = ID.XXX.FILE2,DISP=SHR
//FILEO DD DSN = ID.XXX.FILEOUT,DISP=(NEW,CATLG,DELETE),
SPACE=(CYL,(1,1),RLSE),
DCB=(RECFM=FB,LRECL=09,BLKSIZE=0)
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
* INPUT FILE
FILE FILEA
A-RECORD 1 9 A
A-FIELD1 1 3 A
A-FIELD2 5 1 A
A-FIELD3 7 3 A
FILE FILEB
B-RECORD 1 9 A
B-FIELD1 1 3 A
B-FIELD2 5 1 A
B-FIELD3 7 3 A
* OUTPUT FILE
FILE FILEO
WS-OUT-RECORD 1 9 A
SORT FILEA TO FILEA USING (A-FIELD1 A-FIELD2 A-FIELD3)
SORT FILEB TO FILEB USING (B-FIELD1 B-FIELD2 B-FIELD3)
JOB INPUT (FILEA KEY (A-FIELD1, +
A-FIELD2, +
A-FIELD3) +
FILEB KEY (B-FIELD1, +
B-FIELD2, +
B-FIELD3)) +
NAME TWO-FILE-MATCH
IF NOT MATCHED FILEA FILEB
WS-OUT-RECORD = B-RECORD
PUT FILEO
END-IF
GO TO JOB |
|
|
Back to top |
|
|
loga_nathan_m
New User
Joined: 07 Jun 2007 Posts: 40 Location: India
|
|
|
|
hi,
Thanks a lot...
Could you please send the code using ICETOOL, That would be of very great help. |
|
Back to top |
|
|
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
Loganathan,
I Tested now its working very well for me
and
A-KEY 1 80 A below this give
A-KEY1 1 80 A
B-KEY 1 80 A
B-KEY1 1 80 A
try again i hope you will get it. |
|
Back to top |
|
|
murugan_mf
Active User
Joined: 31 Jan 2008 Posts: 148 Location: Chennai, India
|
|
Back to top |
|
|
vinothsubramanian
New User
Joined: 01 Sep 2006 Posts: 39 Location: Chennai, India
|
|
|
|
Try this and let us know your output:
Code: |
//STEP1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//TEMP1 DD DISP=(,DELETE,DELETE),SPACE=(CYL,10,10),RLSE),DSN=&&TEMP1
//OUTFILE DD DSN= **ouputfile
//INFILE DD DISP=SHR,DSN= **inputfile1
// DD DISP=SHR,DSN= **inputfile2
//TOOLIN DD *
SORT FROM(INFILE) TO(TEMP1) USING(CTL1)
COPY FROM(TEMP1) TO(OUTFILE) USING(CTL2)
//CTL1CNTL DD *
INREC BUILD=(1:1,80,81:SEQNUM,8,ZD,RESTART=(1,80))
SORT FIELDS=(1,80,CH,A)
SUM FIELDS=(81,8,ZD)
/*
//CTL2CNTL DD *
INCLUDE COND=(81,8,ZD,LT,2)
OUTREC FIELDS=(1,80)
/* |
|
|
Back to top |
|
|
himanshu7
Active User
Joined: 28 Aug 2007 Posts: 131 Location: At Desk
|
|
|
|
Hi loganathan,
Try this job.
Code: |
//STEP008 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//SSMSG DD SYSOUT=*
//FILEA DD DSN=FILEA,DISP=SHR
//FILEB DD DSN=FILEB,DISP=SHR
//FILEC DD DSN=DGCVPG2.REGION.DELTA,DISP=SHR
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(15,15)),
// DISP=(MOD,PASS)
//TOOLIN DD *
COPY FROM(FILEB) TO(T1) USING(CTL1)
COPY FROM(FILEA) TO(T1) USING(CTL2)
SELECT FROM(T1) TO(FILEC) ON(1,40,CH) NODUPS USING(CTL3)
/*
//CTL1CNTL DD *
INREC OVERLAY=(81:C'B')
/*
//CTL2CNTL DD *
INREC OVERLAY=(81:C'A')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=FILEC,INCLUDE=(81,1,CH,EQ,C'B'),
BUILD=(1,80)
/* |
The file lenght is 80 and will certainly fetch you No duplicates. |
|
Back to top |
|
|
loga_nathan_m
New User
Joined: 07 Jun 2007 Posts: 40 Location: India
|
|
|
|
Thanks a lot at all.
This above post looks perfect. |
|
Back to top |
|
|
loga_nathan_m
New User
Joined: 07 Jun 2007 Posts: 40 Location: India
|
|
|
|
Hi all,
One small doubt.
If my file contains Packed decimal, will that also be considered while comparison.
File1: Packed decimal, Position 1 to 5 value 25369
File2: Packed decimal, position 1 to 5 value 54879 all other position matches exactly with file1.
will the above two records will be considered as matching or unmatching.
It should be unmatching, just wanted to confirm
(I'm using the ICETOOL code) |
|
Back to top |
|
|
vinothsubramanian
New User
Joined: 01 Sep 2006 Posts: 39 Location: Chennai, India
|
|
|
|
Which Icetool code. Posted by me or himanshu7 |
|
Back to top |
|
|
loga_nathan_m
New User
Joined: 07 Jun 2007 Posts: 40 Location: India
|
|
|
|
Posted by himanshu7 |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
In the case you give (25369 vs 54879), the records would be considered unmatched.
However, you really need to consider the matching PD values to understand if CH would work for you or not.
If your packed decimal fields are "normalized", then the comparisons will work correctly with CH format. If the packed decimal fields are "not normalized", then you'd need to use separate ON operands for the CH and PD fields.
By "normalized", I mean that all of the positive PD values have the same sign (e.g. C) and all of the negative PD values have the same sign (e.g. D).
An example of "not normalized" PD values would be where some of the positive PD values have a C sign and some of the positive PD values have an F sign. |
|
Back to top |
|
|
|