Page 1 of 1

File has to be split into four files

PostPosted: Thu Aug 30, 2007 5:42 pm
by kamal
A files has records :
****
1
2
3
****
3
4
****
5
****
6
7
8


This file has to be split into four files




Whenever '****' is encountered at POS 1:4 split the file and put all records after last '****' into last file.

I know how to do this with FILE-AID ...But I want to use SORT in place...
Please help.

Re: File has to be split into four files

PostPosted: Fri Aug 31, 2007 3:53 am
by Frank Yaeger
Here's a DFSORT job that will do what you asked for. I assumed that your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

//S1    EXEC  PGM=ICEMAN
//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)
//OUT4 DD DSN=...    output file4 (FB/80)
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,2,ZD)),               
        IFTHEN=(WHEN=(1,4,CH,EQ,C'****'),                           
                OVERLAY=(81:SEQNUM,2,ZD)),                         
        IFTHEN=(WHEN=NONE,                                         
                OVERLAY=(83:SEQNUM,2,ZD,                           
                         81:81,2,ZD,SUB,83,2,ZD,M11,LENGTH=2))     
  OUTFIL FNAMES=OUT1,                                               
    INCLUDE=(1,4,CH,NE,C'****',AND,81,2,ZD,EQ,1),                   
    BUILD=(1,80)                                                   
  OUTFIL FNAMES=OUT2,                                               
    INCLUDE=(1,4,CH,NE,C'****',AND,81,2,ZD,EQ,2),                   
    BUILD=(1,80)                                                   
  OUTFIL FNAMES=OUT3,                                               
    INCLUDE=(1,4,CH,NE,C'****',AND,81,2,ZD,EQ,3),                   
    BUILD=(1,80)                                                   
  OUTFIL FNAMES=OUT4,                                               
    INCLUDE=(1,4,CH,NE,C'****',AND,81,2,ZD,EQ,4),                   
    BUILD=(1,80)                                                   
/*