Posted: Wed Mar 17, 2004 3:22 am Post subject: Is this possible via sort?
My input file contains the following data:
Input File:
-------------------------
2002XXX100200300...
2003XXX100300200...
2004XXX100100500...
2002YYY100200300...
2003YYY100200300...
Etc.
Output file should look like this:
------------------------------------
1. For all XXX (or YYY) my output file should contain 4 records with years as 2001,2002,2003 and 2004.
2. When 2001 (or 2002,2003,2004) do not exist in the input file load the output file with 2001 (or 2002,2003,2004) + XXX (or YYY depending on the record) and the rest of the cols as zeros.
3. Output file should be sorted on Col 2 (XXX etc.) followed by Col 1. (2001 etc.)
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Wed Mar 17, 2004 10:19 am Post subject:
Relaxing,
The following DFSORT/ICETOOL job will give you the desired results. If you have syncsort at your shop then change the pgm name to synctool.I assumed that your input file is 80 bytes in length and is of FB Recfm.
A brief explanation of the Job. We first take the input and split each record into 5 records ,the first record being as is and the next corresponding to the years 2001 thru 2004. We also add a constant(1 thru 5) at the end of every record. The parm '/' is used to split the record in a new line.
The second sort operator takes in the above created dataset and sorts on the key (5,3) and the constants at the end of the record(81,1). By doing so we make sure that we have the orginal record as the first record for each key and year.
The third sort operator takes in the above sorted file and eliminates the duplicates leaving the desired output.
Thanks Kolusu. I shall try this. It is like going back to school and meeting your magic teacher who knows everything (and in a more elegant way) and is unselfish to share it.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Wed Mar 17, 2004 12:19 pm Post subject:
relaxing wrote
Quote:
I guess the automatic allocation is 80 FB unless Record Length is specified.
No. If the output data set already has an LRECL (e.g. OLD data set) or you specify the LRECL on the DD, then DFSORT does NOT override that LRECL. If the output data set does not already have an LRECL and you don't specify the LRECL on the DD, then DFSORT sets the output LRECL to the length of the reformatted record (e.g. OUTFIL OUTREC length).
You said you adjusted the job, but you don't show what you changed. However, the error message (ICE222A) indicates that you reformatted the record to 123 bytes with OUTFIL OUTREC, but you have LRECL=80 for the OUT data set.
When you post messages, please include the message number. Note that you can look up all of the DFSORT messages online using Lookat:
Just type in ICE222A and you'll get the full documentation for this DFSORT message. _________________ 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
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Wed Mar 17, 2004 12:28 pm Post subject:
Relaxing,
For sort you never have to code the dcb parameters. They are automatically calculated.so get rid of LRECL & RECFM parameters.If you notice my job , it does not have the DCB parameter. Since your input file is of recfm F, I am overriding that parameter to FB in the very first step itself. Now you output file is of RECFM FB.
The following JCL is tailored for your requirement.
PS: Next time you post , please post all the details like RECFM, LRECL along with a sample input and desired output. This will reduce the guesswork. _________________ Kolusu
www.linkedin.com/in/kolusu
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