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

Sum fields with decimal amounts


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

New User


Joined: 04 Aug 2005
Posts: 36

PostPosted: Wed Sep 03, 2008 12:24 am
Reply with quote

Hello All...

I some-what understand the power of sum fields. but for some reason I can not get it to do it with decimal amounts.

I have a file with dup records the amount I'd like to combine is ( 100.00 ) or (55.23). the file will come with the decimals. I did a test and removed the decimals and it worked fine....

How can it get it to work with the decimals?
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: Wed Sep 03, 2008 1:05 am
Reply with quote

SUM does not support any formats with a decimal point directly. But DFSORT does support the SFF (signed free form) and UFF (unsigned free form) formats that can extract the digits from a value with a decimal point (and do lots more). The SFF and UFF formats can be used directly in the TOT operand of TRAILERx which is another way to "sum" values, or it can be used to convert a value with a decimal point to a ZD or PD value which can be used with SUM, and then converted back.

For a discussion of the latter technique, see the "Sum a number with a decimal point" Smart DFSORT Trick at:

Use [URL] BBCode for External Links

If you want help using TRAILERx with TOT to deal with the values directly, show an example of the input records and what you want for output (relevant fields only), give the RECFM and LRECL of the input files, and give the starting position and length of the relevant fields.
Back to top
View user's profile Send private message
Squeak6

New User


Joined: 04 Aug 2005
Posts: 36

PostPosted: Wed Sep 03, 2008 1:18 am
Reply with quote

SORT FIELDS=(01,9,CH,A)
SUM FIELDS=(139,8, )


the SSN is in positions 01 - 09. the amount starts at position 139. total size of the amount field is 8-bytes. ( including dec 99999.99)

record length is 155. format FB
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: Wed Sep 03, 2008 1:36 am
Reply with quote

Well, since you didn't show me an example of input and output like I asked, I don't know if your values have leading zeros or not, so I'll assume they do (e.g. 00001.01). If not you can change the edit mask in the DFSORT job below to give you what you need.

Code:

//S1    EXEC  PGM=ICEMAN                                 
//SYSOUT    DD  SYSOUT=*                                 
//SORTIN DD DSN=...  input file (FB)                     
//SORTOUT DD DSN=...  output file (FB)                                   
//SYSIN    DD    *                                       
  INREC OVERLAY=(139:139,8,UFF,TO=ZD,LENGTH=8)           
  SORT FIELDS=(01,9,CH,A)                               
  SUM FIELDS=(139,8,ZD)                                 
  OUTREC OVERLAY=(139:139,8,ZD,EDIT=(TTTTT.TT))         
/*
Back to top
View user's profile Send private message
Squeak6

New User


Joined: 04 Aug 2005
Posts: 36

PostPosted: Wed Sep 03, 2008 1:42 am
Reply with quote

I'm not too sure how to post the green screen on this post.. but the data does not have leading zeros. its more like

105.06
40.00
22.50
105.06
40.00
Back to top
View user's profile Send private message
Squeak6

New User


Joined: 04 Aug 2005
Posts: 36

PostPosted: Wed Sep 03, 2008 1:45 am
Reply with quote

Code:
  105.06
   40.00
   22.50
  105.06
   40.00



* I figured it out * icon_wink.gif
Back to top
View user's profile Send private message
Squeak6

New User


Joined: 04 Aug 2005
Posts: 36

PostPosted: Wed Sep 03, 2008 1:46 am
Reply with quote

Code:
+----110--+----120--+----130--+----140--+----
                                             
************************ TOP OF DATA ********
     Miami                 FL33147  105.06   
     Miami                 FL33147   40.00   
     Miami                 FL33147   22.50   
     Miami Gardens         FL33056  105.06   
     Miami Gardens         FL33056   40.00   



the first 3 records belong to the same person the last to belong to another person
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: Wed Sep 03, 2008 1:53 am
Reply with quote

If you want leading zeros suppressed as shown, then all you have to do is change the edit mask from TTTTT.TT to IIIIT.TT:

Code:

  ...
  OUTREC OVERLAY=(139:139,8,ZD,EDIT=(IIIIT.TT))     
Back to top
View user's profile Send private message
Squeak6

New User


Joined: 04 Aug 2005
Posts: 36

PostPosted: Wed Sep 03, 2008 5:42 pm
Reply with quote

thank you so much... I'm now back in my coding *ZONE*... icon_biggrin.gif and very focused
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 Pull data using date difference betwe... DB2 6
No new posts small int to zoned decimal conversion DFSORT/ICETOOL 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
No new posts Select a DB2 value in a specific deci... DB2 4
Search our Forums:

Back to Top