IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Split file into 8 files with header from input by syncsort


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Amit Singh.120888

New User


Joined: 24 Oct 2012
Posts: 6
Location: India

PostPosted: Sun Oct 28, 2012 10:21 am
Reply with quote

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
View user's profile Send private message
palak kamdar

New User


Joined: 14 Oct 2012
Posts: 1
Location: India

PostPosted: Sun Oct 28, 2012 1:30 pm
Reply with quote

Hello,

You can try:

Sort fields=copy
outfil files=(First,Second, Third...till Eighth ),spilt

Or you can see similar example at :

ftp.software.ibm.com/storage/dfsort/mvs/sorttrck.pdf

Page 59

Hope this helps.

Regards,
Back to top
View user's profile Send private message
Amit Singh.120888

New User


Joined: 24 Oct 2012
Posts: 6
Location: India

PostPosted: Sun Oct 28, 2012 1:36 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Oct 28, 2012 2:18 pm
Reply with quote

If you want to add headers and trailers, look at the reporting functions of OUTFIL, HEADERn, TRAILERn.
Back to top
View user's profile Send private message
Amit Singh.120888

New User


Joined: 24 Oct 2012
Posts: 6
Location: India

PostPosted: Sun Oct 28, 2012 3:26 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Oct 28, 2012 4:37 pm
Reply with quote

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
View user's profile Send private message
Amit Singh.120888

New User


Joined: 24 Oct 2012
Posts: 6
Location: India

PostPosted: Sun Oct 28, 2012 5:39 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Oct 28, 2012 5:55 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Sun Oct 28, 2012 8:04 pm
Reply with quote

Quote:
1) This has to be done in one SYNCSORT step.


stupid requirement ...
what if ??? icon_evil.gif

be certain that is somebody posts a solution it will be the best You will get !
Back to top
View user's profile Send private message
Amit Singh.120888

New User


Joined: 24 Oct 2012
Posts: 6
Location: India

PostPosted: Mon Oct 29, 2012 8:43 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Oct 29, 2012 9:18 am
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Mon Oct 29, 2012 9:45 am
Reply with quote

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
View user's profile Send private message
Amit Singh.120888

New User


Joined: 24 Oct 2012
Posts: 6
Location: India

PostPosted: Mon Oct 29, 2012 9:50 am
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Mon Oct 29, 2012 10:58 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Oct 29, 2012 2:09 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Oct 29, 2012 6:57 pm
Reply with quote

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 icon_sad.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top