View previous topic :: View next topic
|
Author |
Message |
tarunflash
New User
Joined: 15 Oct 2005 Posts: 25
|
|
|
|
Hi,
Is there is any way to add the values in afile using JCL by ignoring the sign.
eg. i have a file with foll values
Code: |
192BI -4.10
192PD -2.73
192UM -65.47
211CC 21.40
211CL 64.89
|
if we add this using sort utility i will get sum as 13.99
instead of that i should get as 158.59
i mean it should ignore sign.despite og whether it is -ve or +ve it should add total of them |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You can use DFSORT's UFF format to get absolute values of signed numbers with decimal points. Here's a DFSORT job that will total the values:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
192BI -4.10
192PD -2.73
192UM -65.47
211CC 21.40
211CL 64.89
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,
TRAILER1=(/,'Total',
15:TOT=(15,9,UFF,EDIT=(IIIIIT.TT)))
/*
|
SORTOUT will have:
Code: |
192BI -4.10
192PD -2.73
192UM -65.47
211CC 21.40
211CL 64.89
Total 158.59
|
Quote: |
Use INREC to overlay the "-" and sumerize as normal. |
You can't use SUM for values with a decimal point. You would have to use UFF or SFF format to remove the decimal point and convert to ZD, sum the ZD values and then convert back. TRAILER with TOT is easier. |
|
Back to top |
|
|
|