Page 1 of 1

Need help on SUM field

PostPosted: Thu Apr 26, 2012 10:19 pm
by kiran_wiproblr
Hi All,

Can some one help me please?

I am using below JCL to get sum

//STEP EXEC PGM=SORT                       
//SYSPRINT DD SYSOUT=*                     
//SYSOUT DD SYSOUT=*                       
//SORTIN DD *                             
AAAAAAA 90                                 
AAAAAAA 30                                 
AAAAAAA 40                                 
AAAAAAA 10                                 
XXXXXXX 45                                 
BBBBBBB 90                                 
TTTTTTT 80                                 
//SORTOUT DD SYSOUT=*                     
//SYSIN DD *                               
  INCLUDE COND=(1,7,CH,EQ,C'AAAAAAA')     
  SORT FIELDS=(1,7,CH,A)                   
  SUM FIELDS=(9,2,ZD)                     
/* 


Obtained output
----+----1----+----2----+----3----+----4
AAAAAAA 90
AAAAAAA 80


But My expected output has to be
----+----1----+----2----+----3----+----4
AAAAAAA 170

Re: Need help on SUM field

PostPosted: Thu Apr 26, 2012 10:39 pm
by BillyBoyo
There was not enough space in the field, which is only two bytes long, to hold 170. Maybe next best thing is two record records with same key which add up to that. Check in your documentation of the product.

Re: Need help on SUM field

PostPosted: Thu Apr 26, 2012 10:40 pm
by Akatsukami
You're specifying a length of 2 for your sum field, which is overflowed by adding the second record. Change your SUM card to:
SUM FIELDS=(8,3,ZD)

Re: Need help on SUM field

PostPosted: Thu Apr 26, 2012 11:03 pm
by kiran_wiproblr
Hi Akatsukami

Thanks a lot it is working !!!!!!!!!

Re: Need help on SUM field

PostPosted: Thu Apr 26, 2012 11:28 pm
by BillyBoyo
Keep in mind that your output records are now one byte longer than they were. Better, if you want to SUM, to make your input fields long enough that the SUM won't blow them up.