View previous topic :: View next topic
Author
Message
Prasanya New User Joined: 04 Jun 2007Posts: 34 Location: Chennai
Hi,
I have a certain job in which I'm required to compare two files. I'm supposed to write records to the Output that are Present in the First File, but absent in the first.
For Example, if I have the Two Input Files as below:
File I:
10000 1234 ABC 9999
10001 1235 XYZ 9090
10002 1236 AXZ 9009
File II:
10000 1234 ABC 9999
10002 1236 AXZ 9009
10006 9999 MAD 1111
I need the Output file as below:
Output File:
10000 1234 ABC 9999
10002 1236 AXZ 9009
It's Possible using DFSORT. The Key Fields are 1:5,BI & 12:3,CH. Can someone help me with this please?
Back to top
rajatbagga Active User Joined: 11 Mar 2007Posts: 199 Location: india
hi,
Quote:
Present in the First File, but absent in the first
what do you mean by the above statement?
Back to top
rajatbagga Active User Joined: 11 Mar 2007Posts: 199 Location: india
hi,
As per your above example the output file contains the records which are matching in both the input files...is that what you need?
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Prasanya,
If you want the records from input file1 that have a match in input file2 on those two keys, you can use a DFSORT/ICETOOL job like this:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD *
10000 1234 ABC 9999
10001 1235 XYZ 9090
10002 1236 AXZ 9009
/*
// DD *
10000 1234 ABC 9999
10002 1236 AXZ 9009
10006 9999 MAD 1111
/*
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(CON) TO(OUT) ON(1,5,BI) ON(12,3,CH) FIRSTDUP
/*
If that's not what you want, then you need to do a better job of explaining what you do want.
Back to top
Prasanya New User Joined: 04 Jun 2007Posts: 34 Location: Chennai
Sorry,
My Requirement is that, in the given example, for the Files given, I need the Output to contain only the record
10006 9999 MAD 1111
This Record is present in the Second File, but a corresponding match is not found in the first.
I do not want the record
10001 1235 XYZ 9090
to be displayed in the output, as it is a record which is present in the first file with no match in the second file.
Sorry for any inconvenience.
Back to top
rajatbagga Active User Joined: 11 Mar 2007Posts: 199 Location: india
Hi Prasanya,
Here is the DFSORT/ICETOOL code which meets your requrement:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
10000 1234 ABC 9999
10001 1235 XYZ 9090
10002 1236 AXZ 9009
/*
//IN2 DD *
10000 1234 ABC 9999
10002 1236 AXZ 9009
10006 9999 MAD 1111
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(T2) ON(1,5,BI) ON(12,3,CH) -
KEEPBASE KEEPNODUPS WITHALL WITH(1,81) WITH(83,8) USING(CTL3)
SORT FROM(T2) TO(OUT) USING(CTL4)
/*
//CTL1CNTL DD *
INREC OVERLAY=(81:C'AA',83:8X)
/*
//CTL2CNTL DD *
INREC OVERLAY=(81:C'BB',83:SEQNUM,8,ZD)
/*
//CTL3CNTL DD *
OUTFIL FNAMES=T2,INCLUDE=(81,2,CH,EQ,C'BB')
/*
//CTL4CNTL DD *
SORT FIELDS=(83,8,ZD,A)
OUTREC BUILD=(1,80)
/
*
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Prasanya,
Here's a simpler way to do what you asked for with DFSORT/ICETOOL:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
10000 1234 ABC 9999
10001 1235 XYZ 9090
10002 1236 AXZ 9009
/*
//IN2 DD *
10000 1234 ABC 9999
10002 1236 AXZ 9009
10006 9999 MAD 1111
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SELECT FROM(T1) TO(OUT) ON(1,5,BI) ON(12,3,CH) NODUPS USING(CTL3)
/*
//CTL1CNTL DD *
INREC OVERLAY=(81:C'1')
/*
//CTL2CNTL DD *
INREC OVERLAY=(81:C'2')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,INCLUDE=(81,1,CH,EQ,C'2'),
BUILD=(1,80)
/*
Back to top
Please enable JavaScript!