View previous topic :: View next topic
Author
Message
teevijay New User Joined: 20 Mar 2006Posts: 22
Sorry Guys,
Really running out of time...but need a quick help. i tried to use splice to match two files. File 1 is a driver( Key) file, and File 2 is key + data.
Requirement is, if there is a match, then write all the Matched records from File 2 into File 3.
File 1 --> Lrecl =2, Key @ 1 & 2 position
------
11
12
13
14
15
File 2 --> Lrecl = 10, Key @ 9 & 10 positions
------
AAAAAAAA11
BBBBBBBB11
CCCCCCCC13
DDDDDDDD14
EEEEEEEE16
FFFFFFFF17
GGGGGGGG18
HHHHHHHH18
Code :
----------
//TOOLIN DD *
COPY FROM(IN1) TO(CMPP1) USING(CTL1)
COPY FROM(IN2) TO(CMPP2) USING(CTL2)
SPLICE FROM(CONCAT) TO(COMBINE) ON(9,2,CH) WITHALL WITH(1,10)
Output
------
AAAAAAAA11
BBBBBBBB11
CCCCCCCC13
DDDDDDDD14
HHHHHHHH18 Key 18 is not there in File 1 but still its appearing in the output.
Kindly Help. Many thanks.
Vijay
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Vijay,
Can you try the below sort jcl.
Code:
//STEP00 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
11
12
13
14
15
/*
//IN2 DD *
AAAAAAAA11
BBBBBBBB11
CCCCCCCC13
DDDDDDDD14
EEEEEEEE16
FFFFFFFF17
GGGGGGGG18
HHHHHHHH18
/*
//TMP1 DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA
//OUT DD SYSOUT=*
//*
//TOOLIN DD *
COPY FROM(IN1) TO(TMP1) USING(CTL1)
COPY FROM(IN2) TO(TMP1) USING(CTL2)
SPLICE FROM(TMP1) TO(OUT) ON(9,2,CH) WITH(1,10) WITHALL USING(CTL3)
//*
//CTL1CNTL DD *
OPTION COPY
INREC FIELDS=(9:1,2,11:C'0 ')
//*
//CTL2CNTL DD *
OPTION COPY
INREC FIELDS=(1,10,11:C' 1')
//*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,OMIT=(11,1,CH,EQ,C' '),OUTREC=(1,10)
//*
OUT
Code:
AAAAAAAA11
BBBBBBBB11
CCCCCCCC13
DDDDDDDD14
Thanks,
Arun
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Arun,
You don't need two id characters for this - one id character will do it.
Vijay,
You can use a DFSORT/ICETOOL job like this to do what you asked for:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
11
12
13
14
15
/*
//IN2 DD *
AAAAAAAA11
BBBBBBBB11
CCCCCCCC13
DDDDDDDD14
EEEEEEEE16
FFFFFFFF17
GGGGGGGG18
HHHHHHHH18
/*
//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)
SPLICE FROM(T1) TO(OUT) ON(9,2,CH) WITH(1,10) WITHALL USING(CTL3)
/*
//CTL1CNTL DD *
OPTION COPY
INREC BUILD=(9:1,2,11:C'1')
/*
//CTL2CNTL DD *
OPTION COPY
INREC OVERLAY=(11:C'2')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,OMIT=(11,1,CH,EQ,C'2'),BUILD=(1,10)
/*
Back to top
teevijay New User Joined: 20 Mar 2006Posts: 22
Thanks guys.
Back to top
revdpoel New User Joined: 01 Nov 2006Posts: 56
All the records from file 2, which are present in file 1, are written to the output file.
Ok
But what if you want the records from file 2, which are NOT present in file 1, to be written to the output file. How becomes the code then?
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Show an example of your input records and what you want for output.
Back to top
revdpoel New User Joined: 01 Nov 2006Posts: 56
File 1 --> Lrecl =2, Key @ 1 & 2 position
------
11
12
13
14
15
File 2 --> Lrecl = 10, Key @ 9 & 10 positions
------
AAAAAAAA11
BBBBBBBB11
CCCCCCCC13
DDDDDDDD14
EEEEEEEE16
FFFFFFFF17
GGGGGGGG18
HHHHHHHH18
Output
------
EEEEEEEE16
FFFFFFFF17
GGGGGGGG18
HHHHHHHH18
because 16, 17 and 18 aren't available in file 1.
See file 1 for instance as accounts. And file 2 as transactions on an account. If you can not find an account for a transaction in the account-file (file 1) it has to be written to the output file.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Here's a DFSORT/ICETOOL job for that requirement:
Code:
//S2 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input file1 (FB/2)
//IN2 DD DSN=... input file1 (FB/10)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=... output file (FB/10)
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(9,2,CH) KEEPNODUPS KEEPBASE -
WITHALL WITH(1,11) USING(CTL3)
/*
//CTL1CNTL DD *
OPTION COPY
INREC BUILD=(9:1,2,11:C'BB')
/*
//CTL2CNTL DD *
OPTION COPY
INREC OVERLAY=(11:C'VV')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,INCLUDE=(11,2,CH,EQ,C'VV'),BUILD=(1,10)
/*
Back to top
Please enable JavaScript!