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

Splitting a file dynamically


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

New User


Joined: 27 Jun 2006
Posts: 60

PostPosted: Wed May 02, 2012 6:50 pm
Reply with quote

Hi,

I have the following requirement: -

A flat file of fixed length 80 bytes has a numeric value from 01 to 99 in the first two positions. Based on this value, we need to split this file into 99 different files. For example, if the Value is 01, it should write to FILE01, if it has a Value 02, it should write to FILE02 and so on.

I know, I can use OUTFIL FNAMES and INCLUDE COND parameters to achieve this. But in doing so I need to write 99 such statements.

Can this be done in any better way using DFSORT?

Thanks,
Indrajit
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed May 02, 2012 7:06 pm
Reply with quote

What problems do you feel you have doing it that way?
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Wed May 02, 2012 9:45 pm
Reply with quote

Indrajit_57,
If you are leaning towards a solution to dynamically build sort control statements then you can use sample job as below which requires an extra input file with sequence number from 01-99 (or any number you want).

Below is an example for 4 files only but you will get the idea. Alternatively, you can create a sequence number file using SORT or other utility as well. You can also create entire JCL dynamically (if you don't want to code 99 FILE01-FILE99 dd statements) and submit through INTRDR.

Code:
//STEP0001 EXEC PGM=SORT                                               
//SORTIN   DD  *                                                       
01                                                                     
02                                                                     
03                                                                     
04                                                                     
//SORTOUT  DD DSN=&&SRTCRD,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)   
//SYSIN DD *                                                           
 OPTION COPY                                                           
 OUTFIL REMOVECC,                                                       
        HEADER1=(2:'OPTION COPY'),                                     
        BUILD=(2:C'OUTFIL FNAMES=FILE',1,2,C',',80:X,/,                 
               2:C'INCLUDE=(1,2,ZD,EQ,',1,2,C')')                       
/*                                                                     
//SYSOUT DD SYSOUT=*                                                   
//*                                                                     
//STEP0002 EXEC PGM=SORT                                               
//SORTIN   DD  *                                                       
01SQLCODE01A                                                           
02SQLCODE02B                                                           
02SQLCODE02C                                                           
03SQLCODE03D                                                           
03SQLCODE03E                                                           
03SQLCODE03F                                                           
04SQLCODE04G                                                           
04SQLCODE04H                                                           
04SQLCODE04I                                                           
04SQLCODE04J                                                           
//FILE01   DD  SYSOUT=*                                                 
//FILE02   DD  SYSOUT=*                                                 
//FILE03   DD  SYSOUT=*                                                 
//FILE04   DD  SYSOUT=*                                                 
//SORTOUT  DD  SYSOUT=*                                                 
//SYSIN    DD DSN=&&SRTCRD,DISP=SHR                                     
//SYSOUT DD SYSOUT=*                                                   
//*                                                                     

Thanks,
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed May 02, 2012 10:15 pm
Reply with quote

If you have a problem coding the OUTFIL/INCLUDE statements you can generate them like shown below.

Code:

//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                         
DUMMY RECORD                                           
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                     
  OUTFIL REPEAT=100,IFOUTLEN=80,                       
  IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,3,ZD,START=0)), 
  IFTHEN=(WHEN=(81,3,ZD,EQ,0),BUILD=(3:C'OPTION COPY')),
  IFTHEN=(WHEN=NONE,                                   
  BUILD=(3:C'OUTFIL FNAMES=OUT',SEQNUM,2,ZD,           
           C',INCLUDE=(1,2,ZD,EQ,',SEQNUM,2,ZD,C')'))   
//*
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
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
Search our Forums:

Back to Top