Page 1 of 1

Sum values in a column

PostPosted: Sat Apr 19, 2014 7:37 pm
by swatmf14
I am trying to calculate sum of float values in column 714 and this value has length of 10 bytes....
But if my sum is greater than 10 bytes then also i need correct sum. 
e.g
1------------10---------------------------------714---------------723
04/19/2014                                             5600000.00
04/19/2014                                                6000.00
04/14/2014                                             5000000.00

Then i want output in another file as:
Sum   10600000.00

Please help me...

Re: Sum values in a column

PostPosted: Sun Apr 20, 2014 3:48 am
by BillyBoyo
Can you show the code that you have tried, please. Is that all you want in the output file, just the sum?

Re: Sum values in a column

PostPosted: Mon Apr 21, 2014 12:21 pm
by swatmf14
Yes..i want output as sum only..
The code i tried as below :
//step001 exec pgm=sort
//sortin dd dsn=ip.ps,disp=shr
//sortwk dd dsn=
//sortout dd dsn=op.ps,disp=shr
//sysin dd *
  sort fields=(1,10,ch,a)
  sum fileds=(714,11,zd)
/*
//

Re: Sum values in a column

PostPosted: Mon Apr 21, 2014 1:13 pm
by NicC
Please use the code tags when posting fixed font stuff like JCL, program code, data. I have coded yor stuff for you. I have also deleted your post that presents the SYSIN only as it simply duplicates the SYSIN data shown above. I seem to recall many posts saying that sort does not know aout decimals. Look them up for possibble solutions.

Re: Sum values in a column

PostPosted: Mon Apr 21, 2014 1:38 pm
by BillyBoyo
NicC is correct. Your data is not ZD, because ZD cannot understand "." in the data. There is a table of supported data-types in the manual. Have a look and see if you can get to something. Post back, either if you do or if you are still stuck.

Also, please copy/paste your code from your emulator. Otherwise we end up chasing typos.

Re: Sum values in a column

PostPosted: Mon Apr 21, 2014 4:17 pm
by swatmf14
ok..i will follow all suggestions.

Re: Sum values in a column

PostPosted: Mon Apr 21, 2014 5:35 pm
by swatmf14
I am new to the mainframe. I read manual but i am not clear,so can u explain me with sample program,so that it will be helpful for me in future also.

Re: Sum values in a column

PostPosted: Mon Apr 21, 2014 5:53 pm
by BillyBoyo
In the DFSORT Application Programming Guide you should find a table called: Summary Field Formats and Lengths. This tells you the data-types you can use for SUM, and points you to a further description of those data-types.

In that further description, you will find a data-type which can describe your data, but which can't be used in SUM.

You will need to convert that value with an actual decimal place into a field-type which SUM can understand, to use SUM.

What is the RECFM and LRECL of your input file? You will need to, temporarily, extend each record, in INREC, and return it to the original size and content, after the SORT and SUM, with OUTREC.

Re: Sum values in a column

PostPosted: Mon Apr 21, 2014 10:19 pm
by skolusu
swatmf14 wrote:
 
e.g
1------------10---------------------------------714---------------723
04/19/2014                                             5600000.00
04/19/2014                                                6000.00
04/14/2014                                             5000000.00

Then i want output in another file as:
Sum   10600000.00

Please help me...


Your summed value is incorrect. It is 10606000.00

If your intention is to sum all the free format values then you need the following control cards

//SYSIN    DD *                                                 
  OPTION COPY                                                   
  OUTFIL REMOVECC,NODETAIL,BUILD=(20X),                         
  TRAILER1=('SUM  ',TOT=(714,10,UFF,EDIT=(IIIIIIIIIIII.TT)))     
//*   


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