Split Files with Headers and Trailers using DFSORT

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Locked
Veera
Moderator
Posts: 111
Joined: Wed Feb 22, 2006 2:59 pm

Split Files with Headers and Trailers using DFSORT

Post by Veera » Fri Nov 14, 2008 11:12 pm

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.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Sat Nov 15, 2008 1:17 am

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).
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Veera
Moderator
Posts: 111
Joined: Wed Feb 22, 2006 2:59 pm

Post by Veera » Sat Nov 15, 2008 3:20 am

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.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Sat Nov 15, 2008 4:29 am

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.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Locked

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others