Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SUM of absolute values

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: SUM of absolute values
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10277
Location: italy

PostPosted: Thu Nov 18, 2010 7:16 pm    Post subject: Reply to: SUM of absolute values
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    Post subject: Reply to: SUM of absolute values
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts BI,TO=ZD Changing Values Tyler Dunbar DFSORT/ICETOOL 4 Tue Jul 25, 2017 12:12 am
No new posts Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Compare two files and subtract values ameetmund DFSORT/ICETOOL 7 Fri Mar 31, 2017 3:35 pm
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us