Page 1 of 1

Split Files with Headers and Trailers using DFSORT

Posted: Fri Nov 14, 2008 11:12 pm
by Veera

Code: Select all

//JS010    EXEC PGM=ICETOOL                    
//TOOLMSG   DD SYSOUT=*                        
//DFSMSG    DD SYSOUT=*                        
//*                                            
//IN     DD *                                  
HEAD1                                          
11111                                          
22222                                          
33333                                          
44444                                          
TAIL1                                          
//*                                            
//OUT1   DD DSN=ABC.OUT1,                  
//            DISP=(MOD,CATLG,DELETE),         
//            UNIT=SYSDA,                      
//            SPACE=(CYL,(1,1),RLSE),          
//            DCB=(RECFM=FB,LRECL=5,BLKSIZE=0) 
//OUT2   DD DSN=ABC.OUT2,                  
//            DISP=(MOD,CATLG,DELETE),         
//            UNIT=SYSDA,                          
//            SPACE=(CYL,(1,1),RLSE),              
//            DCB=(RECFM=FB,LRECL=5,BLKSIZE=0)     
//LIST1  DD SYSOUT=*                               
//TOOLIN DD *                                      
  COPY FROM(IN) USING(CTL1)                        
  COPY FROM(IN) USING(CTL2)                        
  COPY FROM(IN) USING(CTL3)                        
//CTL1CNTL DD *                                    
  OPTION STOPAFT=1                                 
  OUTFIL FNAMES=(OUT1,OUT2)                        
//CTL2CNTL DD *                                    
  OPTION SKIPREC=1,STOPAFT=4                       
  OUTFIL FNAMES=(OUT1,OUT2),SPLIT                  
//CTL3CNTL DD *                                    
  OPTION SKIPREC=5                                 
  OUTFIL FNAMES=(OUT1,OUT2)          


Note : The order of records will change if we use SPLIT function. If the order matters then we should go by STARTREC,ENDREC.


Code: Select all

SORT FIELDS=COPY                              
OUTFIL FILES=01,STARTREC=AAAA,ENDREC=BBBB 
OUTFIL FILES=02,STARTREC=BBBB+1,ENDREC=CCCC
Frank -> I was trying to code a generic utility using SPLIT so that it can be used irrespective of count of records in the input file. My bad SUBSET is not working in my shop.May be i need to ask the system maintenance team to install latest updates from DFSORT.

Code: Select all


//TOOLIN DD *                                      
  COPY FROM(IN) USING(CTL1)                        
  COPY FROM(IN) USING(CTL2)                        
  COPY FROM(IN) USING(CTL3)                        
//CTL1CNTL DD *                                    
  OPTION STOPAFT=1                                 
  OUTFIL FNAMES=(OUT1,OUT2)         -> This copies the headers into both files.                    
//CTL2CNTL DD *                                    
  OPTION SKIPREC=1                       
  OUTFIL FNAMES=(OUT1,OUT2),SPLIT   -> This splits the records evenly, 
                                       (But we need to avoid last record being SPLIT here)
After this i was wondering how to just copy the last record of the i/p file wihtout using the SUBSET and if we donot know the count of records in the I/P file.

Or generic way of doing using any means is fine.

Thanks,
Veera.

Posted: Sat Nov 15, 2008 1:17 am
by Frank Yaeger
I don't really understand what you're trying to accomplish here or what question you're asking exactly.

If you want to use SUBSET, have your System Programmer install z/OS DFSORT V1R5 PTF UK90013 (July, 2008).

Posted: Sat Nov 15, 2008 3:20 am
by Veera
Ok Sorry for the confusion Frank.

Firstly, I was trying to answer the question which sowjanya has asked in JCL forum.

Second: The question I wanted to ask you is how to code a generic utility which will split the files into exactly 2(half) files. Both the files also should have the header and trailer records in it.

Pre-Condition is we do not know the count of records in the given input file.

Third: Since we did not install z/OS DFSORT V1R5 PTF UK90013 SUBSET is not working. So is there a way to achieve the above requirement the Split of the file into 2 equal halves without using SUBSET function.

Am I clear now, if I am still ambiguous I will give an example?

I should have made this into 2 separate threads.

Thanks
Veera.

Posted: Sat Nov 15, 2008 4:29 am
by Frank Yaeger
Actually, you should have posted your "solution" to the question from the person who was using Syncsort in that JCL thread. Please do so. (I said I don't answer Syncsort questions - I didn't say you can't.)

I am going to lock this thread.

Please start a new thread for your new question and give an example of your input records and expected output records. Also, give the RECFM and LRECL of the file.