Thanks so much for this Kolusu - it works great...I did notice that I had different record counts in 2 of the 3 files, due to the SUM setting. This identified a problem in my data, which I was able to clean up at the same time. So all is now well!
Have a great day - mine is already starting to be great. Billy On Mon, Aug 3, 2015 at 5:25 PM, Sri h Kolusu <[email protected]> wrote: > Bill, > > The trick is to concatenate the master file 3 times but have a header file > to distinguish the file and put the key values to be sorted at a common > place. (usually at the end) > > So the largest sort key is from file 2 which has 9 + 8 = 17 bytes and the > smallest sort key is from file3 which has just 8 bytes. So we pad spaces > to the right for key3. So depending on how you want to results you may > want to left pad with high values or binary zeroes. Try the following JCL > > //********************************************************************** > //* CREATE A 90 BYTE HEADER TO USE AS AN IDENTIFIER * > //********************************************************************** > //STEP0100 EXEC PGM=SORT > //SYSOUT DD SYSOUT=* > //SORTIN DD * > //SORTOUT DD DSN=&&HDR,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE) > //SYSIN DD * > OPTION COPY > OUTFIL REMOVECC,NODETAIL,BUILD=(90X),HEADER1=(3'$') > //* > //********************************************************************** > //* CONCATENATE THE MASTER FILE 3 TIMES EACH WITH A HEADER FILE AND * > //* PUT THE KEY AT A COMMON PLACE SO THAT WE CAN SORT IN 1 PASS. * > //* * > //* FILE INDICATOR WILL BE AT POSITION 91 * > //* * > //* FILE1 - SORT CHAR 10-15 AND THEN 40-47 WILL BE AT POSITION 92 * > //* FILE2 - SORT CHAR 73-81 AND THEN 40-47 WILL BE AT POSITION 92 * > //* FILE3 - SORT CHAR 40-47 WILL BE AT POSITION 92 * > //********************************************************************** > //STEP0200 EXEC PGM=SORT > //SYSOUT DD SYSOUT=* > //SORTIN DD DISP=SHR,DSN=&&HDR,VOL=REF=*.STEP0100.SORTOUT > // DD DISP=SHR,DSN=Your.Master.File > // DD DISP=SHR,DSN=&&HDR,VOL=REF=*.STEP0100.SORTOUT > // DD DISP=SHR,DSN=Your.Master.File > // DD DISP=SHR,DSN=&&HDR,VOL=REF=*.STEP0100.SORTOUT > // DD DISP=SHR,DSN=Your.Master.File > //OUT1 DD SYSOUT=* > //OUT2 DD SYSOUT=* > //OUT3 DD SYSOUT=* > //SYSIN DD * > INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),PUSH=(91:ID=1)), > IFTHEN=(WHEN=(91,1,ZD,EQ,1),OVERLAY=(92:10,6,40,8)), > IFTHEN=(WHEN=(91,1,ZD,EQ,2),OVERLAY=(92:73,9,40,8)), > IFTHEN=(WHEN=(91,1,ZD,EQ,3),OVERLAY=(92:40,8)) > > SORT FIELDS=(91,18,CH,A) $ FILE-ID + COMPOSITE KEY > SUM FIELDS=NONE > > OUTFIL FNAMES=OUT1,BUILD=(1,90), > INCLUDE=(91,1,ZD,EQ,1,AND,1,3,CH,NE,C'$$$') > > OUTFIL FNAMES=OUT2,BUILD=(1,90), > INCLUDE=(91,1,ZD,EQ,2,AND,1,3,CH,NE,C'$$$') > > OUTFIL FNAMES=OUT3,BUILD=(1,90), > INCLUDE=(91,1,ZD,EQ,3,AND,1,3,CH,NE,C'$$$') > > //* > > > Sri Hari Kolusu > DFSORT Development > IBM Corporation > Email: [email protected] > Phone: 520-799-2237 Tie Line: 321-2237 > > IBM Mainframe Discussion List <[email protected]> wrote on > 08/03/2015 01:29:54 PM: > > > From: Bill Ashton <[email protected]> > > To: [email protected] > > Date: 08/03/2015 01:30 PM > > Subject: Re: SORT one input to 3 output files - different orders > > Sent by: IBM Mainframe Discussion List <[email protected]> > > > > Hi Kolusu...yes, all the master files and the trans files are 90 bytes > FB. > > Each record has multiple pieces of data, with the three master files > being > > sorted on their respective "key". I did make one little error earlier, > by > > forgetting that two of the files have compound keys... so here is the > sort > > criteria once more - correctly! > > File1 - Sort Char 10-15 and then 40-47 > > File2 - Sort Char 73-81 and then 40-47 > > File3 - Sort Char 40-47 > > > > Thanks for your help! > > B > > > > On Mon, Aug 3, 2015 at 4:00 PM, Sri h Kolusu <[email protected]> wrote: > > > > > Bill, > > > > > > Are all Input files of the same LRECL and RECFM? If so we can > accomplish > > > the task in a Single pass of the data and sort the accordingly. There > is a > > > trick to get it done. Let me know the attributes of all the input file > and > > > desired output file attributes and I will show you a way to do it. > > > > > > Thanks, > > > Kolusu > > > DFSORT Development > > > IBM Corporation > > > > > > IBM Mainframe Discussion List <[email protected]> wrote on > > > 08/03/2015 12:33:46 PM: > > > > > > > From: Bill Ashton <[email protected]> > > > > To: [email protected] > > > > Date: 08/03/2015 12:34 PM > > > > Subject: SORT one input to 3 output files - different orders > > > > Sent by: IBM Mainframe Discussion List <[email protected]> > > > > > > > > Good afternoon, friends! I thought this should be easy, but I can't > get > > > > started with this. > > > > > > > > I have one "transaction" file that I need to add to 3 different > "master" > > > > files. The master files are in 3 different sequences, so I can't > just > > > sort > > > > the trans file and MOD it to the end. Also, because I don't know > which > > > day > > > > of this week the file will come in, I need to run this every day, > and so > > > > need to also drop my duplicate entries, as I know the trans file is > > > unique. > > > > > > > > Can this be done in a single sort step? > > > > > > > > For the sake of argument, assume these sorts: > > > > File1 - sort Char data in cols 10-15 > > > > File2 - sort Char data in cols 73-81 > > > > File3 - sort Char data in cols 40-47 > > > > > > > > Each file, when master & trans are combined, will all have the same > > > data, > > > > just in different order. > > > > > > > > Thanks for directing me! > > > > Billy > > > > > > > > -- > > > > Thank you and best regards, > > > > *Billy Ashton* > > > > > > > > > ---------------------------------------------------------------------- > > > > For IBM-MAIN subscribe / signoff / archive access instructions, > > > > send email to [email protected] with the message: INFO > IBM-MAIN > > > > > > > > > > ---------------------------------------------------------------------- > > > For IBM-MAIN subscribe / signoff / archive access instructions, > > > send email to [email protected] with the message: INFO IBM-MAIN > > > > > > > > > > > -- > > Thank you and best regards, > > *Billy Ashton* > > > > ---------------------------------------------------------------------- > > For IBM-MAIN subscribe / signoff / archive access instructions, > > send email to [email protected] with the message: INFO IBM-MAIN > > > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to [email protected] with the message: INFO IBM-MAIN > -- Thank you and best regards, *Billy Ashton* ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
