MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Split a file into 3 files based on key using DFSORT

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
dips
Beginner


Joined: 21 Jun 2006
Posts: 9
Topics: 4
Location: Bangalore

PostPosted: Mon Jul 03, 2006 9:44 am    Post subject: Split a file into 3 files based on key using DFSORT Reply with quote

Hi,

I have a file of the below format.
Code:

001AAA
001AAB
001AAC
001AAD
001AAE
001AAF
001AAG
001AAH
001AAI
001AAJ
002BAA
002BAB
002BAC
002BAD
002BAE
002BAF
003BAA
003BAB
003BAC
003BAD
003BAE
003BAF


My requirement is is that i want to move the data to diffrent file based on the first 3 bytes. But I want only the first 3 recordfs of each type.

i.e. in the above case i will have 3 output files and they should look like

Outfile 1
Code:

001AAA
001AAB
001AAC

Outfile 2
Code:

002BAA
002BAB
002BAC

Outfile 3
Code:

003BAA
003BAB
003BAC

I know how to write the data to different files using DFSORT. But filtering only the first few records is something I am trying to do.

Can anybody help me on this?

Thanks,
Deepa
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Jul 03, 2006 9:58 am    Post subject: Reply with quote

Here's a DFSORT job that will do what you asked for. I assumed that your input file has RECFM=FB and LRECL=80, but you can change the job appropriately for other attributes.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)                  \
//OUT1 DD DSN=...  output file1 (FB/80)
//OUT2 DD DSN=...  output file2 (FB/80)
//OUT3 DD DSN=...  output file3 (FB/80)
//SYSIN    DD    *
  OPTION COPY
  INREC OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,3))
  OUTFIL FNAMES=OUT1,
     INCLUDE=(1,3,CH,EQ,C'001',AND,81,8,ZD,LE,+3),
     BUILD=(1,80)
  OUTFIL FNAMES=OUT2,
     INCLUDE=(1,3,CH,EQ,C'002',AND,81,8,ZD,LE,+3),
     BUILD=(1,80)
  OUTFIL FNAMES=OUT3,
     INCLUDE=(1,3,CH,EQ,C'003',AND,81,8,ZD,LE,+3),
     BUILD=(1,80)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort


Last edited by Frank Yaeger on Thu Jul 13, 2006 11:28 am; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dips
Beginner


Joined: 21 Jun 2006
Posts: 9
Topics: 4
Location: Bangalore

PostPosted: Tue Jul 04, 2006 5:32 am    Post subject: Reply with quote

Thanks Frank!!
_________________
Thanks,
Deepa
Back to top
View user's profile Send private message
dips
Beginner


Joined: 21 Jun 2006
Posts: 9
Topics: 4
Location: Bangalore

PostPosted: Wed Jul 12, 2006 6:23 am    Post subject: Reply with quote

Frank,

When i tried this example using the data I have, I found that each output file has more than 3 records. The reason being, that we restart the Sequence number after very 3 records and the records with sequence number LE 3 are selected. But in this case we need to restart the Sequence number for every change in the key fields and only the records with the sequnce number LE 3 should be selected.

Is thereany way of doing this?
Sorry that I was not able to reply to this post before.

Thanks,
Deepa
_________________
Thanks,
Deepa
Back to top
View user's profile Send private message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed Jul 12, 2006 7:05 am    Post subject: Reply with quote

Dips,

I am getting the desired output see my code:
Code:

//STEP010  EXEC PGM=ICEMAN                                             
//SORTIN   DD *                                                         
001AAA                                                                 
001AAB                                                                 
001AAC                                                                 
001AAD                                                                 
001AAE                                                                 
001AAF                                                                 
001AAG                                                                 
001AAH                                                                 
001AAI                                                                 
001AAJ                                                                 
002BAA                                                                 
002BAB                                                                 
002BAC                                                                 
002BAD                                                                 
002BAE                                                                 
002BAF                                                                 
003BAA                                                                 
003BAB                                                                 
003BAC                                                                 
003BAD                                                                 
003BAE                                                                 
003BAF                                                                 
//SORTOUT  DD SYSOUT=*                                                 
//SYSOUT   DD SYSOUT=*                                                 
//SYPRINT  DD SYSOUT=*                                                 
//OUT1 DD DSN=SHEKAR.A.OUT,DISP=(NEW,CATLG,CATLG),                     
//        SPACE=(TRK,(1,1),RLSE)                                       
//OUT2 DD DSN=SHEKAR.B.OUT,DISP=(NEW,CATLG,CATLG),                     
//        SPACE=(TRK,(1,1),RLSE)                                       
//OUT3 DD DSN=SHEKAR.V.OUT,DISP=(NEW,CATLG,CATLG),                     
//        SPACE=(TRK,(1,1),RLSE)                                       
//SYSIN    DD    *                                                     
  OPTION COPY                                                           
  INREC OVERLAY=(81:SEQNUM,2,ZD,RESTART=(1,3))                         
  OUTFIL FNAMES=OUT1,                                                   
     INCLUDE=(1,3,CH,EQ,C'001',AND,81,2,ZD,LE,+3),                     
     BUILD=(1,80)                                                       
  OUTFIL FNAMES=OUT2,                                                   
     INCLUDE=(1,3,CH,EQ,C'002',AND,81,2,ZD,LE,+3),                     
     BUILD=(1,80)                                                       
  OUTFIL FNAMES=OUT3,                                                   
     INCLUDE=(1,3,CH,EQ,C'003',AND,81,2,ZD,LE,+3),                     
     BUILD=(1,80)                                                       
/*                                                                     
//     

OUTPUT
Code:

SHEKAR.A.OUT                                                             
001AAA
001AAB
001AAC

SHEKAR.B.OUT
002BAA
002BAB
002BAC

SHEKAR.C.OUT
003BAA
003BAB
003BAC


_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
dips
Beginner


Joined: 21 Jun 2006
Posts: 9
Topics: 4
Location: Bangalore

PostPosted: Wed Jul 12, 2006 7:22 am    Post subject: Reply with quote

Hi,

Yeah Its working when I gave the data in SYSIN directly and tried.
When I tried it with my file it isnt working.
Let me check it out again.

Thanks a lot.

Deepa
_________________
Thanks,
Deepa
Back to top
View user's profile Send private message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed Jul 12, 2006 7:28 am    Post subject: Reply with quote

Dips,

It will work fine if you give input in SYSIN DD * or in an input dataset.
_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Jul 12, 2006 10:19 am    Post subject: Reply with quote

Quote:
Yeah Its working when I gave the data in SYSIN directly and tried.
When I tried it with my file it isnt working.


The DFSORT job I gave you would work regardless of whether the control statements are given in SYSIN directly, or in a file with RECFM=FB and LRECL=80, as long as you have the control statements I showed in each.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dips
Beginner


Joined: 21 Jun 2006
Posts: 9
Topics: 4
Location: Bangalore

PostPosted: Wed Jul 12, 2006 11:48 pm    Post subject: Reply with quote

Thanks all for your responses.
The problem when I ran this job with my file was that there are too many records for each key. And as i was using the size of sequence number as 2 digits for every 100th record the sequence number was getting reset and hence i was getting more than 3 records. I increased the size of the Sequence number accordingly and got the desired results.

Thanks a lot to u all.
_________________
Thanks,
Deepa
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Jul 13, 2006 11:28 am    Post subject: Reply with quote

Oh, I should have used a larger seqnum to begin with. I changed my example. Sorry.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group