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
 

 

Counting the occurence of records

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

Active Member


Joined: 23 Aug 2005
Posts: 680
Location: NJ

PostPosted: Thu Aug 20, 2009 12:49 am    Post subject: Counting the occurence of records
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: 680
Location: NJ

PostPosted: Thu Aug 20, 2009 2:25 am    Post subject:
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    Post subject:
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: 680
Location: NJ

PostPosted: Fri Aug 21, 2009 1:14 am    Post subject:
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    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 Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm
No new posts To Merge mutliple records into a sing... anandgbe DFSORT/ICETOOL 6 Wed Feb 22, 2017 8:49 am


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