Abijoy
New User
Joined: 24 Mar 2010 Posts: 12 Location: Bangalore
|
|
|
|
Hi,
I am using SORT to add up a field in a file.
LRECL = 80
RECFM = FB
The file has a packed decimal field of length 3 starting from column 1.
It has values 200, 300, and -5 in the three records. And that is all it has.
When i use SUM FIELDS=(1,3,PD) the output has value 495. ( Sum of the above 3 records).
I want the sum to be appearing as 505 ( i.e 200+300+5) discarding the sign. Is there a way to do this? Is it possible to do this in one step?
I am using : SYNCSORT FOR Z/OS 1.3.2.2R
Thanks. |
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
found somewhere on the net googling for "SYNCSORT ABSOLUTE VALUE"
Quote: |
FWIW, this technique works with DFSORT. I assumed the PD value is in
11-15 and the input file has RECFM=FB and LRECL=80, but the statements
can be changed appropriately for other situations. I also assumed you
want to keep the original negative values rather than actually making
them positive.
* If PD value in 11-15 is negative, set 81-85 to value * -1
INREC IFTHEN=(WHEN=(11,5,PD,LT,+0),
OVERLAY=(81:11,5,PD,MUL,-1,TO=PD,LENGTH=5)),
* If PD value in 11-15 is positive, copy value to 81-85
IFTHEN=(WHEN=NONE,OVERLAY=(81:11,5))
* Sort on absolute PD value in 81-85.
SORT FIELDS=(81,5,PD,A)
* Remove 81-85.
OUTREC BUILD=(1,80)
Frank Yaeger - DFSORT Team (IBM) |
|
|