JCL sum exceeding field length



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

JCL sum exceeding field length

Postby nojohn01 » Tue Mar 01, 2016 12:13 pm

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
nojohn01
 
Posts: 2
Joined: Tue Mar 01, 2016 12:03 pm
Has thanked: 2 times
Been thanked: 0 time

Re: JCL sum exceeding field length

 

Re: JCL sum exceeding field length

Postby Aki88 » Tue Mar 01, 2016 1:02 pm

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.

These users thanked the author Aki88 for the post:
nojohn01 (Tue Mar 01, 2016 9:04 pm)
Aki88
 
Posts: 303
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 32 times
Been thanked: 27 times

Re: JCL sum exceeding field length

Postby BillyBoyo » Tue Mar 01, 2016 2:00 pm

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.

These users thanked the author BillyBoyo for the post:
nojohn01 (Tue Mar 01, 2016 9:04 pm)
BillyBoyo
Global moderator
 
Posts: 3776
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 257 times

Re: JCL sum exceeding field length

Postby Aki88 » Tue Mar 01, 2016 3:35 pm

:idea: Dang, that was the logic I had on my mind, method of achieving it - overkill; thanks Billy. :)

Best Regards.
Aki88
 
Posts: 303
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 32 times
Been thanked: 27 times

Re: JCL sum exceeding field length

Postby nojohn01 » Tue Mar 01, 2016 9:06 pm

Aki88 and BillyBoyo, thanks for the quick response! My code now does what I've been trying to make it do for awhile now!
nojohn01
 
Posts: 2
Joined: Tue Mar 01, 2016 12:03 pm
Has thanked: 2 times
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post