Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Squeak6

New User

Joined: 04 Aug 2005
Posts: 36

 Posted: Wed Sep 03, 2008 12:24 am    Post subject: Sum fields with decimal amounts 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?

Frank Yaeger

DFSORT Moderator

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

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

New User

Joined: 04 Aug 2005
Posts: 36

 Posted: Wed Sep 03, 2008 1:18 am    Post subject: Reply to: sum fields 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
Frank Yaeger

DFSORT Moderator

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

Posted: Wed Sep 03, 2008 1:36 am    Post subject:

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))          /*
Squeak6

New User

Joined: 04 Aug 2005
Posts: 36

 Posted: Wed Sep 03, 2008 1:42 am    Post subject: 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
Squeak6

New User

Joined: 04 Aug 2005
Posts: 36

Posted: Wed Sep 03, 2008 1:45 am    Post subject:

 Code: 105.06    40.00    22.50   105.06    40.00

* I figured it out *
Squeak6

New User

Joined: 04 Aug 2005
Posts: 36

Posted: Wed Sep 03, 2008 1:46 am    Post subject:

 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
Frank Yaeger

DFSORT Moderator

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

Posted: Wed Sep 03, 2008 1:53 am    Post subject:

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))
Squeak6

New User

Joined: 04 Aug 2005
Posts: 36

 Posted: Wed Sep 03, 2008 5:42 pm    Post subject: thank you so much... I'm now back in my coding *ZONE*... and very focused
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am SORT 3 files,extract specific fields ... Kiransr DFSORT/ICETOOL 13 Fri Mar 23, 2018 10:54 am How to group and sum the decimal value sakrat DFSORT/ICETOOL 2 Tue Mar 06, 2018 9:13 pm Sum the fields in particular format f... sharana64 DFSORT/ICETOOL 9 Fri Jan 05, 2018 1:11 am SORT BUT RETAIN HIGHEST VALUE ON NON-... leondan22 DFSORT/ICETOOL 2 Thu Dec 14, 2017 8:13 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us