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

Split file based on nth occurrence


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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:

Use [URL] BBCode for External Links
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
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

Moderator Emeritus


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

PostPosted: Wed Dec 17, 2008 8:49 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
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
Search our Forums:

Back to Top