Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Abijoy

New User

Joined: 24 Mar 2010
Posts: 12
Location: Bangalore

 Posted: Thu Nov 18, 2010 5:31 pm    Post subject: SUM of absolute values 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

Global Moderator

Joined: 14 Mar 2007
Posts: 10396
Location: italy

Posted: Thu Nov 18, 2010 7:16 pm    Post subject: Reply to: SUM of absolute values

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)
Abijoy

New User

Joined: 24 Mar 2010
Posts: 12
Location: Bangalore

 Posted: Fri Nov 19, 2010 10:10 am    Post subject: Reply to: SUM of absolute values Thank you Enrico.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics attchmvs from rexx subroutine that re... harisukumaran CLIST & REXX 1 Fri Jan 19, 2018 5:29 am Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm Working with hex values in Filemanage... Emile Straker IBM Tools 0 Tue Sep 12, 2017 1:42 am DB2 NULL Values display V S Amarendra Reddy DB2 3 Thu Sep 07, 2017 6:59 pm Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us