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
 

 

Need help with character to numeric conversion

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
manugeorge2004

New User


Joined: 17 Jun 2009
Posts: 35
Location: Denver

PostPosted: Wed Jan 20, 2010 2:26 am    Post subject: Need help with character to numeric conversion
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

Site Director


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

PostPosted: Wed Jan 20, 2010 2:38 am    Post subject:
Reply with quote

Hello,

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

http://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    Post subject:
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    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 Extra character appears in file when ... Balu5491 All Other Mainframe Topics 1 Wed Jul 26, 2017 2:39 pm
No new posts Validate if a Value from the file is ... balacsv2 COBOL Programming 8 Mon Jun 19, 2017 11:52 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts the use of 'B3'x character in a panel Pedro TSO/ISPF 1 Thu Feb 16, 2017 3:09 am
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm


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