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
 

 

Convert the data to numeric to perform arithmetic

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Convert the data to numeric to perform arithmetic
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    Post subject: arthametic operations
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: 7931
Location: Bellevue, IA

PostPosted: Sat May 02, 2009 8:40 pm    Post subject:
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

Site Director


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

PostPosted: Sat May 02, 2009 8:51 pm    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Sat May 02, 2009 9:00 pm    Post subject:
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    Post subject: Reply to: Convert the data to numeric to perform arithmetic
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

Site Director


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

PostPosted: Sat May 02, 2009 9:38 pm    Post subject:
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    Post subject: Reply to: Convert the data to numeric to perform arithmetic
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

Site Director


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

PostPosted: Sat May 02, 2009 10:13 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
No new posts how to recover an uncataloged VSAM da... archanamuthukrishnan All Other Mainframe Topics 3 Wed Jan 11, 2017 6:18 pm
No new posts HALDB data refresh/copy from producti... vineetanand2007 IMS DB/DC 0 Mon Jan 02, 2017 11:16 am
No new posts JES2 JEC: Use UNIX Pipes to Pass Data... Virendra Shambharkar JCL & VSAM 21 Tue Dec 20, 2016 6:55 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm


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