Page 1 of 1

Summing only on particular field and getting that value only

PostPosted: Thu Oct 13, 2011 12:23 pm
by thangaraaj555
Hi,

Is it possible to sum one particular field in a file and get that value alone in a output file and assuming that I don't have any field that has the same value throughout the file in input...

Example: input
110
220
330
440

I want to sum from col 2 to 3 and get the output as 100 in the output file..

Output file should be

100

Re: Summing only on particular field and getting that value

PostPosted: Thu Oct 13, 2011 2:06 pm
by BillyBoyo
Yes.

Have a look at "TRAILER" stuff in the manual.

Re: Summing only on particular field and getting that value

PostPosted: Thu Oct 13, 2011 9:43 pm
by skolusu
thangaraaj555,

Use the following DFSORT JCL which will give you the desired results.

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                               
110                                                           
220                                                           
330                                                           
440                                                           
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                               
  SORT FIELDS=COPY                                           
  OUTFIL REMOVECC,NODETAIL,                                   
  TRAILER1=('SUM OF ALL RECORDS : ',TOT=(2,2,ZD,M11,LENGTH=8))
//*