Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Split record in differents files depending on key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
elmister

New User


Joined: 27 Nov 2005
Posts: 14

PostPosted: Tue Feb 23, 2010 1:09 am    Post subject: Split record in differents files depending on key
Reply with quote

Hi, I need to do the following:

I have a input file like this:

000001
000001
000001
000002
000002
000003
000004
000004
000005
000005
000005
000005
000006

I want this information splited in three files, but without the split the records with the same key, like following:

output file 1:
000001
000001
000001
000004
000004


output file 2:
000002
000002
000005
000005
000005
000005



output file 3:
000003
000006

So I want all the records with the same key in the same output file, not one record with key 000001 in the output file1, output file2, etc..
Back to top
View user's profile Send private message

Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Feb 23, 2010 11:45 am    Post subject:
Reply with quote

Below sortstep will give you desired result.
I have assumed LRECL=80,RECFM=FB.
Do the changes accordingly if required.
Code:

//S1    EXEC  PGM=SORT     
//SORTIN DD *               
000001                     
000001                     
000001                     
000002                     
000002                     
000003                     
000004                     
000004                     
000005                     
000005                     
000005                     
000005                     
000006                     
//SORTOF1 DD SYSOUT=*       
//SORTOF2 DD SYSOUT=*       
//SORTOF3 DD SYSOUT=*       
//SYSOUT    DD  SYSOUT=*                                             
//SYSIN    DD  *
  SORT FIELDS=(1,6,CH,A)                                           
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,6))),
       IFTHEN=(WHEN=GROUP,BEGIN=(81,8,ZD,EQ,1),PUSH=(89:ID=8)),   
       IFTHEN=(WHEN=NONE,OVERLAY=(97:89,8,ZD,MOD,+3,ZD,LENGTH=1)) 
  OUTFIL FNAMES=SORTOF1,INCLUDE=(97,1,ZD,EQ,1),BUILD=(1,80)       
  OUTFIL FNAMES=SORTOF2,INCLUDE=(97,1,ZD,EQ,2),BUILD=(1,80)       
  OUTFIL FNAMES=SORTOF3,SAVE,BUILD=(1,80)                         
/*                                                                 
Back to top
View user's profile Send private message
elmister

New User


Joined: 27 Nov 2005
Posts: 14

PostPosted: Tue Feb 23, 2010 3:32 pm    Post subject: Reply to: Split record in differents files depending on key
Reply with quote

Many thanks. Its working like I want.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Feb 23, 2010 3:50 pm    Post subject:
Reply with quote

You are Welcome.. icon_biggrin.gif
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 Comparing two sequential files Mohan Kothakota COBOL Programming 14 Mon Apr 16, 2018 6:35 pm
No new posts VSAM - Accessing beyond record size Benchwarmer JCL & VSAM 6 Wed Apr 11, 2018 9:20 pm
No new posts SORT 3 files,extract specific fields ... Kiransr DFSORT/ICETOOL 13 Fri Mar 23, 2018 10:54 am
No new posts How to build one file from two input ... daniele DFSORT/ICETOOL 5 Tue Feb 27, 2018 6:45 pm
No new posts Copying only first and last word from... chandan.inst SYNCSORT 4 Wed Jan 31, 2018 4:19 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us