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 

Split Files

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


Joined: 26 Dec 2002
Posts: 12
Topics: 3

PostPosted: Fri Apr 23, 2004 5:30 pm    Post subject: Split Files Reply with quote

Is there a way to achieve the following in sort
Input Records:
1
1
1
2
2
3
3
3
3
3

Output Record of File 1
1
1
1

Output Record of File 2
2
2

Output Record of File 3
3
3
3
3
3

The file may not always have these records the idea being splitting the files based on similar records.
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: Fri Apr 23, 2004 6:20 pm    Post subject: Reply with quote

It's not clear what you're really asking for.

Do you mean that every time the key changes, you want to write to another output data set? If the key changes 1000 times, do you want 1000 output data sets? What is the actual maximum number of unique keys you can have? Are you going to supply a DD statement for each possible output file, or do you want to dynamically allocate the output files as needed, or ?
_________________
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
abhikush
Beginner


Joined: 26 Dec 2002
Posts: 12
Topics: 3

PostPosted: Fri Apr 23, 2004 6:35 pm    Post subject: Reply with quote

Yes that is the idea. But what I am planning to do is split the file based on a key and if the keys are more than certain number say 15 then I will create 15 + 1 file. i.e. 15 files based on the key and then 1 file with the remaining keys.

I can then feed the new file created back to the same sort card and continue.
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: Sat Apr 24, 2004 11:31 am    Post subject: Reply with quote

Ok, let's assume your key is in positions 1-2, and that you will supply the 16 output DD statements needed. Here's a DFSORT job that will do what you want:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file
//CTL2CNTL DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
// DD *
  OUTFIL FNAMES=OUT16,SAVE
//OUT01 DD DSN=... output file 1
...
//OUT16 DD DSN=... output file 16
//TOOLIN DD *
* For each of the first 15 unique keys, generate a
* control statement like this:
*  OUTFIL FNAMES=OUTnn,INCLUDE=(1,2,CH,EQ,C'xx')
  SELECT FROM(IN) TO(CTL2CNTL) ON(1,2,CH) FIRST USING(CTL1)
* Use the generated control statements plus
*  OUTFIL FNAMES=OUT16,SAVE
* to split the input records to OUT01-OUT16.
  COPY FROM(IN) USING(CTL2)
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=CTL2CNTL,REMOVECC,ENDREC=15,
    OUTREC=(C' OUTFIL FNAMES=OUT',SEQNUM,2,ZD,
     C',INCLUDE=(1,2,CH,EQ,C''',1,2,C''')',80:X)
/*


If you wanted to get fancier, you could generate the OUTnn DD statements instead of hardcoding them and submit the entire job to the internal reader.
_________________
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
abhikush
Beginner


Joined: 26 Dec 2002
Posts: 12
Topics: 3

PostPosted: Sun Apr 25, 2004 9:25 am    Post subject: Reply with quote

Thanks Frank.

I will try it out.
Back to top
View user's profile Send private message
vishalknps
Beginner


Joined: 16 May 2004
Posts: 1
Topics: 0

PostPosted: Sun May 16, 2004 5:20 am    Post subject: Reply with quote

Quote:

Hi,

I want to split the input file based on the particular field(rebate period). If the number of the rebate period is 6, means i have to move corresponding records to 6 files. The problem is i dont know the number of rebate periods in the file before processing.

Is it possible trhru JCL or COBOL
The firdt 2 bytes inticates the type of the record whether HD, TR & UD.
record length is 400 for all HD TR & UD
My input file looks like. Say 3 distinct rebate periods.

HD<-------------------------------some data-------------------->20000401
UD<--------------------------some difrent data------------------------------>
.
.
TR<--------------------------------some data--------------------->20000401
HD<----------------------------------------------------------------->20040101
UD
.
TR<----------------------------------------------------------------->20040101
HD<------------------------------------------------------------------>20020101
UD
.
.
TR--------------------------------------------------------------------20020101

The out put files look like
out1

HD<----------------------------------------------------------------->20040101
UD
.
TR<----------------------------------------------------------------->20040101
out 2
HD<------------------------------------------------------------------>20020101
UD
.
.
TR--------------------------------------------------------------------20020101
out 3
like
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Sun May 16, 2004 8:01 am    Post subject: Reply with quote

Vishal,

The following DFSORT/ICETOOL JCl will give you the desired results. If you have syncsort at your shop then use synctool as pgm in step0100.The first step reads the input dataset and creates dynamic control cards and also output files. The step0200 then submits another job to intrdr which actually splits the file into 'n' number of output files. You need to put your tid or the highlevel qualifier in place of USERID

For your understanding as to how the job works, remove the statement in step0200
Code:

//SORTOUT  DD SYSOUT=(*,INTRDR)       


and replace it with
Code:

//SORTOUT  DD SYSOUT=*


Now check your SYSOUT and make sure that the jcl looks right. If you are satisfied that the jcl is ok then code the INTRDR statement.

Code:

//STEP0100 EXEC PGM=ICETOOL     
//TOOLMSG   DD SYSOUT=*         
//DFSMSG    DD SYSOUT=*         
//IN        DD DSN=YOUR INPUT FILE,
//             DISP=SHR
//T1       DD  DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T2       DD  DSN=&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//CON      DD  DSN=&T1,DISP=OLD,VOL=REF=*.T1               
//         DD  DSN=&T2,DISP=OLD,VOL=REF=*.T2               
//C1       DD  DSN=&C1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//D1       DD  DSN=&D1,DISP=(,PASS),SPACE=(CYL,(2,2),RLSE)
//TOOLIN   DD  *                                         
  COPY FROM(IN)  USING(CTL1)                             
  SORT FROM(CON) USING(CTL2)                             
//CTL1CNTL DD  *                                         
  INREC FIELDS=(1,2,SEQNUM,8,ZD)                               
  OUTFIL FNAMES=T1,INCLUDE=(1,2,CH,EQ,C'HD'),                 
  OUTREC=(C' OUTFIL FNAMES=OUT',SEQNUM,5,ZD,                   
          C',STARTREC=',3,8,C',ENDREC=',8Z,80:X,SEQNUM,8,ZD)   
  OUTFIL FNAMES=T2,INCLUDE=(1,2,CH,EQ,C'TR'),                 
  OUTREC=(49X,3,8,80:X,SEQNUM,8,ZD)                           
  OUTFIL FNAMES=D1,INCLUDE=(1,2,CH,EQ,C'HD'),                 
  OUTREC=(C'//OUT',SEQNUM,5,ZD,C' DD DSN=USERID.OUT',         
          SEQNUM,5,ZD,C',',/,                                 
          C'//',12X,C'DISP=(NEW,CATLG,DELETE),',/,             
          C'//',12X,C'UNIT=SYSDA,',/,                         
          C'//',12X,C'SPACE=(CYL,(2,2),RLSE)',80:X)           
//CTL2CNTL DD  *                       
   OPTION EQUALS
   SORT FIELDS=(81,8,CH,A)             
   SUM FIELDS=(50,8,BI)               
   OUTFIL FNAMES=C1,OUTREC=(1,80)     
//*
//STEP0200 EXEC  PGM=SORT             
//SYSOUT   DD SYSOUT=*                 
//SYSIN    DD *                       
  SORT FIELDS=COPY                     
//SORTOUT  DD SYSOUT=(*,INTRDR)       
//SORTIN   DD DATA,DLM=$$             
//USERIDA  JOB 'SPLIT COPY',                 
//             CLASS=A,               
//             MSGCLASS=Y,             
//             MSGLEVEL=(1,1),         
//             NOTIFY=&SYSUID         
//*                       
//STEP0100 EXEC  PGM=SORT   
//SYSOUT   DD SYSOUT=*       
//SORTIN   DD DSN=YOUR INPUT FILE,
//            DISP=SHR
//SYSIN    DD *                         
  SORT FIELDS=COPY                     
$$                                     
//         DD DSN=&C1,DISP=(OLD,PASS)   
//         DD DSN=&D1,DISP=(OLD,PASS)   
//*



Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Sun May 16, 2004 10:29 am    Post subject: Reply with quote

Clever solution, Kolusu. I added OPTION EQUALS to CTL2CNTL to make sure the records are sorted and summed in the correct order.

With DFSORT/ICETOOL, we can use SPLICE instead of the binary zero sum trick by replacing STEP0100 with the following:

Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG   DD SYSOUT=*
//DFSMSG    DD SYSOUT=*
//IN        DD DSN=YOUR INPUT FILE,
//             DISP=SHR
//T1       DD  DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T2       DD  DSN=&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//CON      DD  DSN=&T1,DISP=OLD,VOL=REF=*.T1
//         DD  DSN=&T2,DISP=OLD,VOL=REF=*.T2
//C1       DD  DSN=&C1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//D1       DD  DSN=&D1,DISP=(,PASS),SPACE=(CYL,(2,2),RLSE)
//TOOLIN   DD  *
  COPY FROM(IN)  USING(CTL1)
  SPLICE FROM(CON) TO(C1) ON(81,8,CH) WITH(50,8) USING(CTL2)
/*
//CTL1CNTL DD  *
  INREC FIELDS=(1,2,SEQNUM,8,ZD)
  OUTFIL FNAMES=T1,INCLUDE=(1,2,CH,EQ,C'HD'),
  OUTREC=(C' OUTFIL FNAMES=OUT',SEQNUM,5,ZD,
          C',STARTREC=',3,8,C',ENDREC=',81:SEQNUM,8,ZD)
  OUTFIL FNAMES=T2,INCLUDE=(1,2,CH,EQ,C'TR'),
  OUTREC=(50:3,8,81:SEQNUM,8,ZD)
  OUTFIL FNAMES=D1,INCLUDE=(1,2,CH,EQ,C'HD'),
  OUTREC=(C'//OUT',SEQNUM,5,ZD,C' DD DSN=&&O',
          SEQNUM,5,ZD,C',',/,
          C'//',12X,C'DISP=(NEW,CATLG,DELETE),',/,
          C'//',12X,C'UNIT=SYSDA,',/,
          C'//',12X,C'SPACE=(CYL,(2,2),RLSE)',80:X)
/*
//CTL2CNTL DD  *
   OUTFIL FNAMES=C1,OUTREC=(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
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Sun May 16, 2004 12:08 pm    Post subject: Reply with quote

Frank,

Thanks for adding the option Equals parm. I always forget that because it is the installed default parm for our site. And I love to play with splice but unfortunately I can't. So I still have to go with good old binary zero sum trick Sad

Kolusu
_________________
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