Summing only on particular field and getting that value only



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Summing only on particular field and getting that value only

Postby thangaraaj555 » Thu Oct 13, 2011 12:23 pm

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
thangaraaj555
 
Posts: 10
Joined: Thu Oct 13, 2011 12:17 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Summing only on particular field and getting that value

Postby BillyBoyo » Thu Oct 13, 2011 2:06 pm

Yes.

Have a look at "TRAILER" stuff in the manual.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Summing only on particular field and getting that value

Postby skolusu » Thu Oct 13, 2011 9:43 pm

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))
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post