|
View previous topic :: View next topic
|
| Author |
Message |
senjay
Active User

Joined: 10 May 2007 Posts: 147 Location: India
|
|
|
|
Hello,
I have the below input files. first column is key1 and second column is key2. The sample output should have the records if key1 in file 1 is found in file 2 and the corresponding key2 in file 1 is not found in file 2.
key1 - can have duplicates
key2 - can have duplicates
key1 + key2 combination - is unique.
My idea was a two step solution:
step 1: find the unmatched records from file1 with file2, key = key1 + key2
step 2: find the matched records from output of step 1 with file 2, key = key 1.
Problem:
THe DFSORT PTF we have is July 2008 and hence we can't use JOINKEYS.
Both the files are FB, LRECL = 80.
Could any of you guide me in getting the expected result.
sample input File 1:
| Code: |
A 01 SSS
A 02 SSS
B 03 TTT
B 02 TTT
B 01 TTT
C 03 RRR
D 03 EEE
Z 03 WER
Z 05 WER |
sample input File 2:
| Code: |
A 01 SSS
A 05 SSS
B 99 TTT
B 96 TTT
B 97 TTT
B 09 TTT
C 03 RRR
E 03 EEE
E 04 EEE
F 04 EEE
|
Expected Output:
| Code: |
A 02 SSS
B 03 TTT
B 02 TTT
B 01 TTT |
Code'd |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
| Back to top |
|
 |
senjay
Active User

Joined: 10 May 2007 Posts: 147 Location: India
|
|
|
|
Bill,
Thanks to the pointer, Now I got the solution.
The solution is posted below as it might be of some help to others. THe LRECL is assumed to be 20.
| Code: |
//STEP010 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=ABC.INP1,DISP=SHR
//IN2 DD DSN=ABC.INP2,DISP=SHR
//MOD1 DD DSN=&&MOD1,
// DISP=(MOD,PASS),
// SPACE=(CYL,(X,Y),RLSE)
//OUT1 DD DSN=ABC.OUT1,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(2,5),RLSE),
// DCB=(RECFM=FB,LRECL=20)
//OUTX DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(MOD1) USING(ICE1)
COPY FROM(IN2) TO(MOD1) USING(ICE2)
SELECT FROM(MOD1) TO(OUT1) ON(1,1,CH) ON(3,2,CH) NODUPS USING(ICE3)
//ICE1CNTL DD *
INREC OVERLAY=(21:C'A')
//ICE2CNTL DD *
INREC OVERLAY=(21:C'B')
//*
//ICE3CNTL DD *
OUTFIL INCLUDE=(21,1,CH,EQ,C'A'),OUTREC=(1,20)
//*
//STEP020 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//OUT1 DD DSN=ABC.OUT1,DISP=SHR
//IN2 DD DSN=ABC.INP2,DISP=SHR
//MOD2 DD DSN=&&MOD2,DISP=(MOD,PASS),
// SPACE=(CYL,(X,Y),RLSE)
//OUT2 DD DSN=ABC.OUT2,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(2,5),RLSE),
// DCB=(RECFM=FB,LRECL=20)
//OUTX DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN2) TO(MOD2) ON(1,1,CH) FIRST USING(ICE1)
COPY FROM(OUT1) TO(MOD2) USING(ICE2)
SPLICE FROM(MOD2) TO(OUT2) ON(1,1,CH) WITHALL -
WITH(1,21) KEEPNODUPS KEEPBASE USING(ICE3)
//ICE1CNTL DD *
INREC OVERLAY=(21:C'RR')
//ICE2CNTL DD *
INREC OVERLAY=(21:C'MM')
//*
//ICE3CNTL DD *
OUTFIL INCLUDE=(21,2,CH,EQ,C'MR'),BUILD=(1,20)
//*
|
Explanation:
In step010, key is KEY1 + Key2 and the unmatched record from file 1 with file 2 is written in to OUT1 file.
In step020, the records from OUT1 file that don't have key1 in INP2 file should be rejected. since INP2 file records are not written in to output file, we remove the duplicates based on KEY1 from INP2 file. Now we have a master file (OUT1 ddname) with duplicates on it (key = KEY1) and Reference file with no duplicates (Key = KEY1). Then SPLICE mentioned in the pointer is applied to get the required output. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
senjay,
You really don't need that many passes of data, Here is 2 pass solution. Your both input files are FB and lrecl=80 , so we can actually concatenate a fixed header to identify the records from each files using that header.
| Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
$$$$
// DD *
A 01 SSS
A 02 SSS
B 03 TTT
B 02 TTT
B 01 TTT
C 03 RRR
D 03 EEE
Z 03 WER
Z 05 WER
// DD *
$$$$
// DD *
A 01 SSS
A 05 SSS
B 99 TTT
B 96 TTT
B 97 TTT
B 09 TTT
C 03 RRR
E 03 EEE
E 04 EEE
F 04 EEE
//T1 DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SORT FROM(T1) USING(CTL2)
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'$$$$'),PUSH=(81:ID=1))
SORT FIELDS=(1,4,CH,A),EQUALS
SUM FIELDS=(81,1,ZD)
OUTFIL FNAMES=T1
//*
//CTL2CNTL DD *
SORT FIELDS=(1,1,CH,A,81,1,ZD,D),EQUALS
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(83:SEQNUM,4,ZD,RESTART=(1,1))),
IFTHEN=(WHEN=GROUP,BEGIN=(83,4,ZD,EQ,1),PUSH=(82:81,1))
OUTFIL FNAMES=OUT,BUILD=(1,80),INCLUDE=(81,2,SS,EQ,C'12,13')
//* |
This will produce the following output
| Code: |
A 02 SSS
B 01 TTT
B 02 TTT
B 03 TTT |
|
|
| Back to top |
|
 |
senjay
Active User

Joined: 10 May 2007 Posts: 147 Location: India
|
|
|
|
Hi Skolusu,
Thanks for the efficient one, This gives me some more ideas.
Thanks again,
Senthil |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|