Page 1 of 1

DFSORT, sum fields of signed decimal fields

PostPosted: Wed Nov 23, 2011 4:39 pm
by JorenWillems
Hi

I have following 5 records in my input file:

+00000052.42
+00000014.48
-00000009.95
+00000009.29
-00000016.04

I want do sum this fields but I encountered several problem due to the format.

Can someone please help me by writing a good sort to sum this fields?

thx

Re: DFSORT, sum fields of signed decimal fields

PostPosted: Wed Nov 23, 2011 11:53 pm
by Frank Yaeger
If you just want one output record with the total of the fields, you can use a DFSORT job like the following:

//S1 EXEC PGM=SORT                                               
//SYSOUT DD SYSOUT=*                                             
//SORTIN DD *                                                   
+00000052.42                                                     
+00000014.48                                                     
-00000009.95                                                     
+00000009.29                                                     
-00000016.04                                                     
//SORTOUT DD SYSOUT=*                                           
//SYSIN DD *                                                     
  OPTION COPY                                                   
  OUTFIL REMOVECC,NODETAIL,                                     
    TRAILER1=(TOT=(1,12,SFF,EDIT=(STTTTTTTT.TT),SIGNS=(+,-)))   
/*


SORTOUT would have:

+00000050.20


If you want something else, you need to do a better job of explaining what you want to do.

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss? ... g3T7000080