Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sum fields with decimal amounts

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Sum fields with decimal amounts
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 Moderator


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

PostPosted: Wed Sep 03, 2008 1:05 am    Post subject:
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:

www.ibm.com/systems/support/storage/software/sort/mvs/tricks/

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    Post subject: Reply to: sum fields
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 Moderator


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

PostPosted: Wed Sep 03, 2008 1:36 am    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Wed Sep 03, 2008 1:53 am    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Sum Fields ballaswaroop DFSORT/ICETOOL 4 Tue May 02, 2017 11:07 am
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts Joinkeys with decimal scdinesh DFSORT/ICETOOL 3 Fri Feb 10, 2017 4:46 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us