Posted: Mon Aug 30, 2004 5:38 pm Post subject: Join the Fields for a pair of records having a matching key
Hi
I know this can be done using DFSORT using SPLICE. But just curious whether we can do this using SYNCSORT.
Code:
File A has the following Record
--------------------------------
001 AAAAA
002 CCCCC
003 EEEEE
004 GGGGG
Code:
File B has the following Record
--------------------------------
001 BBBBB
003 DDDDD
004 FFFFF
005 HHHHH
Code:
My Output File is
------------------
001 AAAAA BBBBB
003 EEEEE DDDDD
004 GGGGG FFFFF
Both the File has a Record format of FB and LRECL of 80.
Also the Key is starting at position 1 and has a length of 3.
(In both the files).
Any help on this highly appreciated. _________________ Regds,
Somu
Thank You Kolusu.
I have searched these topics before my post. But as you can see it's merging
two files laterally. But my requirement is merging based on a key in these two files.That is only matched records should be merged and unmatched records should be discarded.
Hope I'm clear. _________________ Regds,
Somu
Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
Posted: Tue Aug 31, 2004 8:37 am Post subject:
Somu,
All you need is an additional omit statement to remove the non matched records. The approach is similar to the merging of the files. Here is a JCL which will give you the desired results.
Code:
//STEP0100 EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
001 AAAAA
002 CCCCC
003 EEEEE
004 GGGGG
//IN2 DD *
001 BBBBB
003 DDDDD
004 FFFFF
005 HHHHH
//T1 DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//T2 DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//CON DD DSN=&T1,VOL=REF=*.T1,DISP=(OLD,PASS)
// DD DSN=&T2,VOL=REF=*.T2,DISP=(OLD,PASS)
//OUT DD DSN=YOUR OUTPUT FILE,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(X,Y),RLSE)
//TOOLIN DD *
COPY FROM(IN1) USING(CTL1)
COPY FROM(IN2) USING(CTL2)
SORT FROM(CON) USING(CTL3)
//CTL1CNTL DD *
OUTFIL FNAMES=T1,
OUTREC=(01,10, $ FIRST 10 BYTES AS IS
6Z, $ PAD 6 BINARY ZEROES
17,64) $ REST OF THE FIELDS
//CTL2CNTL DD *
OUTFIL FNAMES=T2,
OUTREC=(01,4, $ FIRST 4 BYTES AS IS
6Z, $ PAD 6 BINARY ZEROES
5,5, $ FIELD TO BE MERGED
Z, $ PAD 1 BINARY ZERO
17,64) $ REST OF THE FIELDS
//CTL3CNTL DD *
OPTION EQUALS
SORT FIELDS=(1,3,CH,A) $ SORT ON KEY
SUM FIELDS=(11,4,BI, $ SUM ON FIELD
15,2,BI) $ SUM ON FIELD
OUTFIL FNAMES=OUT,
OMIT=(05,6,BI,EQ,X'00',OR, $ OMIT NON MATCHING RECORDS
11,6,BI,EQ,X'00')
/*
Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
Posted: Tue Aug 31, 2004 3:46 pm Post subject:
Somuk,
Try the following control cards.
Code:
//CTL1CNTL DD *
OUTFIL FNAMES=T1,
OUTREC=(01,10, $ FIRST 10 BYTES AS IS
6Z, $ PAD 6 BINARY ZEROES
10Z, $ PAD 10 BINARY ZEROES
17,54) $ REST OF THE FIELDS
//CTL2CNTL DD *
OUTFIL FNAMES=T2,
OUTREC=(01,4, $ FIRST 4 BYTES AS IS
6Z, $ PAD 6 BINARY ZEROES
5,5, $ FIELD TO BE MERGED
Z, $ PAD 1 BINARY ZERO
12,10, $ Comp-3 FIELD
17,54) $ REST OF THE FIELDS
//CTL3CNTL DD *
OPTION EQUALS
SORT FIELDS=(1,3,CH,A) $ SORT ON KEY
SUM FIELDS=(11,4,BI,
15,2,BI,
17,8,BI,
25,2,BI)
OUTFIL FNAMES=OUT,
OMIT=(05,6,BI,EQ,X'00',OR, $ OMIT NON MATCHING RECORDS
11,6,BI,EQ,X'00')
/*
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum