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: 1209
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: 1056
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: 1209
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: 1209
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: 19243
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: 1056
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 All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Identify Number of Multivolume Dataset All Other Mainframe Topics 5
No new posts Write record twice based on condition... SYNCSORT 7
No new posts Help required to reset decimal points... DFSORT/ICETOOL 10
No new posts Unable to interpret a hex value to De... COBOL Programming 7
No new posts Create a FTP record with help of SYNC... SYNCSORT 3
Search our Forums:


Back to Top