I have to split a file in 5 files containing equal number of records. I will do it with dfsort but i don't see how.The input file contain variable number of records and i have to keep the input sequence.
Example: input file contain records 1 to 100, output file 1 must contain records 1 to 20, output file2 records 21 to 40,... and outfil 5 records 80 to 100.
Could anybody suggest a way to achieve this work with dfSort ?
Thank you for the answer, but that just the problem. In the example i spoke about 100 records but the next run, it will perhaps contain 200 records and so file 1 have to contain records 1 to 40 and not 1 to 20 + 101 to 120.
input file contain records 1 to 100, output file 1 must contain records 1 to 20, output file2 records 21 to 40,... and outfil 5 records 80 to 100.
Will the input file always contain an even multiple of 5 (e.g. 100, 200) or can it contain extra records (e.g. 102). If it can contain extra records, how do you want the records split among the 5 files when you have 102 records? Must the extra 2 records go to the fifth file or can they go to the first file or what?
Thanks for your interest to my problem.
If i don't have a multiple of 5, like in your example, i will have some file with one records more than the others. With your example, i will have 2 files with 101 records, and 3 with 100 records. Wich file contain one record more don't have any importance, but records must be in sequence, example: file 1 with records 1 to 101, file 2 with records 102 to 201, ... file 5 records 402 to 502. My problem is that i don't know the amount of records in advance. I can found it in the output message of a preceding step but i don't see how to divide it by 5 and pass this information to a sort step in the same job.
Can you please provide the SYNCSORT solution for the same?
If by "you", you mean "me": I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort. However, I can tell you that only DFSORT supports the IFTHEN and OVERLAY functions I used in my solution, so you can't use it with Syncsort.
If by "you", you mean somebody else, ignore this post.
Here's a new solution for this requirement that uses the SPLIT1R function of DFSORT available with z/OS DFSORT PTF UK90007 and DFSORT R14 PTF UK90006. SPLIT1R only does one rotation among the files so the records are always contiguous.
Here's a DFSORT job that uses SPLIT1R dynamically to divide any number of input records among any number of output files:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//C1 DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//CTL3CNTL DD *
OUTFIL FNAMES=(OUT01,OUT02,...,OUTnn), <--- change for nn
// DD DSN=*.C1,VOL=REF=*.C1,DISP=(OLD,PASS)
//OUT01 DD DSN=... output file01
//OUT02 DD DSN=... output file02
//OUTnn DD DSN=... output filenn <--- change for nn
//TOOLIN DD *
* Get the record count.
COPY FROM(IN) USING(CTL1)
* SPLIT1R=x where x = count/nn.
* nn is the number of output files.
COPY FROM(T1) TO(C1) USING(CTL2)
* Use SPLIT1R=x to split records contiguously among
* the nn output files.
COPY FROM(IN) USING(CTL3)
//CTL1CNTL DD *
//CTL2CNTL DD *
1,8,ZD,DIV,+nn, <--- set to nn
For complete information on SPLIT1R and the other new DFSORT/ICETOOL functions available with the April, 2006 PTFs, see: