View previous topic :: View next topic
Author
Message
Ambili S Active User Joined: 06 Sep 2007Posts: 112 Location: India
Hi
The input file has user and his bus route no details as follows.
USER1 Route1
USER2 Route2
USER3 Route3
USER4 Route5
theres another input file which has only valid route nos. Say there are 2 lakh records in this file
Route1
Route2
Route5
Route9
In my output i want only the records from first file which have valid route nos. Can this be achieved using SPLICE , keeping in view that 2nd file has 2 lakh valid route nos.though we can use INCLUDE COND , but as there are many records in 2nd file is it possible to use SPLICE or any other option.
hence o/p would be
USER1 Route1
USER2 Route2
USER4 Route5
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
What is the RECFM and LRECL of each input file?
Can there be duplicate users in file1?
Can there be duplicate routes in file2?
What is the starting position, length and format of the fields in each input file?
Back to top
Terry Heinze JCL Moderator Joined: 14 Jul 2008Posts: 1249 Location: Richfield, MN, USA
For conformity to a standard, please use the Western numbering system instead of lakh.
Back to top
Ambili S Active User Joined: 06 Sep 2007Posts: 112 Location: India
File 1 will have duplicate route nos.For e.g.
USER1 Route1
USER2 Route2
USER3 Route3
USER4 Route5
USER5 Route3
File 2 has only unique valid route nos.
Both files are FB , Rec length is 80. For File 1 the first field is user name , it's of length 15 , then route nos which starts from 16th position and is of length 20 , then there are other data till 80th pos.
For File 2 , there's only 1 field. It starts from 1 and is of length 20.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Assuming you want the output records sorted by the user name field, here's a DFSORT job that will do what you asked for.
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input file1 (FB/80)
//IN2 DD DSN=... input file2 (FB/80)
//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 DSN=... output file (FB/80)
//TOOLIN DD *
COPY FROM(IN2) TO(T1) USING(CTL1)
COPY FROM(IN1) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(T2) ON(16,20,CH) WITHALL -
WITH(1,81) USING(CTL3)
SORT FROM(T2) TO(OUT) USING(CTL4)
/*
//CTL1CNTL DD *
INREC BUILD=(16:1,20,81:C'BB')
/*
//CTL2CNTL DD *
INREC OVERLAY=(81:C'VV')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=T2,INCLUDE=(81,2,CH,EQ,C'VB'),BUILD=(1,80)
/*
//CTL4CNTL DD *
SORT FIELDS=(1,15,CH,A)
/*
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
Here is another way of getting the desired results using the new WHEN=GROUP function
Concatenate your both input files , but have the file2 (which just has the unq route numbers) first in the list.
Since the file2 has all spaces from pos 21 we use that as the indicator for a group.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ROUTE1
----+----1----+----2----+----3----+----4----+----5----+----6----+----7
ROUTE2
ROUTE5
ROUTE9
// DD *
USER1 ROUTE1
USER2 ROUTE2
USER3 ROUTE3
USER4 ROUTE5
USER5 ROUTE3
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=(21,60,CH,EQ,C' '),OVERLAY=(81:1,20)),
IFTHEN=(WHEN=NONE,OVERLAY=(81:16,20))
SORT FIELDS=(81,20,CH,A),EQUALS
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(21,60,CH,EQ,C' '),PUSH=(101:81,20))
OUTFIL BUILD=(1,80),
INCLUDE=(81,20,CH,EQ,101,20,CH,AND,21,60,CH,GT,C' ')
/*
Back to top
Ambili S Active User Joined: 06 Sep 2007Posts: 112 Location: India
Thanks , both the JCL's worked .
Back to top
Please enable JavaScript!