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
 

 

Split file based on nth occurrence

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

New User


Joined: 29 Nov 2006
Posts: 27
Location: India

PostPosted: Tue Dec 16, 2008 2:31 pm    Post subject: Split file based on nth occurrence
Reply with quote

I need a help in this following problem:

I have a input file VBA e.g.:

Code:
NOKIA 123456
AAAABBBBB
AAAABBBBB
AAAABBBBB
NOKIA azsdfgg
AAAABBBBB
AAAABBBBB
NOKIA 123456
AAAABBBBB
AAAABBBBB
NOKIA 123456
AAAABBBBB
AAAABBBBB
NOKIA 123456
AAAABBBBB
AAAABBBBB


I need to split the file using SORT/ICETOOL by nth occurrence of NOKIA. In the above example, if I want to split in every 3rd occurrence of NOKIA then the sort will output 2 files (total NOKIA count=5) like:

File 1:
Code:

NOKIA 123456
AAAABBBBB
AAAABBBBB
AAAABBBBB
NOKIA azsdfgg
AAAABBBBB
AAAABBBBB
NOKIA 123456



File 2:

Code:
AAAABBBBB
AAAABBBBB
NOKIA 123456
AAAABBBBB
AAAABBBBB
NOKIA 123456
AAAABBBBB
AAAABBBBB
Back to top
View user's profile Send private message

Skolusu

Senior Member


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

PostPosted: Tue Dec 16, 2008 10:08 pm    Post subject: Reply to: Split file based on nth occurrence
Reply with quote

arindam111,

You can very easily split using the new WHEN=GROUP function of DFSORT available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:


Code:

//STEP0100 EXEC PGM=ICEMAN             
//SYSOUT   DD SYSOUT=*                 
//SORTIN   DD *                         
 NOKIA 123456                           
 AAAABBBBB                             
 AAAABBBBB                             
 AAAABBBBB                             
 NOKIA AZSDFGG                         
 AAAABBBBB                             
 AAAABBBBB                             
 NOKIA 123456                           
 AAAABBBBB                             
 AAAABBBBB                             
 NOKIA 123456                           
 AAAABBBBB                             
 AAAABBBBB                             
 NOKIA 123456                           
 AAAABBBBB                             
 AAAABBBBB                             
//FILE1    DD SYSOUT=*                                               
//FILE2    DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                   
  OUTREC IFTHEN=(WHEN=INIT,BUILD=(1,5,16X,6)),                       
  IFTHEN=(WHEN=GROUP,BEGIN=(22,5,CH,EQ,C'NOKIA'),PUSH=(6:ID=8,SEQ=8))
                                                                     
  OUTFIL FNAMES=FILE1,BUILD=(1,5,22),                               
  INCLUDE=(6,8,ZD,LT,3,OR,(6,8,ZD,EQ,3,AND,14,8,ZD,EQ,1))           
  OUTFIL FNAMES=FILE2,SAVE,BUILD=(1,5,22)                           
//*                                                                 


If you don't have the July, 2008 PTF installed, ask your System Programmer to install it (it's free).

For complete details on the new WHEN=GROUP and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
Back to top
View user's profile Send private message
arindam111

New User


Joined: 29 Nov 2006
Posts: 27
Location: India

PostPosted: Wed Dec 17, 2008 7:06 am    Post subject: Reply to: Split file based on nth occurrence
Reply with quote

Thanks Skolusu. I will try it out.

The problem I stated, was actually developed in COBOL but the program taking 17 hours to run in production with a millions of records in input file. Thats why I switch to JCL.
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: Wed Dec 17, 2008 8:49 am    Post subject:
Reply with quote

Hello,

What is done with the records after the spilt?

Quote:
the program taking 17 hours to run in production with a millions of records in input file
How many millions of records? One of my little processes (cobol) passes and splits around 20 million records into multiple files - in about 20 minutes. These records are about 1050 bytes long.

While this reply is not actually SORT related, i'd suggest you take the time to understand why your cobol process takes so long. I am sure there are other processes that will need to process the records that are not going to be only SORT. Knowing what is taking all of the time will still need to be determined. . .
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
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
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm


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