IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Ignore sign while adding values using DFSORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
tarunflash

New User


Joined: 15 Oct 2005
Posts: 25

PostPosted: Fri Nov 24, 2006 3:06 pm
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Nov 24, 2006 3:42 pm
Reply with quote

That should be simple...

Use INREC to overlay the "-" and sumerize as normal.

Download Frank's Smart DFSORT Tricks at:
http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Nov 24, 2006 9:31 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Adding QMF and SPUFI to the ISPF menu DB2 20
Search our Forums:

Back to Top