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 an input file based on key value

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Splitting an input file based on key value
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    Post subject:
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    Post subject:
Reply with quote

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

Site Director


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

PostPosted: Fri Sep 11, 2009 8:14 pm    Post subject:
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 Moderator


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

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

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

I posted a solution previously for something similar at:

http://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    Post subject:
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    Post subject:
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    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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 11 Tue May 16, 2017 2:20 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am


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