Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Splitting a file dynamically

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Splitting a file dynamically
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed May 02, 2012 7:06 pm    Post subject: Reply to: Splitting a file dynamically
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: 578
Location: USA

PostPosted: Wed May 02, 2012 9:45 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 3 Thu Jul 27, 2017 9:16 pm
No new posts Extra character appears in file when ... Balu5491 All Other Mainframe Topics 1 Wed Jul 26, 2017 2:39 pm
No new posts SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us