MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Spliting an input file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
yrcreddy
Beginner


Joined: 28 Dec 2005
Posts: 27
Topics: 12

PostPosted: Wed Jul 19, 2006 5:07 am    Post subject: Spliting an input file Reply with quote

Please help me how to split the input file to get the desired result.

My input file records are as follow:
Header1
1
2
3
4
5
6
7
Count 8
Where the trailer contains the no of records in the input file.

The output files are:

OutFile1:
header1
1
2
Count 2

OutFile2:
header1
3
4
Count 2
OutFile3:

header1
5
6
Count 2
OutFile4:

header1
7
Count 1

I am using the following JCL to split the file and getting the file splitting but I need to add the header and trailer for each output dataset.
My JCL is:
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=(OUT01,OUT02,OUT03,OUT04),
SPLITBY=2,STARTREC=2,ENDREC=7
/*
The above card will exclude the header and trailer records from the input file.

The count of the records of the input file is different. Can you please help me how to split the input file based on the above specified criteria.
_________________
Thanks,
Ramachandra Reddy
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jul 19, 2006 5:42 am    Post subject: Reply with quote

yrcreddy,

Please answer the following Questions.


    Is there a way to identify the header and the trailer in the input file?

    Is the split always 2 records into each file? or can this number change?

    What is the LRECL and RECFM of both input and desired output files?

    Do you want the HEADER from the input files to be Copied in all the output files or do you want to generate a Header for all the output files




Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
yrcreddy
Beginner


Joined: 28 Dec 2005
Posts: 27
Topics: 12

PostPosted: Wed Jul 19, 2006 6:26 am    Post subject: Reply with quote

Hi kolusu,

Here i am giving your queries answres:
1)Is there a way to identify the header and the trailer in the input file?
there is no way to find the header but the trailer should be allways the count of the file.

2)Is the split always 2 records into each file? or can this number change?
as per my requirement i need to split the file for each 40 records.

3)What is the LRECL and RECFM of both input and desired output files?
LRECL is 80 and RECFM is FB

4)Do you want the HEADER from the input files to be Copied in all the output files or do you want to generate a Header for all the output files
I want to copy the HEADER from the input file to be copied in all output file.
_________________
Thanks,
Ramachandra Reddy
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jul 19, 2006 8:23 am    Post subject: Reply with quote

yrcreddy,

Your requirement is sligtly trickier because you want the header in all your output files. SPLIT, SPLITBY, SPLIT1R cannot be used with reporting features like header and trailer1. So try this

Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                         
HEADER1                                                 
1                                                       
2                                                       
3                                                       
4                                                       
5                                                       
6                                                       
7                                                       
COUNT 8                                                 
//HDR      DD DSN=&H,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//REST     DD DSN=&R,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//TRL      DD DSN=&T,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//CNTL     DD DSN=&C,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                         
  OUTFIL FNAMES=HDR,STARTREC=1,ENDREC=1,                   
  OUTREC=(C'HDR,C',                                         
          C'''',                                           
          01,50,                                           
          C'''',                                           
          80:X)                                             
  OUTFIL FNAMES=REST,STARTREC=2                             
  OUTFIL FNAMES=TRL,REMOVECC,NODETAIL,                     
  TRAILER1=(' OPTION STOPAFT=',COUNT-2=(M11,LENGTH=8),80:X)
  OUTFIL FNAMES=CNTL,ENDREC=1,                             
  OUTREC=(C' OUTFIL FNAMES=OUT01,STARTREC=',               
          +1,ADD,(+0,MUL,+02),EDIT=(TTTTTTTT),             
          C',ENDREC=',                                     
          +1,MUL,+02,EDIT=(TTTTTTTT),                     
          C',',/,                                         
          C' HEADER1=(HDR),TRAILER1=(COUNT),REMOVECC',/,   
          C' OUTFIL FNAMES=OUT02,STARTREC=',               
          +1,ADD,(+1,MUL,+02),EDIT=(TTTTTTTT),             
          C',ENDREC=',                                     
          +2,MUL,+02,EDIT=(TTTTTTTT),                     
          C',',/,                                         
          C' HEADER1=(HDR),TRAILER1=(COUNT),REMOVECC',/,   
          C' OUTFIL FNAMES=OUT03,STARTREC=',               
          +1,ADD,(+2,MUL,+02),EDIT=(TTTTTTTT),             
          C',ENDREC=',                                     
          +3,MUL,+02,EDIT=(TTTTTTTT),                     
          C',',/,                                         
          C' HEADER1=(HDR),TRAILER1=(COUNT),REMOVECC',/,   
          C' OUTFIL FNAMES=OUT04,STARTREC=',               
          +1,ADD,(+3,MUL,+02),EDIT=(TTTTTTTT),             
          C',ENDREC=',                                     
          +4,MUL,+02,EDIT=(TTTTTTTT),                     
          C',',/,                                         
          C' HEADER1=(HDR),TRAILER1=(COUNT),REMOVECC',/,   
          80:X)                                           
/*                                                         
//STEP0200 EXEC PGM=SORT     
//SYSOUT   DD SYSOUT=*       
//SYMNAMES DD DSN=&H,DISP=SHR
//SORTIN   DD DSN=&R,DISP=SHR
//OUT01    DD SYSOUT=*       
//OUT02    DD SYSOUT=*       
//OUT03    DD SYSOUT=*       
//OUT04    DD SYSOUT=*       
//SYSIN    DD DSN=&T,DISP=SHR
//         DD *             
  SORT FIELDS=COPY           
//         DD DSN=&C,DISP=SHR
/*


This example splits the input file as 2 records each. So if you want to change the number then you need to change+nn to the desired number.ex if you wanted the split to 40 then change +nn to +40.

Code:

OUTFIL FNAMES=CNTL,ENDREC=1,   
  OUTREC=(C' OUTFIL FNAMES=OUT01,STARTREC=',               
          +1,ADD,(+0,MUL,+nn),EDIT=(TTTTTTTT),             
          C',ENDREC=',                                     
          +1,MUL,+nn,EDIT=(TTTTTTTT),                     
          C',',/,                                         
          C' HEADER1=(HDR),TRAILER1=(COUNT),REMOVECC',/,   
          C' OUTFIL FNAMES=OUT02,STARTREC=',               
          +1,ADD,(+1,MUL,+nn),EDIT=(TTTTTTTT),             
          C',ENDREC=',                                     
          +2,MUL,+nn,EDIT=(TTTTTTTT),                     
          C',',/,                                         
          C' HEADER1=(HDR),TRAILER1=(COUNT),REMOVECC',/,   
          C' OUTFIL FNAMES=OUT03,STARTREC=',               
          +1,ADD,(+2,MUL,+nn),EDIT=(TTTTTTTT),             
          C',ENDREC=',                                     
          +3,MUL,+nn,EDIT=(TTTTTTTT),                     
          C',',/,                                         
          C' HEADER1=(HDR),TRAILER1=(COUNT),REMOVECC',/,   
          C' OUTFIL FNAMES=OUT04,STARTREC=',               
          +1,ADD,(+3,MUL,+nn),EDIT=(TTTTTTTT),             
          C',ENDREC=',                                     
          +4,MUL,+nn,EDIT=(TTTTTTTT),                     
          C',',/,                                         
          C' HEADER1=(HDR),TRAILER1=(COUNT),REMOVECC',/,   
          80:X)                         


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
yrcreddy
Beginner


Joined: 28 Dec 2005
Posts: 27
Topics: 12

PostPosted: Thu Jul 20, 2006 12:46 am    Post subject: Reply with quote

Thank you very much kolusu
_________________
Thanks,
Ramachandra Reddy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group