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

Reg: Using NUMVAL intrinsic function


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

New User


Joined: 26 Mar 2005
Posts: 17

PostPosted: Sun Jun 05, 2005 11:50 pm
Reply with quote

Hello,
Appreciate any suggestions / help on this problem.

CODE:

05 WS-A PIC X(3) '999'.
05 WS-B PIC 9(3).

DISPLAY 'WS-A: ' WS-A
MOVE FUNCTION NUMVAL(WS-A) TO WS-B.
DISPLAY ' WS-B: ' WS-B

Problem: there is a compilation error to the effect that use of NUMVAL function is invalid in this context.

Troubleshooting: Tried changing WS-B to COMP-1 because the return type of NUMVAL is floating point...But error persists.

Thanks for help.
Back to top
View user's profile Send private message
Aditya Bhardwaj
Warnings : 1

New User


Joined: 02 Nov 2004
Posts: 18
Location: Noida, India

PostPosted: Tue Jun 07, 2005 10:45 am
Reply with quote

Hi SSB,
The solution to your problem is to use COMPUTE rather to move the value from alphanumeric to the numeric field.

Code the following:

05 WS-A PIC X(3) '999'.
05 WS-B PIC 9(3).

DISPLAY 'WS-A: ' WS-A
COMPUTE WS-B = FUNCTION NUMVAL(WS-A).
DISPLAY ' WS-B: ' WS-B

With this we can do five arithmetic operations on the same like ADD, SUBTRACT, MULTIPLY, DIVIDE and COMPUTE.

During the analysis, what we found is, the "FUNCTION NUMVAL (WS-A)" performs the related task, but fail to find the location to store it temporarily before moving it to WS-B variable.

Let me know if I am clear and suggestions/corrections are always welcomed.
Back to top
View user's profile Send private message
mail_ssb

New User


Joined: 26 Mar 2005
Posts: 17

PostPosted: Fri Jun 10, 2005 6:05 am
Reply with quote

Hi Aditya,

You are correct....NUMVAL works if I use COMPUTE....

Its weird but even standard IBM documentation illustrates NUMVAL using a MOVE statement..!!

Appreciate your help...Thanks..!
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 Calling an Open C library function in... CICS 1
No new posts DATE2 function SYNCSORT 15
No new posts Help on PL/I jsonPutValue function PL/I & Assembler 8
No new posts how to use Tso outtrap external function All Other Mainframe Topics 8
No new posts INSYNC option with same function as I... JCL & VSAM 0
Search our Forums:

Back to Top