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 

Multiple headers in SORT

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


Joined: 16 Jun 2008
Posts: 1
Topics: 1

PostPosted: Wed Feb 11, 2009 3:37 am    Post subject: Multiple headers in SORT Reply with quote

Hi Guys,

I am having 4 files as Input to SORT and all four of them contain a header and then detail records. it is possible that some times one of them may be empty. All the four files will have same headers.

I need to write to sortout to 2 different files based on some field criteria. But the problem I have is, I should have only one header in the output files.

How do I get this using the SORT.

Thanks,
Praveen
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 Feb 11, 2009 9:14 am    Post subject: Reply with quote

RAJATALL,

1. What is the LRECL/RECFM of the 4 files
2. How do you identify the header and the detail records?
3. What is the condition to split the input into 2 different files
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
RAJATALL
Beginner


Joined: 16 Jun 2008
Posts: 1
Topics: 1

PostPosted: Wed Feb 11, 2009 10:27 am    Post subject: Multiple headers in SORT Reply with quote

Hi Kolusu,

The files are FB files and having a LRECL of 100
Headers and Trailers are identified with '00' in the first 2 bytes
We check the 10th bye of the file and based on the values writing them to 2 different files.

Thanks,
Praveen
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 Feb 11, 2009 11:09 am    Post subject: Reply with quote

RAJATALL,

The following DFSORT JCL will give you the desired results. I assumed that you don't need the trailer.

we add a seqnum at the end of header and trailer record using an IFTHEN and we then using it on INCLUDE on OUTFIL to only pick the first header. The other OR condition is to split your file based on the value in pos 10.

Code:

//STEP0100 EXEC PGM=SORT 
//SYSOUT   DD SYSOUT=*   
//SORTIN   DD DSN=your 100 byte file1,DISP=SHR
//         DD DSN=your 100 byte file2,DISP=SHR
//         DD DSN=your 100 byte file3,DISP=SHR
//         DD DSN=your 100 byte file4,DISP=SHR
//OUT1     DD SYSOUT=*                         
//OUT2     DD SYSOUT=*                         
//SYSIN    DD *                               
  SORT FIELDS=COPY                             
 
  INREC IFTHEN=(WHEN=(1,2,CH,EQ,C'00'),       
  OVERLAY=(101:SEQNUM,2,ZD))                   
                                               
  OUTFIL FNAMES=OUT1,BUILD=(1,100),           
  INCLUDE=(101,2,ZD,EQ,1,OR,10,2,CH,EQ,C'AA') 
 
  OUTFIL FNAMES=OUT2,BUILD=(1,100),           
  INCLUDE=(101,2,ZD,EQ,1,OR,10,2,CH,EQ,C'BB') 
/*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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