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

Counting the occurence of records


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Thu Aug 20, 2009 12:49 am
Reply with quote

Hi All,

I am having a requirement in which I have an input file and I need to find the occurrence of each record in the file.

I would like to know whether I can do this with the help of DFsort or ICEtool rather writing a program.

Input file will be like:-

Code:
EEEEEEEEEEE
AAAAAAAAAAA
CCCCCCCCCCC
BBBBBBBBBBB
DDDDDDDDDDD
ZZZZZZZZZZZ
AAAAAAAAAAA
CCCCCCCCCCC
DDDDDDDDDDD
AAAAAAAAAAA
CCCCCCCCCCC
ZZZZZZZZZZZ



Expected output have to be in the below sorted order.

Code:
BBBBBBBBBBB 01
EEEEEEEEEEE 01
DDDDDDDDDDD 02
DDDDDDDDDDD 02
ZZZZZZZZZZZ 02
ZZZZZZZZZZZ 02
AAAAAAAAAAA 03
AAAAAAAAAAA 03
AAAAAAAAAAA 03
CCCCCCCCCCC 03
CCCCCCCCCCC 03
CCCCCCCCCCC 03
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Thu Aug 20, 2009 2:25 am
Reply with quote

Hi all,

I have tried the below JCL which was given in one of the older posts.I am getting the record occurence as 01 for all the records which is not true.

The input file FB and 2000 bytes long and the Key starts at 13 the postion and is 12 bytes long.

Code:

//STEP0200 EXEC PGM=ICETOOL                                             
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN       DD DSN=SSYG.USER.NKGB352.NKGFOI.PHYTODAY.TEST,DISP=SHR       
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)             
//OUT      DD SYSOUT=*                                                 
//TOOLIN   DD *                                                         
  COPY FROM(IN) USING(CTL1)                                             
  SORT FROM(T1) USING(CTL2)                                             
//CTL1CNTL DD *                                                         
  OUTFIL FNAMES=T1,REMOVECC,BUILD=(1,2000,12X),                         
  SECTIONS=(13,12,TRAILER3=(13,12,2001:COUNT=(M11,LENGTH=2),C'D'))     
//CTL2CNTL DD *                                                         
  SORT FIELDS=(13,12,CH,A,2001,2,CH,D)                                 
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(2001,2,CH,NE,C' '), -               
  PUSH=(2001:2001,2))                                                   
  OUTFIL FNAMES=OUT,OMIT=(2003,1,CH,EQ,C'D'),BUILD=(1,2002)             
/*                                                                     


Can anyone help me on this.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Aug 20, 2009 2:57 am
Reply with quote

khamarutheen,

The following DFSORT/ICETOOL JCL will give you the desired results. The trick here is to concatenate the input file twice and sum the occurances in 1 file and keep the other file as is. I also concatenated a single record 'hdr' created in step0100 which will be used as an identifier for the each record as to which file it belongs to.

Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                           
//SORTOUT  DD DSN=&&H,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                       
  OUTFIL BUILD=(2000X),                                   
  REMOVECC,NODETAIL,HEADER1=(C'HDR')                     
//*                                                       
//STEP0200 EXEC PGM=ICETOOL   
//TOOLMSG  DD SYSOUT=*       
//DFSMSG   DD SYSOUT=*       
//IN       DD DSN=&&H,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT
//         DD DSN=your input 2000 lrecl file,DISP=SHR
//         DD DSN=&&H,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT
//         DD DSN=your input 200 lrecl file,DISP=SHR
//T1       DD DSN=&&O1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)       
//OUT      DD SYSOUT=*                                           
//TOOLIN   DD *                                                 
  SORT FROM(IN) USING(CTL1)                                     
  SORT FROM(T1) USING(CTL2)                                     
//CTL1CNTL DD *                                                         
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(2002:8C'0',7C'0',C'1')),             
  IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(2001:ID=1)),       
  IFTHEN=(WHEN=(2001,1,ZD,EQ,2,AND,1,3,CH,NE,C'HDR'),                   
  OVERLAY=(2002:SEQNUM,8,ZD))                                           
  SORT FIELDS=(13,12,CH,A,2002,8,CH,A),EQUALS                           
  SUM FIELDS=(2010,8,ZD)                                               
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(2001,1,ZD,EQ,1),PUSH=(2002:2010,8)) 
  OUTFIL FNAMES=T1,INCLUDE=(2001,1,ZD,EQ,2),                           
  BUILD=(1,2000,2002,8,ZD,M10,LENGTH=8)                                 
/*                                                                     
//CTL2CNTL DD *                                                         
  SORT FIELDS=(2001,8,CH,A,13,12,CH,A),EQUALS                           
  OUTFIL FNAMES=OUT                                                     
//*
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Fri Aug 21, 2009 1:14 am
Reply with quote

Thank you Kolusu. Worked like a charm.
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 Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
No new posts JCL sortcard to print only the records DFSORT/ICETOOL 11
Search our Forums:

Back to Top