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

Convert the data to numeric to perform arithmetic


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vrkpati

New User


Joined: 18 Jun 2007
Posts: 7
Location: hyderabad

PostPosted: Sat May 02, 2009 8:11 pm
Reply with quote

Hi,
I have a i/p file that contains the imbedded decimal point X'4B' How do I convert the data to numeric to perform arithmetic operations and then reconvert the data back to a -9(9).99 before writing the record.

In my record i have values like
ws-amount --- declared as x(7) justified right.

ws-amount --- field values are as follows
-500.00
100.00
-200.00

I want to get the total sum of ws-amount.... means my output
should be -600.00 after computation

how do I convert ws-amount to a fully numeric field, perform arithmetic on it and then write the result back out.
Back to top
View user's profile Send private message
vrkpati

New User


Joined: 18 Jun 2007
Posts: 7
Location: hyderabad

PostPosted: Sat May 02, 2009 8:13 pm
Reply with quote

my compiler not taking NUM-VAL function
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Sat May 02, 2009 8:40 pm
Reply with quote

Post in BBcode format the first couple of lines from any page of your compiler output so we can know which version of COBOL you're dealing with.

Also, it is not NUM-VAL it is NUMVAL. And post the code where you tried to use it to see what the compiler thinks about it.
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: Sat May 02, 2009 8:51 pm
Reply with quote

Hello,

At the top of the page is a link to "IBM Manuals".

Suggest you look at both NUMVAL (as Robert mentioned) and NUMVAL-C in the Language Reference that is for your compiler.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Sat May 02, 2009 9:00 pm
Reply with quote

Take a look at Craq Giegerich post in Convert a Numeric-Edited value to Numeric value.
If it works for MOVE, I wonder if it will work for ADD or COMPUTE....
Back to top
View user's profile Send private message
vrkpati

New User


Joined: 18 Jun 2007
Posts: 7
Location: hyderabad

PostPosted: Sat May 02, 2009 9:27 pm
Reply with quote

ws-amount --- field values are as follows
-500.00
100.00
-200.00
to use ws-amount in compute or in add i need to convert it to s9(6)v99 from -9(6).99 how to do that ?? with out using NUMVAL function
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: Sat May 02, 2009 9:38 pm
Reply with quote

Hello,

Quote:
with out using NUMVAL function
And this is a requirement because. . . ?

You can use the features of the compiler or you can do it "by hand", parsing each byte in code and "building" the needed value.
Back to top
View user's profile Send private message
vrkpati

New User


Joined: 18 Jun 2007
Posts: 7
Location: hyderabad

PostPosted: Sat May 02, 2009 9:55 pm
Reply with quote

I didn't get you exactly

I got compile error with NUMVAR function. (can't tell u my compiler error now as there is no connection now)
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: Sat May 02, 2009 10:13 pm
Reply with quote

Hello,

Quote:
I got compile error with NUMVAR function.
Because you did not use a valid function. . . Where did you get NUMVAR?

Quote:
I didn't get you exactly
What did you "not get"? That is like posting "it didn't work" - providing nothing for us to work with. . .
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 2
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top