IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SUM of absolute values


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Abijoy

New User


Joined: 24 Mar 2010
Posts: 12
Location: Bangalore

PostPosted: Thu Nov 18, 2010 5:31 pm
Reply with quote

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.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Nov 18, 2010 7:16 pm
Reply with quote

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)
Back to top
View user's profile Send private message
Abijoy

New User


Joined: 24 Mar 2010
Posts: 12
Location: Bangalore

PostPosted: Fri Nov 19, 2010 10:10 am
Reply with quote

Thank you Enrico.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Generate output lines (SYSIN card for... DFSORT/ICETOOL 4
Search our Forums:

Back to Top