|
View previous topic :: View next topic
|
| Author |
Message |
Amit Singh.120888
New User
Joined: 24 Oct 2012 Posts: 6 Location: India
|
|
|
|
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 |
|
| Back to top |
|
 |
palak kamdar
New User
Joined: 14 Oct 2012 Posts: 1 Location: India
|
|
| Back to top |
|
 |
Amit Singh.120888
New User
Joined: 24 Oct 2012 Posts: 6 Location: India
|
|
|
|
Hi,
Using split by option we can only split the files, but how do we add the header and trailers??? And that too in one step?
please suggest syncsort steps only. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| If you want to add headers and trailers, look at the reporting functions of OUTFIL, HEADERn, TRAILERn. |
|
| Back to top |
|
 |
Amit Singh.120888
New User
Joined: 24 Oct 2012 Posts: 6 Location: India
|
|
|
|
I think I was not clear with my questin.
I meant how can I use SPLITBY and header trailer addition steps in the same step??? |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
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. |
|
| Back to top |
|
 |
Amit Singh.120888
New User
Joined: 24 Oct 2012 Posts: 6 Location: India
|
|
|
|
Hi,
Apologies for the loose description.
My input file is :
| Code: |
1000|mark |anthony |cambridge
1001|tom |hoppins |sommerville
1002|nick |breganza |luxemburg
1003|mark |anthony |cambridge |
desired output files:
File1:
| Code: |
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. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
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. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
| Quote: |
| 1) This has to be done in one SYNCSORT step. |
stupid requirement ...
what if ???
be certain that is somebody posts a solution it will be the best You will get ! |
|
| Back to top |
|
 |
Amit Singh.120888
New User
Joined: 24 Oct 2012 Posts: 6 Location: India
|
|
|
|
Hi,
I am unable to get the syntax correct. Can anyone please
write the step for me? It would be of great help...
Following error is shown
SORTOF01 SPLIT, SPLITBY, SPLIT1R OR REPEAT INCOMPATIBLE WITH REPORT WRITING |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 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. |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
| Quote: |
1) This has to be done in one SYNCSORT step.
|
Instead of putting restrictions on your request, why don't you try to get a working solution first ? it's better than no solution at all.
Gerry |
|
| Back to top |
|
 |
Amit Singh.120888
New User
Joined: 24 Oct 2012 Posts: 6 Location: India
|
|
|
|
Yes Dick, I understand that.
But I guess, there is no solution to this i.e to achive this functionality in one step.
Anyways,thanks for all the help. |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
here is a 1 step solution, but really I don't see the difference between 1 or 2 steps.
| Code: |
//SORT0001 EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
1000|MARK |ANTHONY |CAMBRIDGE
1001|TOM |HOPPINS |SOMMERVILLE
1002|NICK |BREGANZA |LUXEMBURG
1003|MARK |ANTHONY |CAMBRIDGE
//OUT01 DD DSN=&&T1,SPACE=(TRK,(20,5),RLSE),DISP=(,PASS,)
//OUT02 DD DSN=&&T2,SPACE=(TRK,(20,5),RLSE),DISP=(,PASS,)
//OUT03 DD DSN=&&T3,SPACE=(TRK,(20,5),RLSE),DISP=(,PASS,)
//OUT04 DD DSN=&&T4,SPACE=(TRK,(20,5),RLSE),DISP=(,PASS,)
//OUT05 DD DSN=&&T5,SPACE=(TRK,(20,5),RLSE),DISP=(,PASS,)
//OUT06 DD DSN=&&T6,SPACE=(TRK,(20,5),RLSE),DISP=(,PASS,)
//OUT07 DD DSN=&&T7,SPACE=(TRK,(20,5),RLSE),DISP=(,PASS,)
//OUT08 DD DSN=&&T8,SPACE=(TRK,(20,5),RLSE),DISP=(,PASS,)
//OUT01R DD SYSOUT=*
//OUT02R DD SYSOUT=*
//OUT03R DD SYSOUT=*
//OUT04R DD SYSOUT=*
//OUT05R DD SYSOUT=*
//OUT06R DD SYSOUT=*
//OUT07R DD SYSOUT=*
//OUT08R DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) USING(CTLA)
COPY FROM(OUT01) USING(CTL1)
COPY FROM(OUT02) USING(CTL2)
COPY FROM(OUT03) USING(CTL3)
COPY FROM(OUT04) USING(CTL4)
COPY FROM(OUT05) USING(CTL5)
COPY FROM(OUT06) USING(CTL6)
COPY FROM(OUT07) USING(CTL7)
COPY FROM(OUT08) USING(CTL8)
/*
//CTLACNTL DD *
SORT FIELDS=COPY
OUTFIL FNAMES=(OUT01,OUT02,OUT03,OUT04,OUT05,OUT06,OUT07,OUT08),
SPLIT
/*
//CTL1CNTL DD *
SORT FIELDS=COPY
OUTFIL FNAMES=OUT01R,REMOVECC,
HEADER1=(001:'HEADER',
010:&DATE,
020:&TIME),
TRAILER1=('TRAILER ',COUNT=(M11,LENGTH=10))
/*
//CTL2CNTL DD *
SORT FIELDS=COPY
OUTFIL FNAMES=OUT02R,REMOVECC,
HEADER1=(001:'HEADER',
010:&DATE,
020:&TIME),
TRAILER1=('TRAILER ',COUNT=(M11,LENGTH=10))
/*
//CTL3CNTL DD *
SORT FIELDS=COPY
OUTFIL FNAMES=OUT03R,REMOVECC,
HEADER1=(001:'HEADER',
010:&DATE,
020:&TIME),
TRAILER1=('TRAILER ',COUNT=(M11,LENGTH=10))
/*
//CTL4CNTL DD *
SORT FIELDS=COPY
OUTFIL FNAMES=OUT04R,REMOVECC,
HEADER1=(001:'HEADER',
010:&DATE,
020:&TIME),
TRAILER1=('TRAILER ',COUNT=(M11,LENGTH=10))
/*
//CTL5CNTL DD *
SORT FIELDS=COPY
OUTFIL FNAMES=OUT05R,REMOVECC,
HEADER1=(001:'HEADER',
010:&DATE,
020:&TIME),
TRAILER1=('TRAILER ',COUNT=(M11,LENGTH=10))
/*
//CTL6CNTL DD *
SORT FIELDS=COPY
OUTFIL FNAMES=OUT06R,REMOVECC,
HEADER1=(001:'HEADER',
010:&DATE,
020:&TIME),
TRAILER1=('TRAILER ',COUNT=(M11,LENGTH=10))
/*
//CTL7CNTL DD *
SORT FIELDS=COPY
OUTFIL FNAMES=OUT07R,REMOVECC,
HEADER1=(001:'HEADER',
010:&DATE,
020:&TIME),
TRAILER1=('TRAILER ',COUNT=(M11,LENGTH=10))
/*
//CTL8CNTL DD *
SORT FIELDS=COPY
OUTFIL FNAMES=OUT08R,REMOVECC,
HEADER1=(001:'HEADER',
010:&DATE,
020:&TIME),
TRAILER1=('TRAILER ',COUNT=(M11,LENGTH=10))
/*
|
Gerry |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
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. |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
| Quote: |
| But I guess, there is no solution to this i.e to achive this functionality in one step. |
This is not what you were asked for.
You should have posted your jcl and sort control statements along with all of the informational/diagnostic info generated by the run  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|