I have a file with N records.
I want to split the file into 8 files having equal number of records in each file
Header and trailer should be there in each output file
this all should be done in a single step using SYNCSORT
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
No, you weren't clear:
Quote:
how do we add the header and trailers
and
Quote:
Header and trailer should be there in each output file
You didn't even mention that you have header and trailer on your input, which is implied by your apparent dislike of the OUTFIL suggestion.
What do you want in the headers and trailers on your output? Header same as input? Trailer with what? And presumably reflecting the content of the output?
Show sample of your input (including header and trailer) and expected output (including headers and trailers) all in the Code tags please. Also RECFM and LRECL of input and outputs. Plus anything else you'd like to mention that, on reflection, you feel will fully describe your situation to us, rather than a loose description for you who has the full description to hand.
HEADER DATE TIME
1000|mark |anthony |cambridge
TRAILER 0000000001
File2:
Code:
HEADER DATE TIME
1001|tom |hoppins |sommerville
TRAILER 0000000001
File3:
Code:
HEADER DATE TIME
1002|nick |breganza |luxemburg
TRAILER 0000000001
File4:
Code:
HEADER DATE TIME
1003|mark |anthony |cambridge
TRAILER 0000000001
File5:
Code:
HEADER DATE TIME
TRAILER 0000000000
File6:
Code:
HEADER DATE TIME
TRAILER 0000000000
File7:
Code:
HEADER DATE TIME
TRAILER 0000000000
File8:
Code:
HEADER DATE TIME
TRAILER 0000000000
1) This has to be done in one SYNCSORT step.
2) Records should be equally distributed in the 8 output files in sequential manner i.e splitby option is out of contention.
3) The number of input records are not fixed. For simplicity I have just taken 4 records. Any no. of records may come in the input file.
4) The date and time in header will be report creation date and time.
5) The 0000000001 in trailer denotes record count.
6) DCB parameters
LRECL=80
RECFM=FB, for both input and output files.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Use SPLIT on OUTFIL, with HEADER1, TRAILER1, REMOVECC. You'll need to source your date and time from something, so check your SyncSort documentation for that. If you really want current (system) date you should be able to get it all in one step, but you have the "midnight" problem, as well as re-runs and testing.
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello,
Do not ask people to do your work for you . . . We are here to help, but not actually to the work.
Some folks may post a solution, but you need to go on as they might not post what you want or (unfortunately) incorrect/untested "solutions" sometimes get posted.
Why did you post only part of one line of the informational/diagnostic info (for whatever reason, you omitted the message id. . .
Using the Code tag, you need to post the JCL and sort control statements as well as the informational/diagnostic info generated.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
OK, SPLIT does exactly what you want, and the HEADERn, TRAILERn do exactly what you want, but you can't use them together.
So, you have to decide which to replace. The HEADERn/TRAILERn are doing more complicated processing, so I'd replace the SPLIT.
If you "temporarily add" an extra field to your record, and you use MOD of 8 on a SEQNUM, then you will get a value of 0 through 7. Then on your eight OUTFIL with the HEADERn/TRAILERn, use INCLUDE to select the records needed.