Page 1 of 1

How to get roll up count?

PostPosted: Fri Feb 24, 2012 11:44 am
by pjagathis
Hi,

I have to get the rollup count in the output file

Input File:

10|AAAAAA    |12345|000002
10|AAAAAA    |12345|000002
10|AAAAAA    |12345|000003
11|BBBBBB    |67890|000003
11|BBBBBB    |67890|000003
11|BBBBBB    |67890|000003


The records are rolled on 4 th field based on first three fields.. So after rollup based on above input only 2 records will come to output.

Code Used to rollup alone

//SYSIN    DD *           
**                         
  SORT FIELDS=(01,02,CH,A,
               03,10,CH,A,
               15,05,CH,A)
**                         
   SUM FIELDS=(21,06,ZD)   
**                         
/*                         


Output File:


The last field should have the number of records rolled into single record. How can we get the count in output file?

10|AAAAAA    |12345|000007|3|
11|BBBBBB    |67890|000006|2|


Please help me to get the last field in the output file(ie, How many number of records rolled into a single record..!

Re: How to get roll up count?

PostPosted: Fri Feb 24, 2012 2:04 pm
by BillyBoyo
Are you saying you want the SUM plus the count of records which make up that sum? Can you check your output, and correct or better explain please.

Re: How to get roll up count?

PostPosted: Fri Feb 24, 2012 2:10 pm
by enrico-sorichetti
here is something to start with

the jcl
 000004 //ICE     EXEC PGM=SORT                                                 
 000005 //SYSOUT    DD SYSOUT=*                                                 
 000006 //SYSPRINT  DD SYSOUT=*                                                 
 000007 //SORTIN    DD *                                                       
 000008 1239      0010                                                         
 000009 1239      0020                                                         
 000010 1239      0030                                                         
 000011 1239      0040                                                         
 000012 1232      0010                                                         
 000013 1232      0020                                                         
 000014 1232      0030                                                         
 000015 1231      0010                                                         
 000016 1231      0020                                                         
 000017 1231      0030                                                         
 000018 1231      0040                                                         
 000019 1238      0010                                                         
 000020 1238      0020                                                         
 000021 1238      0030                                                         
 000022 1237      0010                                                         
 000023 1237      0020                                                         
 000024 1236      0010                                                         
 000025 1235      0010                                                         
 000026 //SORTOUT   DD SYSOUT=*                                                 
 000027 //SYSIN     DD *                                                       
 000028   SORT  FIELDS(01,4,CH,A)                                               
 000029   INREC OVERLAY=(21:C'0001')                                           
 000030   SUM   FIELDS(11,4,ZD,21,4,ZD)                                         
 000031 //                                                                     

the result
********************************* TOP OF DATA **********************************
1231      0100      0004                                                       
1232      0060      0003                                                       
1235      0010      0001                                                       
1236      0010      0001                                                       
1237      0030      0002                                                       
1238      0060      0003                                                       
1239      0100      0004                                                       
******************************** BOTTOM OF DATA ********************************

Re: How to get roll up count?

PostPosted: Fri Feb 24, 2012 5:04 pm
by pjagathis
Hi enrico-sorichetti,

Thanks this was i expected.. Thanks.

Hi BillyBoyo,

I think you are clear now.