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

Need help with character to numeric conversion


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

New User


Joined: 17 Jun 2009
Posts: 38
Location: Denver

PostPosted: Wed Jan 20, 2010 2:26 am
Reply with quote

I have a requirement to multiply a quantity with an amount ( sounds simple). But the value coming in for quantity is not predictable. Amount is alway 7 dollar positions and 2 cents positions

The quantity is coming in as X(10).
The value can be in any of the below format

00000001.5
0000001.55
000001.555
00001.5555
0001.55555
001.555555
01.5555555
1.55555555

How can I do the muliplication
How can I convert the above values to numeric with same data and do the multiply.
Can I use NUMVAL.

eg.COMPUTE QTY-NUM = FUNCTION NUMVAL(QTY-ALPHANUM)
If so, if I define QTY-NUM as 9(8)V9(8), can I give this directly in my multiplication

I want to avoid looping. Also, if NUMVAL wont do this, can I use any other functions or statements like UNSTRING,INSPECT etc
Your advice is appreciated
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: Wed Jan 20, 2010 2:38 am
Reply with quote

Hello,

Yes, if i understand correctly, you should be able to do what you want with NUMVAL.

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/igy3lr40/7.1.32
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Wed Jan 20, 2010 3:53 am
Reply with quote

If the X(10) quantity could contain a currency sign, look at NUMVAL-C also. In addition to the Reference Manual Dick pointed to, see the Programming Guide for more information about NUMVAL and NUMVAL-C.
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 Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts 10 byte RBA conversion DB2 2
No new posts 10 byte RBA conversion -non applicati... JCL & VSAM 1
No new posts file manager is doing string conversion IBM Tools 3
No new posts Convert HEX to Numeric DB2 3
Search our Forums:

Back to Top