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 

Extracting multiple detailed records

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


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Wed Jan 05, 2011 11:07 am    Post subject: Extracting multiple detailed records Reply with quote

My input file is having multiple country reports with multiple Header, multiple Detailed and multiple Trailer records for each country.
Record lenght is of 80 bytes fixed.
I need to split detailed records for each particular country into seperate output files.
There are different Headers record formats and different trailer record formats.
We can identify that a particular country by one of Header record is having Country Code at 10th position with 3 bytes length.
Then after few more Header records, Detailed records will start, which we can identify as for detailed records the first 5 bytes is numeric.
we need to extract all this numeric records into output file untill the first 5 bytes are spaces or equal to "Total"

Following is the sample input file:

Code:
XXXXXXXXXXXXX
YYYYYYYYYYYY
          11
zzzzzzzzzzzzz
11111
11222
11333
11444
Total
AAAAAAAAAAAAAA
BBBBBBBBBBBBBB
          22
ccccccccccccc
22111
22222
22333
22444

Total

My first output file should look like

Code:
11111
11222
11333
11444


And my second output file should look like

Code:
22111
22222
22333
22444


Please help me with DFSORT or ICETOOL how to achieve above results.
_________________
Thanks
Madhu Sudhan
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 Jan 05, 2011 11:26 am    Post subject: Reply with quote

psmadhusudhan,

Do you always have 2 groups or do you have variable number of output files? How do you handle variable groups? Are you going to predefine max output files ?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
psmadhusudhan
Beginner


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Wed Jan 05, 2011 7:16 pm    Post subject: Reply with quote

I have 3 groups in input file so I shall have 3 output files also.
Each seperate country detailed records should go to one seperate file.
And each country will repeat only once in the input file.
Max output files are three in this scenario as input countries as three.
_________________
Thanks
Madhu Sudhan
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Jan 05, 2011 7:50 pm    Post subject: Reply with quote

Assuming a 'Total' record is present after each group (regardless of whether or not a space record is present), you can use a DFSORT job like the following to do what you asked for:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//OUT1 DD DSN=...  output file1 (FB/80)
//OUT2 DD DSN=...  output file2 (FB/80)
//OUT3 DD DSN=...  output file3 (FB/80)
//SYSIN DD *
  OPTION COPY
  INCLUDE COND=(1,5,FS,EQ,NUM,OR,1,5,CH,EQ,C'Total')
  INREC IFTHEN=(WHEN=GROUP,END=(1,5,CH,EQ,C'Total'),
    PUSH=(81:ID=1)),
   IFTHEN=(WHEN=(1,5,CH,EQ,C'Total'),OVERLAY=(81:X))
  OUTFIL FNAMES=OUT1,INCLUDE=(81,1,ZD,EQ,1),BUILD=(1,80)
  OUTFIL FNAMES=OUT2,INCLUDE=(81,1,ZD,EQ,2),BUILD=(1,80)
  OUTFIL FNAMES=OUT3,INCLUDE=(81,1,ZD,EQ,3),BUILD=(1,80)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
psmadhusudhan
Beginner


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Wed Jan 05, 2011 9:27 pm    Post subject: Reply with quote

Sorry I have some corrections in my input file structure
1. My input file is variable file with RECL 133
2. I might have more than 3 country groups in input file, where as I need to extract country codes of 11,22,33 onlyt to rspective output files.
3. There might space record in between last numeric record and record with "Total"
_________________
Thanks
Madhu Sudhan
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: Thu Jan 06, 2011 11:46 am    Post subject: Reply with quote

psmadhusudhan,

Use the following DFSORT JCL

Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD DSN=Your input vb 133 byte file,DISP=SHR
//OUT1     DD SYSOUT=*                                   
//OUT2     DD SYSOUT=*                                   
//OUT3     DD SYSOUT=*                                   
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                       
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,3X,5)),             
  IFTHEN=(WHEN=GROUP,BEGIN=(17,3,SS,EQ,C'11 ,22 ,33 '), 
  END=(8,5,CH,EQ,C'TOTAL'),PUSH=(5:17,3))               
                                                         
  OUTFIL FNAMES=OUT1,BUILD=(1,4,8),                     
  INCLUDE=(8,5,FS,EQ,NUM,AND,5,3,CH,EQ,C'11 ')           
                                                         
  OUTFIL FNAMES=OUT2,BUILD=(1,4,8),                     
  INCLUDE=(8,5,FS,EQ,NUM,AND,5,3,CH,EQ,C'22 ')           
                                                         
  OUTFIL FNAMES=OUT3,BUILD=(1,4,8),                     
  INCLUDE=(8,5,FS,EQ,NUM,AND,5,3,CH,EQ,C'33 ')           
/*

_________________
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