Hi,
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 ?
Will copy 20 record each int0 all the output files, but in case if there are more than 100 records it will continue the writing 101-120 record to FILE01 and so on...
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.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
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.
OUT1 will have 1-20, OUT2 will have 21-40, OUT3 will have 41-60, OUT4 will have 61-80 and OUT5 will have 81-102. Not quite what you said, but hopefully close enough.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
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.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
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:
Code:
//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)
* Generate:
* 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 *
OUTFIL FNAMES=T1,REMOVECC,NODETAIL,
TRAILER1=(COUNT=(M11,LENGTH=8))
/*
//CTL2CNTL DD *
OUTREC BUILD=(2X,C'SPLIT1R=',
1,8,ZD,DIV,+nn, <--- set to nn
TO=ZD,LENGTH=8,80:X)
/*
For complete information on SPLIT1R and the other new DFSORT/ICETOOL functions available with the April, 2006 PTFs, see:
This option is working fine with record format FB but with VB it is giving error. Could you please let me know what changes are required to make VB format work?
I am getting one other error. Could you please help me out?
I am splitting a file in to 4 equal files and the input files contains less than 4 records (in case), the current ICETOOL logic is getting abended with
ICE007A F SYNTAX ERROR with all empty file allocations.
Suppose if my input file has 3 records then I want my job to be successful with 3 records distributed to first 3 files and the fourth file as an empty file.