Sum values in a column



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

Sum values in a column

Postby swatmf14 » Sat Apr 19, 2014 7:37 pm

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...
swatmf14
 
Posts: 11
Joined: Fri Jan 17, 2014 10:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Sum values in a column

Postby BillyBoyo » Sun Apr 20, 2014 3:48 am

Can you show the code that you have tried, please. Is that all you want in the output file, just the sum?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Sum values in a column

Postby swatmf14 » Mon Apr 21, 2014 12:21 pm

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)
/*
//
swatmf14
 
Posts: 11
Joined: Fri Jan 17, 2014 10:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Sum values in a column

Postby NicC » Mon Apr 21, 2014 1:13 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Sum values in a column

Postby BillyBoyo » Mon Apr 21, 2014 1:38 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Sum values in a column

Postby swatmf14 » Mon Apr 21, 2014 4:17 pm

ok..i will follow all suggestions.
swatmf14
 
Posts: 11
Joined: Fri Jan 17, 2014 10:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Sum values in a column

Postby swatmf14 » Mon Apr 21, 2014 5:35 pm

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.
swatmf14
 
Posts: 11
Joined: Fri Jan 17, 2014 10:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Sum values in a column

Postby BillyBoyo » Mon Apr 21, 2014 5:53 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Sum values in a column

Postby skolusu » Mon Apr 21, 2014 10:19 pm

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
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