Posted: Mon Jul 09, 2007 1:03 pm Post subject: Write only first n messages in OUTFILs with Syncsort
We are trying to read an input file and split it into 3 files depending on values in columns 1 to 4. We only want the first 700000 records in each of the 3 OUTFILs. We believe that we could do it in DFSORT by using IFTHEN OUTREC logic and adding a sequence number then comparing the OUTFIL include to also check that the sequence number is less than 700001. How can we do this with Syncsort which does not support he IFTHEN logic?
SyncSort for z/OS 1.2 does support IFTHEN but that is probably not what you need. If you are looking to divide your output into 3 files based on the contents of particular field but you only want 7000 records in each output, we can do that much easier. Try the following code:
There are many other ways to break up the data being written to different OUTFILs. If this doesn't work for you let me know exactly what is wrong and we can work it out. _________________ Alissa Margulies
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
What level of Syncsort are you at, above 1.2 it does support IFTHEN logic.
Anyway, you should be able to OUTFIL FILES=nn,INCLUDE=,ENDREC= without the IFTHEN logic.
Thanks for the update, Alisssa. I tried your suggestion, but only the first OUTFIL contained any records. My understanding of the ENDREC parm is that it is specifying how many input records to process before ending rather than how many output records to process. If my interpretation is not correct, I can paste in my small test case so that you can check my input statements.
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Mon Jul 09, 2007 6:03 pm Post subject:
Alissa/Cics Guy,
ENDREC is processed before INCLUDE/OMIT conditions on OUTFIL. So only the first file will have the output and rest of the output files will be empty which is confirmed by OP.
mcclr,
I am not sure what version of syncsort you are running, but if you are interested I can show you a way to get the desired results but would involve 2 passes of data. If that is ok let me know the LRECL & RECFM of input & output files.
or if your shop has fileaid then you can use the following JCL to get the desired results
Thanks kolusu. We would prefer doing this in one pass, but 2 is better than the 4 we may end up with. The lrecl is 243 and the recfm is fb.
Alissa,
I would also be interested in any other ways that you may have to accomplish this.
Alissa and Frank,
Would it be inappropriate to suggest an enhancement request for both products to add a STOPAFT option to the OUTFIL statement? That would seem to be a fairly simple solution.
I had problems with the web site yesterday. I did not mean to post the message that was posted. I was trying to PREVIEW the message while I tested the solution and somehow the message got posted multiple times. To make matters worse for the solution to work there has to be too many restrictions on the input data that makes it weak.
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Tue Jul 10, 2007 1:07 pm Post subject:
mcclr,
Here is the JCL which will give you the desired results.Basically we split the input files into 3 different files and while doing that we add a seqnum to each output file and in the next step we use that seqnum to pick records which are less than or equal to desired count.
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Tue Jul 10, 2007 1:17 pm Post subject:
Alissa,
I think OP is running a version of syncsort which is less than syncsort z/os 1.2 version and most of the features like IFTHEN & RESTART parameters are only supported in versions 1.2 and higher. So he/she needs a solution which would proably work even on on syncsort's older versions.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Tue Jul 10, 2007 1:24 pm Post subject:
Quote:
Would it be inappropriate to suggest an enhancement request for both products to add a STOPAFT option to the OUTFIL statement? That would seem to be a fairly simple solution.
Since I "invented" ENDREC, let me explain the difference between what STOPAFT does and what ENDREC does.
STOPAFT=n stops after n input records are accepted. So let's say we have STOPAFT=5, an INCLUDE COND=(...), 20 input records and records 3-7 meet the INCLUDE criteria. We will stop processing at record 7 with records 3-7 in the output file.
ENDREC=n stops at record n regardless of how many records are accepted. So let's say we have OUTFIL with ENDREC=5, an INCLUDE=(...), 20 input records and records 3-7 meet the INCLUDE criteria. We will stop processing at record 5 with records 3-5 in the output file.
What's missing is STOPAFT=n for OUTFIL which would stop after n records are accepted. So let's say we have OUTFIL with STOPAFT=5, an INCLUDE=(...), 20 input records and records 3-7 meet the INCLUDE criteria. We will stop processing at record 7 with records 3-7 in the output file.
I will add STOPAFT for OUTFIL to the list of candidates for future enhancements to DFSORT. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Kolusu's solution of two steps is superior to our 4 step solution.
Thanks to Frank for the enhancement request for a STOPAFT option on OUTFIL and for the IFTHEN WHEN SEQNUM example that we found in another post.
Thanks to Alissa also. It appears that we will need to get release 1.2 of Syncsort and use Frank's IFTHEN WHEN SEQNUM logic because our data is not numeric but rather character and we want one file to contain data < 'CN ' the second file < 'OPTX' and the third file to contain the remainder - unless you have another idea that will work for that scenario.
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