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
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.
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')
//*