View previous topic :: View next topic
Author
Message
karthik_sripal New User Joined: 28 Mar 2008Posts: 69 Location: 125.16.180.5
Hi all,
i have a File1 like this, i would say this a s loookup file
Code:
----+----1----+----2----
************************
123 TN
345 KA
456 KL
************************
and file2 like this , i would like to call this as data file
Code:
----+----1----+--
*****************
123 1111111
123 1111111
123 1111111
345 2222222
345 2222222
456 3333333
*****************
and would like to have my output file like this
Code:
----+----1----+--
*****************
123 1111111 TN
123 1111111 TN
123 1111111 TN
345 2222222 KA
345 2222222 KA
456 3333333 KL
*****************
in essence, i need to look up the value for the key in the datafile and fetch it and append it to the data file record.
could some one please say me how to do this using SORT.
would be of great help.
Kindly write back if am not comprehensible
Thanks.
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?
Back to top
karthik_sripal New User Joined: 28 Mar 2008Posts: 69 Location: 125.16.180.5
we can have it same ..say 80 byte file. we write both those files so there is no constraint on Lrecl, so its totally under our jurisdiction.
Back to top
karthik_sripal New User Joined: 28 Mar 2008Posts: 69 Location: 125.16.180.5
and the Recfm is FB.
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
karthik_sripal,
Since both files are of the same length we can simply concatenate them together and use the group function to get the desired results. Just make sure that state code file has spaces in pos 5 thru 11 as we are using that field as indicator as to which file the record belongs to
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
----+----1----+----2----+----3----+----4----+----5----+----6----+---
123 TN
345 KA
456 KL
// DD *
123 1111111
123 1111111
123 1111111
345 2222222
345 2222222
456 3333333
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'1')),
IFTHEN=(WHEN=(5,7,CH,GT,C' '),OVERLAY=(81:C'2'))
SORT FIELDS=(1,3,CH,A),EQUALS
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(83:SEQNUM,8,ZD,RESTART=(1,3))),
IFTHEN=(WHEN=GROUP,BEGIN=(83,8,ZD,EQ,1),PUSH=(20:20,2,82:81,1))
OUTFIL INCLUDE=(81,2,ZD,EQ,21),BUILD=(1,80)
/*
The output from this job is
Code:
123 1111111 TN
123 1111111 TN
123 1111111 TN
345 2222222 KA
345 2222222 KA
456 3333333 KL
Back to top
karthik_sripal New User Joined: 28 Mar 2008Posts: 69 Location: 125.16.180.5
Thank you very Much Friend.
Back to top
Please enable JavaScript!