View previous topic :: View next topic
|
Author |
Message |
Squeak6
New User
Joined: 04 Aug 2005 Posts: 36
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
Squeak6
New User
Joined: 04 Aug 2005 Posts: 36
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
Squeak6
New User
Joined: 04 Aug 2005 Posts: 36
|
|
|
|
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 |
|
|
Squeak6
New User
Joined: 04 Aug 2005 Posts: 36
|
|
|
|
Code: |
105.06
40.00
22.50
105.06
40.00
|
* I figured it out * |
|
Back to top |
|
|
Squeak6
New User
Joined: 04 Aug 2005 Posts: 36
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
Squeak6
New User
Joined: 04 Aug 2005 Posts: 36
|
|
|
|
thank you so much... I'm now back in my coding *ZONE*... and very focused |
|
Back to top |
|
|
|