Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Saikumaar Nagarajan wrote: |
We have a requirement to split one input files into 70 output files (70 number is fixed).
Conditions -
1. Number of records in each file is calculated based on nbr of records from input file.
2. Record can be written into the next file only when it is a new key
Eg: if Input file has 700 rec.
Approx Number of records per file will be 10
if first 12 records belong to the same key, and second key starts with 13th record onwards,
then my first file should have 12 records and starting from 13th record it should be written in 2nd file.
|
Saikumaar Nagarajan,
Your condition 2 nullifies cond 1. If you want to split the file based on the key, it doesn't matter as to how many records you have in the input file and what the split value is.
ex: 1
Input has 708 records and each key has 12 records
708/12 = 59 files
if you go by the count of 70 files then 708/70 = 10.11 rounded to 10.But your split need to account for same key value records in one file which makes the count of 10 records per file useless.
ex: 2
Input has 700 records and each key has 5 records
700/70 = 10 records per file which can contain records of 2 keys in one file.
But then your rule 2 specifies that the new key should be in a new file, making the count of 10 records per file useless
Since your intention is to split the file based on the key you can use when=group function to split the file
I assumed that your input files is FB file with LRECL of 80 and your key starts in pos 1 for 10 bytes and is already sorted
The following DFSORT JCL will give you the desired results
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=Your input FB 80 byte file,DISP=SHR
//OUT01 DD SYSOUT=*
//OUT02 DD SYSOUT=*
//OUT03 DD SYSOUT=*
//OUT04 DD SYSOUT=*
....all 70 files declaration
//OUT70 DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(83:SEQNUM,8,ZD,RESTART=(01,10))),
IFTHEN=(WHEN=GROUP,BEGIN=(83,8,ZD,EQ,1),PUSH=(81:ID=2))
OUTFIL FNAMES=OUT01,INCLUDE=(81,2,ZD,EQ,01),BUILD=(1,80)
OUTFIL FNAMES=OUT02,INCLUDE=(81,2,ZD,EQ,02),BUILD=(1,80)
OUTFIL FNAMES=OUT03,INCLUDE=(81,2,ZD,EQ,03),BUILD=(1,80)
OUTFIL FNAMES=OUT04,INCLUDE=(81,2,ZD,EQ,04),BUILD=(1,80)
OUTFIL FNAMES=OUT05,INCLUDE=(81,2,ZD,EQ,05),BUILD=(1,80)
OUTFIL FNAMES=OUT06,INCLUDE=(81,2,ZD,EQ,06),BUILD=(1,80)
OUTFIL FNAMES=OUT07,INCLUDE=(81,2,ZD,EQ,07),BUILD=(1,80)
OUTFIL FNAMES=OUT08,INCLUDE=(81,2,ZD,EQ,08),BUILD=(1,80)
OUTFIL FNAMES=OUT09,INCLUDE=(81,2,ZD,EQ,09),BUILD=(1,80)
OUTFIL FNAMES=OUT10,INCLUDE=(81,2,ZD,EQ,10),BUILD=(1,80)
.... all 70 outfil definitons
OUTFIL FNAMES=OUT70,INCLUDE=(81,2,ZD,EQ,70),BUILD=(1,80)
//* |
|
|