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

Sum a number with a decimal point using syncsort


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

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Wed Mar 28, 2007 1:28 pm
Reply with quote

Hi,

How can I sum a numeric field that has a sign and a decimal point using syncsort . For example, if my input file has:
251.91
241.23
289.72
231.78
-651.52
I want my output file to have:
Code:
363.12
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Wed Mar 28, 2007 10:44 pm
Reply with quote

I think you'll ned to reformat (using OUTREC?) to exclude the decpt, then sum that file, then reformat again to reinsert it.

Your example does not show decpt alignment, though, as your negative number's decpt is not aligned. In that case - much more complicated.

Is your example good?
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Thu Mar 29, 2007 9:54 am
Reply with quote

Hi Phrzby,

Its aligned only negetive sign in first byte for last record & others record are starting from second byte .

Would u please provide sort card for this?
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Thu Mar 29, 2007 10:01 am
Reply with quote

Ekta,

Why dont you try Sum a number with a decimal point from SORTTRCK pdf. Your requirement and the example provided by Frank in PDF are similar.

Let us know, if you need the PDF file.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Thu Mar 29, 2007 11:20 am
Reply with quote

Murali ,

I think u have not read my post i need the solution for syncsort not for dfsort

Hope i am clear
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Mar 30, 2007 2:47 am
Reply with quote

Hi Ekta,

If i understand correctly, the decimal point will always be in the same place?

If so, i believe you can do it in 2 passes - one pass with an inrec that copies the file skipping that data position and a second pass to sum the numbers without the decimal.

Given the same requirement, i would write a little COBOL program to do what i need - FWIW. Seems like so many of these "little" things, undergo "scope creep" and the new requirement definition needs real code.

Good Luck icon_smile.gif
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Fri Mar 30, 2007 7:10 pm
Reply with quote

I agree with Dick.

Use the right software tool so as your needs expand, you can change naturally, and those who inherit the system from you have a chance at knowing what's going on.

If you must use SORT, at least comment it (col1 = '*') with why and what you are doing.
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Point and Shoot )PTNS TSO/ISPF 0
Search our Forums:

Back to Top