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

Including Record Count to header record


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

Active User


Joined: 22 Jan 2006
Posts: 114
Location: India

PostPosted: Tue Apr 28, 2009 7:14 pm
Reply with quote

I have a file as below

Code:

Acc1 Security1 H
Acc1 Security1 T
Acc1 Security1 T
Acc1 Security1 T
Acc1 Security2 H
Acc1 Security2 T
Acc1 Security2 T
Acc1 Security3 H
Acc1 Security3 T


and the output should be as

Code:

Acc1 Security1 H 3
Acc1 Security1 T
Acc1 Security1 T
Acc1 Security1 T
Acc1 Security2 H 2
Acc1 Security2 T
Acc1 Security2 T
Acc1 Security3 H 1
Acc1 Security3 T


where the newly added fields as part of 'H' records are count of the 'T' records.

Is this possible to be implemented using SORT ?
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Apr 28, 2009 10:25 pm
Reply with quote

The following DFSORT/ICETOOL JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=ICETOOL                               
//TOOLMSG  DD SYSOUT=*                                     
//DFSMSG   DD SYSOUT=*                                     
//IN       DD *                                           
----+----1----+----2----+----3----+----4----+----5----+----
ACC1 SECURITY1 H                                           
ACC1 SECURITY1 T                                           
ACC1 SECURITY1 T                                           
ACC1 SECURITY1 T                                           
ACC1 SECURITY2 H                                           
ACC1 SECURITY2 T                                           
ACC1 SECURITY2 T                                           
ACC1 SECURITY3 H                                           
ACC1 SECURITY3 T                                           
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//OUT      DD SYSOUT=*                                     
//TOOLIN   DD *                                           
  COPY FROM(IN) USING(CTL1)                               
  SORT FROM(T1) USING(CTL2)                               
//CTL1CNTL DD *                                           
  OUTFIL FNAMES=T1,REMOVECC,                               
  SECTIONS=(6,9,TRAILER3=(6:6,9,17:COUNT-1=(M10,LENGTH=8)))
//CTL2CNTL DD *                                           
  SORT FIELDS=(6,9,CH,A,17,8,CH,D),EQUALS                 
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(16,1,CH,EQ,C' '),       
  RECORDS=2,PUSH=(17:17,8))                               
  OUTFIL FNAMES=OUT,OMIT=(16,1,CH,EQ,C' ')                 
/*                                                         
Back to top
View user's profile Send private message
Itanium

Active User


Joined: 22 Jan 2006
Posts: 114
Location: India

PostPosted: Wed Apr 29, 2009 10:23 am
Reply with quote

Thanks Kolusu. Getting the results, if i run with one acct.

When executing with below input
Code:

ACC1 SECURITY1 H
ACC1 SECURITY1 T
ACC1 SECURITY1 T
ACC1 SECURITY1 T
ACC1 SECURITY2 H
ACC1 SECURITY2 T
ACC1 SECURITY2 T
ACC1 SECURITY3 H
ACC1 SECURITY3 T
ACC2 SECURITY1 H
ACC2 SECURITY1 T
ACC2 SECURITY1 T
ACC2 SECURITY1 T
ACC2 SECURITY2 H
ACC2 SECURITY2 T
ACC2 SECURITY2 T
ACC2 SECURITY3 H
ACC2 SECURITY3 T


Output is as below
Code:

ACC1 SECURITY1 H       3
ACC1 SECURITY1 T       
ACC1 SECURITY1 T       
ACC1 SECURITY1 T       
ACC2 SECURITY1 H       
ACC2 SECURITY1 T       
ACC2 SECURITY1 T       
ACC2 SECURITY1 T       
ACC1 SECURITY2 H       2
ACC1 SECURITY2 T       
ACC1 SECURITY2 T       
ACC2 SECURITY2 H       
ACC2 SECURITY2 T       
ACC2 SECURITY2 T       
ACC1 SECURITY3 H       1
ACC1 SECURITY3 T       
ACC2 SECURITY3 H       
ACC2 SECURITY3 T       


It should have been as
Code:

ACC1 SECURITY1 H       3
ACC1 SECURITY1 T       
ACC1 SECURITY1 T       
ACC1 SECURITY1 T       
ACC1 SECURITY2 H       2
ACC1 SECURITY2 T       
ACC1 SECURITY2 T       
ACC1 SECURITY3 H       1
ACC1 SECURITY3 T       
ACC2 SECURITY1 H       3
ACC2 SECURITY1 T       
ACC2 SECURITY1 T       
ACC2 SECURITY1 T       
ACC2 SECURITY2 H       2
ACC2 SECURITY2 T       
ACC2 SECURITY2 T       
ACC2 SECURITY3 H       1
ACC2 SECURITY3 T       
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Apr 29, 2009 9:52 pm
Reply with quote

Itanium,

You never mentioned anything about the keys in your first post. So I assumed that the key is only 9 bytes from pos 6. But looks like your key is 14 bytes length from pos1. In that case use the following JCL

Code:

//STEP0100 EXEC PGM=ICETOOL                                 
//TOOLMSG  DD SYSOUT=*                                       
//DFSMSG   DD SYSOUT=*                                       
//IN       DD *                                             
ACC1 SECURITY1 H                                             
ACC1 SECURITY1 T                                             
ACC1 SECURITY1 T                                             
ACC1 SECURITY1 T                                             
ACC1 SECURITY2 H                                             
ACC1 SECURITY2 T                                             
ACC1 SECURITY2 T                                             
ACC1 SECURITY3 H                                             
ACC1 SECURITY3 T                                             
ACC2 SECURITY1 H                                             
ACC2 SECURITY1 T                                             
ACC2 SECURITY1 T                                             
ACC2 SECURITY1 T                                             
ACC2 SECURITY2 H                                             
ACC2 SECURITY2 T                                             
ACC2 SECURITY2 T                                             
ACC2 SECURITY3 H                                             
----+----1----+----2----+----3----+----4----+----5----+----6-
ACC2 SECURITY3 T                                             
//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,                                 
  SECTIONS=(1,14,TRAILER3=(1,14,17:COUNT-1=(M10,LENGTH=8))) 
//CTL2CNTL DD *                                             
  SORT FIELDS=(1,14,CH,A,17,8,CH,D),EQUALS                   
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(16,1,CH,EQ,C' '),         
  RECORDS=2,PUSH=(17:17,8))                                 
  OUTFIL FNAMES=OUT,OMIT=(16,1,CH,EQ,C' ')                   
/*                                                           
Back to top
View user's profile Send private message
Itanium

Active User


Joined: 22 Jan 2006
Posts: 114
Location: India

PostPosted: Wed Apr 29, 2009 9:54 pm
Reply with quote

Thanks Kolusu.
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts To get the count of rows for every 1 ... DB2 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top