Page 1 of 1

JCL sum exceeding field length

PostPosted: Tue Mar 01, 2016 12:13 pm
by nojohn01
I have data in a file with the format of "111111122222". The first 7 digits I sort and the I need to add the last 5 digits together for like values. The sum function works properly for the first 4 values but once the sum of the 2 fields exceeds 5 digits the, not fields are not added. I think I need to increase the field length using INREC but I am unsure of how to do this or if this would be the proper way to make it work. Any help would be greatly appreciated.
Here is my code.
//SYSIN    DD  *                
 ****************=(7,1,CH,A)      
        SORT  FIELDS=(1,7,CH,A)  
        SUM FIELDS=(8,5,ZD)      


Here is my data file
111111122222
122222233333
133333344444
144444455555
155555566666
166666677777
177777788888
188888899999
111111110000
122222220000
133333330000
144444440000
155555550000
166666660000
177777770000


Here is the output
111111132222
122222253333
133333374444
144444495555
155555550000
155555566666
166666660000
166666677777
177777770000
177777788888
188888899999

Re: JCL sum exceeding field length

PostPosted: Tue Mar 01, 2016 1:02 pm
by Aki88
Hello,

See if this helps you; have assumed 10 to be maximum length for the summation:


 SORT FIELDS=(1,7,CH,A)                                  
 INREC BUILD=(1:1,7,8:8,5,ZD,EDIT=(TTTTTTTTTT),LENGTH=10)
 SUM FIELDS=(8,10,ZD)                                    
 


Output:


11111110000032222
12222220000053333
13333330000074444
14444440000095555
15555550000116666
16666660000137777
17777770000158888
18888880000099999
 


Hth.

Re: JCL sum exceeding field length

PostPosted: Tue Mar 01, 2016 2:00 pm
by BillyBoyo
Aki88,

The right idea, just a little excessive:



 INREC BUILD=(1,7,C'0000',8,5)
 SORT FIELDS=(1,7,CH,A)  
 SUM FIELDS=(8,9,ZD)


The number of zeros inserted and the length of the sum field depend on the size of your total. Go for one order of magnitude greater than expected.

Re: JCL sum exceeding field length

PostPosted: Tue Mar 01, 2016 3:35 pm
by Aki88
:idea: Dang, that was the logic I had on my mind, method of achieving it - overkill; thanks Billy. :)

Best Regards.

Re: JCL sum exceeding field length

PostPosted: Tue Mar 01, 2016 9:06 pm
by nojohn01
Aki88 and BillyBoyo, thanks for the quick response! My code now does what I've been trying to make it do for awhile now!