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

Splitting an input file based on key value


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

New User


Joined: 11 Sep 2009
Posts: 3
Location: Chennai, India

PostPosted: Fri Sep 11, 2009 2:38 pm
Reply with quote

Hi All,
We have a requirement to split one input files into 70 output files (70 number is fixed).
Conditions -
1. Number of records in each file is calculated based on nbr of records from input file.
2. Record can be written into the next file only when it is a new key

Eg: if Input file has 700 rec.
Approx Number of records per file will be 10
if first 12 records belong to the same key, and second key starts with 13th record onwards,
then my first file should have 12 records and starting from 13th record it should be written in 2nd file.

Can this be done using any of the SORT methods?
Back to top
View user's profile Send private message
Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Fri Sep 11, 2009 2:46 pm
Reply with quote

Hi,
Which sort product in present at your shop ?
DF Sort or Syncsort?
Back to top
View user's profile Send private message
Saikumaar Nagarajan

New User


Joined: 11 Sep 2009
Posts: 3
Location: Chennai, India

PostPosted: Fri Sep 11, 2009 2:49 pm
Reply with quote

I'd be using DFSort
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Sep 11, 2009 8:14 pm
Reply with quote

Hello,

What if the first 100 records have the same key?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Sep 11, 2009 9:35 pm
Reply with quote

This is difficult (though not impossible) with DFSORT/ICETOOL.

I posted a solution previously for something similar at:

ibmmainframes.com//viewtopic.php?t=18842

but I don't have time to adjust it for your situation.

You would be better off writing a program to do this.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Sat Sep 12, 2009 6:04 am
Reply with quote

Saikumaar Nagarajan wrote:
We have a requirement to split one input files into 70 output files (70 number is fixed).
Conditions -
1. Number of records in each file is calculated based on nbr of records from input file.
2. Record can be written into the next file only when it is a new key

Eg: if Input file has 700 rec.
Approx Number of records per file will be 10
if first 12 records belong to the same key, and second key starts with 13th record onwards,
then my first file should have 12 records and starting from 13th record it should be written in 2nd file.


Saikumaar Nagarajan,

Your condition 2 nullifies cond 1. If you want to split the file based on the key, it doesn't matter as to how many records you have in the input file and what the split value is.

ex: 1

Input has 708 records and each key has 12 records

708/12 = 59 files

if you go by the count of 70 files then 708/70 = 10.11 rounded to 10.But your split need to account for same key value records in one file which makes the count of 10 records per file useless.

ex: 2

Input has 700 records and each key has 5 records

700/70 = 10 records per file which can contain records of 2 keys in one file.

But then your rule 2 specifies that the new key should be in a new file, making the count of 10 records per file useless

Since your intention is to split the file based on the key you can use when=group function to split the file

I assumed that your input files is FB file with LRECL of 80 and your key starts in pos 1 for 10 bytes and is already sorted

The following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT         
//SYSOUT   DD SYSOUT=*           
//SORTIN   DD DSN=Your input FB 80 byte file,DISP=SHR
//OUT01    DD SYSOUT=*
//OUT02    DD SYSOUT=*
//OUT03    DD SYSOUT=*
//OUT04    DD SYSOUT=*
....all 70 files declaration
//OUT70    DD SYSOUT=*
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                   
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(83:SEQNUM,8,ZD,RESTART=(01,10))),
  IFTHEN=(WHEN=GROUP,BEGIN=(83,8,ZD,EQ,1),PUSH=(81:ID=2))           
                                                                     
  OUTFIL FNAMES=OUT01,INCLUDE=(81,2,ZD,EQ,01),BUILD=(1,80)
  OUTFIL FNAMES=OUT02,INCLUDE=(81,2,ZD,EQ,02),BUILD=(1,80)
  OUTFIL FNAMES=OUT03,INCLUDE=(81,2,ZD,EQ,03),BUILD=(1,80)
  OUTFIL FNAMES=OUT04,INCLUDE=(81,2,ZD,EQ,04),BUILD=(1,80)
  OUTFIL FNAMES=OUT05,INCLUDE=(81,2,ZD,EQ,05),BUILD=(1,80)
  OUTFIL FNAMES=OUT06,INCLUDE=(81,2,ZD,EQ,06),BUILD=(1,80)
  OUTFIL FNAMES=OUT07,INCLUDE=(81,2,ZD,EQ,07),BUILD=(1,80)
  OUTFIL FNAMES=OUT08,INCLUDE=(81,2,ZD,EQ,08),BUILD=(1,80)
  OUTFIL FNAMES=OUT09,INCLUDE=(81,2,ZD,EQ,09),BUILD=(1,80)
  OUTFIL FNAMES=OUT10,INCLUDE=(81,2,ZD,EQ,10),BUILD=(1,80)
  ....   all 70 outfil definitons
  OUTFIL FNAMES=OUT70,INCLUDE=(81,2,ZD,EQ,70),BUILD=(1,80)
//*
Back to top
View user's profile Send private message
Saikumaar Nagarajan

New User


Joined: 11 Sep 2009
Posts: 3
Location: Chennai, India

PostPosted: Mon Sep 14, 2009 2:10 pm
Reply with quote

Frank, Skolusu thank you for your replies. I'll try out these solutions and share the result....
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 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
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top