IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Have to split the file based on the field


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
advith001

New User


Joined: 16 Mar 2005
Posts: 23

PostPosted: Tue Jun 03, 2008 4:23 pm
Reply with quote

Hi, I required sorting a seq file based on first 17chars and split based on the first 3 chars and write them each into separate files. Not sure how many files might require.

Example..
CTL2 is of 3 char, Account number is of 14 chars
13122222222222222
13122222222222221
13122222222222223
14433333333333321
14433333333333315
14433333333333310
00155555555555529
00155555555555120

expected output is:

00155555555555529
00155555555555120
13122222222222221
13122222222222222
13122222222222223
14433333333333310
14433333333333315
14433333333333321

If this is a repeated question and I can find in threads, please let me know location where can I find..

Anna.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Jun 03, 2008 4:36 pm
Reply with quote

Well, given that the three digit field on which to split gives you a possible 1,000 output files, then using SORT may not be viable in one step. Also the limitation of 255 DD statements doesn't help.

You could sort the records into the order that you require them and then use something like REXX to use dynamic allocation for the split output datasets, only having one at a time allocated.
Back to top
View user's profile Send private message
advith001

New User


Joined: 16 Mar 2005
Posts: 23

PostPosted: Tue Jun 03, 2008 4:46 pm
Reply with quote

I noticed the maximum number of files I would require creating is 30 (for 30 diff states).

Hi Expat, can you plz let me know how REXX can be useful and if possible the commands/code... I don't know REXX cmds..

Thanks!
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Jun 03, 2008 5:21 pm
Reply with quote

I suppose that you could create the 30+ files each time and use sort card along the lines of ..... I don't think that there is a restriction on the number of output files, and I certainly have used 9 or so in the past

Code:

  SORT    FIELDS=(1,17,A),FORMAT=CH       
  OUTFIL  FILES=1,INCLUDE=(1,3,CH,EQ,C'001')
  OUTFIL  FILES=2,INCLUDE=(1,3,CH,EQ,C'002')

  etc etc

  OUTFIL  FILES=30,INCLUDE(1,3,CH,EQ,C'030')
Back to top
View user's profile Send private message
advith001

New User


Joined: 16 Mar 2005
Posts: 23

PostPosted: Tue Jun 03, 2008 5:35 pm
Reply with quote

Hi Expat, thanks for your suggestion.. but is there any option to create a new GDG version for each CTL2( first 3 chars) value change?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Jun 03, 2008 5:58 pm
Reply with quote

advith001 wrote:
Hi Expat, thanks for your suggestion.. but is there any option to create a new GDG version for each CTL2( first 3 chars) value change?


Do you want the same base name but different GENERATION for each output? That you can handle in the JCL.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Jun 03, 2008 6:12 pm
Reply with quote

Or do you want a different GDG base for each possible output ?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Jun 03, 2008 6:30 pm
Reply with quote

Either way it is just a matter of setting up the jcl the way you want it.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Jun 03, 2008 7:37 pm
Reply with quote

Consultancy available at competitive rates icon_biggrin.gif
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jun 03, 2008 10:20 pm
Reply with quote

advith001,

The following DFSORT/ICETOOL JCL will create a dynamic JCL on the fly and submit it via Intrdr which will split the records based on the first 3 characters. However remember that the no: of output files you can open at a time depends on the TIOT limit.

Code:

//STEP0100 EXEC PGM=ICEMAN                                       
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD DSN=your input file,DISP=SHR                       
//C1       DD DSN=&&C1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)       
//D1       DD DSN=&&D1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)       
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)       
//SYSIN    DD *                                                 
  SORT FIELDS=(1,3,CH,A)                                         
  OUTFIL FNAMES=C1,REMOVECC,NODETAIL,                           
  HEADER1=('//CTL1CNTL DD *',/,                                 
           '  SORT FIELDS=(1,17,CH,A)',80:X),                   
  SECTIONS=(1,3,                                                 
  TRAILER3=('  OUTFIL FNAMES=OUT',1,3,C',INCLUDE=(1,3,CH,EQ,C', 
            '''',1,3,'''',')',80:X))                             
  OUTFIL FNAMES=T1,REMOVECC,NODETAIL,                           
  TRAILER1=('  SORT FROM(IN) USING(CTL1)',80:X)                 
  OUTFIL FNAMES=D1,REMOVECC,NODETAIL,                           
  SECTIONS=(1,3,                                                 
  TRAILER3=(C'//OUT',1,3,4X,C'DD DSN=OUTPUT.FILE',1,3,/,         
            C'//',12X,C'DISP=(NEW,CATLG,DELETE),',/,             
            C'//',12X,C'UNIT=SYSDA,',/,                         
            C'//',12X,C'SPACE=(CYL,(X,Y),RLSE)',/,               
            C'/*',80:X))                                         
/*
//STEP0200 EXEC  PGM=ICEMAN                 
//SYSOUT   DD SYSOUT=*                       
//SYSIN    DD *                             
   OPTION COPY                               
/*                                           
//SORTOUT  DD SYSOUT=*                       
//SORTIN   DD DATA,DLM=$$                   
//TIDXXXXA JOB 'COPY',                       
//             CLASS=A,                     
//             MSGCLASS=Y,                   
//             MSGLEVEL=(1,1),               
//             NOTIFY=TID                   
//*                                         
//STEP0100 EXEC  PGM=ICETOOL                 
//TOOLMSG  DD SYSOUT=*                       
//DFSMSG   DD SYSOUT=*                       
//IN       DD DSN=YOUR INPUT FILE,DISP=SHR   
//TOOLIN   DD *                             
$$                                           
//         DD DSN=&T1,DISP=(OLD,PASS)       
//         DD DSN=&D1,DISP=(OLD,PASS)       
//         DD DSN=&C1,DISP=(OLD,PASS)
/*


Check the output of step0200 and if it had generated the correct JCL , change the sortout statement in step0200 to the following and submit the job

Code:

//SORTOUT  DD SYSOUT=(*,INTRDR)               


The output from the above job would be like this . so change the space parameters and names of the output files to suit your needs

Code:

//TIDXXXXA JOB 'COPY',                           
//             CLASS=A,                           
//             MSGCLASS=Y,                       
//             MSGLEVEL=(1,1),                   
//             NOTIFY=TID                         
//*                                               
//STEP0100 EXEC  PGM=ICETOOL                     
//TOOLMSG  DD SYSOUT=*                           
//DFSMSG   DD SYSOUT=*                           
//IN       DD DSN=YOUR INPUT FILE,DISP=SHR       
//TOOLIN   DD *                                   
  SORT FROM(IN) USING(CTL1)                       
//OUT001    DD DSN=OUTPUT.FILE001                 
//            DISP=(NEW,CATLG,DELETE),           
//            UNIT=SYSDA,                         
//            SPACE=(CYL,(X,Y),RLSE)             
/*                                               
//OUT131    DD DSN=OUTPUT.FILE131                 
//            DISP=(NEW,CATLG,DELETE),           
//            UNIT=SYSDA,                         
//            SPACE=(CYL,(X,Y),RLSE)             
/*                                               
//OUT144    DD DSN=OUTPUT.FILE144                 
//            DISP=(NEW,CATLG,DELETE),           
//            UNIT=SYSDA,                         
//            SPACE=(CYL,(X,Y),RLSE)             
/*                                               
//CTL1CNTL DD *                                   
  SORT FIELDS=(1,17,CH,A)                         
  OUTFIL FNAMES=OUT001,INCLUDE=(1,3,CH,EQ,C'001')
  OUTFIL FNAMES=OUT131,INCLUDE=(1,3,CH,EQ,C'131')
  OUTFIL FNAMES=OUT144,INCLUDE=(1,3,CH,EQ,C'144')


Hope this helps...

Cheers
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top