View previous topic :: View next topic
|
Author |
Message |
mail_ssb
New User
Joined: 26 Mar 2005 Posts: 17
|
|
|
|
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 |
|
|
Aditya Bhardwaj Warnings : 1 New User
Joined: 02 Nov 2004 Posts: 18 Location: Noida, India
|
|
|
|
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 |
|
|
mail_ssb
New User
Joined: 26 Mar 2005 Posts: 17
|
|
|
|
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 |
|
|
|