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
 
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 add sequence number for duplicate rec... SRUTHI DRAVIDAMANI COBOL Programming 11 Thu Feb 22, 2018 5:37 pm
No new posts how to add the amount for duplicate r... SRUTHI DRAVIDAMANI COBOL Programming 6 Wed Feb 21, 2018 7:21 pm
No new posts Merging records, but not all the time prino DFSORT/ICETOOL 17 Sat Feb 17, 2018 4:20 pm
No new posts Need all records with high key kalidasvs SYNCSORT 15 Fri Feb 09, 2018 10:38 pm
No new posts Why is SORT rearranging records that ... cschablow DFSORT/ICETOOL 4 Wed Jan 24, 2018 10:14 pm

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