DFSORT to Split the records according to the header
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> Utilities

#1: DFSORT to Split the records according to the header Author: Magesh_J PostPosted: Mon Sep 22, 2014 12:36 pm
    —
Hi,

I have below input file, with 3 report DF, EE, and GG.

I need to split the input files into three files based on the group header.

Code:

1DF  AABB     
 HEAD1         
 HEAD2         
  ZYKA DATA   
  ZYKA DATA   
1DF  AABB     
 HEAD1         
 HEAD2         
  YYAA DATA   
  ZYYA DATA   
1EE  CCDD     
 HEAD1         
 HEAD2         
 ZYZZ DATA     
 XYZZ DATA     
1DF SSDD       
 HEAD1         
 HEAD2         
 ZYYA DATA     
 ZYYA DATA     
1EE  FFGG     
 HEAD1         
 HEAD2         
 GGYY DATA     
 HHYY DATA     
1GG  FFHH     
 HEAD1         
 HEAD2         
   AAYY DATA   
   AACC DATA   


Output should be

DF-REport File1
Code:

1DF  AABB   
 HEAD1       
 HEAD2       
  ZYKA DATA 
  ZYKA DATA 
1DF  AABB   
 HEAD1       
 HEAD2       
  YYAA DATA 
  ZYYA DATA 
1DF SSDD   
 HEAD1     
 HEAD2     
 ZYYA DATA 
 ZYYA DATA 


EE-Report File2
Code:

1EE  FFGG   
 HEAD1       
 HEAD2       
 GGYY DATA   
 HHYY DATA   


GG-Report - File3
Code:

HEAD1       
HEAD2       
  AAYY DATA
  AACC DATA


Tried Code :
Code:

//SORTOUT DD SYSOUT=*                                               
//EE  DD SYSOUT=*                                                   
//DF  DD SYSOUT=*                                                   
//GG  DD SYSOUT=*                                                   
//SYSIN DD *                                                       
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'1'),PUSH(81:1,3))     
  OPTION COPY                                                       
  OUTFIL FNAMES=DF,INCLUDE(81,3,CH,EQ,C'1DF'),BUILD=(1,80)         
  OUTFIL FNAMES=EE,INCLUDE(81,3,CH,EQ,C'1EE'),BUILD=(1,80)         
  OUTFIL FNAMES=GG,INCLUDE(81,3,CH,EQ,C'1GG'),BUILD=(1,80)         
/*                                                                 


Sortout is used for backup copy.
Please advice if i am missing something, or any other best way to achive this ?

Thanks
Magesh

#2:  Author: kolusuLocation: San Jose PostPosted: Mon Sep 22, 2014 12:58 pm
    —
Magesh_J wrote:
Please advice if i am missing something, or any other best way to achive this ?


Magesh_J,

why do you need to validate 3 bytes? 2 bytes is more than enough. Just push the contents from byte 2 for a length of 2 bytes. Use the following control cards

Code:

//SORTOUT DD SYSOUT=*                                               
//EE  DD SYSOUT=*                                                   
//DF  DD SYSOUT=*                                                   
//GG  DD SYSOUT=*                                                   
//SYSIN DD *                                                       
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'1'),PUSH(81:2,2))     

  OUTFIL FNAMES=DF,INCLUDE(81,2,CH,EQ,C'DF'),BUILD=(1,80)         
  OUTFIL FNAMES=EE,INCLUDE(81,2,CH,EQ,C'EE'),BUILD=(1,80)         
  OUTFIL FNAMES=GG,INCLUDE(81,2,CH,EQ,C'GG'),BUILD=(1,80)         
/*



Magesh_J wrote:
Sortout is used for backup copy.


Notice that SORTOUT will be 82 bytes as you haven't chopped off the additional bytes that you pushed. Ideally I would add another OUTFIL File with SAVE to have all the records that do not fit the include conditions.
Code:

//OTHER DD SYSOUT=*                                               
//EE  DD SYSOUT=*                                                   
//DF  DD SYSOUT=*                                                   
//GG  DD SYSOUT=*                                                   
//SYSIN DD *                                                       
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'1'),PUSH(81:2,2))     

  OUTFIL FNAMES=DF,INCLUDE(81,2,CH,EQ,C'DF'),BUILD=(1,80)         
  OUTFIL FNAMES=EE,INCLUDE(81,2,CH,EQ,C'EE'),BUILD=(1,80)         
  OUTFIL FNAMES=GG,INCLUDE(81,2,CH,EQ,C'GG'),BUILD=(1,80)         
  OUTFIL FNAMES=OTHER,SAVE,BUILD=(1,80)         
/*

#3:  Author: William Collins PostPosted: Mon Sep 22, 2014 2:31 pm
    —
Magesh_J,

If your required output for GG is as stated, you'll need a little something extra. Probably a typo?

#4:  Author: Magesh_J PostPosted: Tue Sep 23, 2014 6:02 am
    —
Thank you very much Kolusu

#5:  Author: Magesh_J PostPosted: Tue Sep 23, 2014 10:50 am
    —
Yes William, Its a typo...

Missed it.

Thanks
Magesh



MVSFORUMS.com -> Utilities


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group