View previous topic :: View next topic
|
Author |
Message |
vinu78
Active User
Joined: 02 Oct 2008 Posts: 179 Location: India
|
|
|
|
Hi All,
My reqt is to accept alphanumeric value as input and the output should be as mentioned below.
01 WS-INPUT PIC X(10)
01 WS-OUTPUT PIC X(10)
Code: |
Input Output
4006.65 0004006650
905.65 0000905650
1 0000001000 |
Reason for above conversion
The output will be passed to another existing logic that is defined as 9(6)V9(3). So the values will be read and passed to further downstream as 4006.65, 905.65, 1.00
Please help in coming with the conversion logic. I have tried with NUMVAL however not able to achieve the result.
Thanks
Vinu |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Where are you not getting the result? And what result are you getting?
9(6)V9(3) is only nine bytes, so it you think it 10, that could be the problem. V is an implied, not actual decimal place, so if you expect ".", that could be the problem.
As long as all the input data are valid, NUMVAL should do what you want. If the data are not all valid, NUMVAL will turn it's nose up at the first one it doesn't like, and an abend will ensue, so be sure. |
|
Back to top |
|
|
chandan.inst
Active User
Joined: 03 Nov 2005 Posts: 275 Location: Mumbai
|
|
|
|
Hi,
Agree with BIll..
Even You can try below approach. This is untested
1. Unstring INPUT fields in two numeric fields with delimited by '.'
2. Multiply 1st part of ustring output by 1000 and then add later part of
unstring output to multiplication result
I might be missing something here so its better try out and play around the logic
Also it will be better if you show us how you have used Numval and provide answers to Bill's question
Regards,
Chandan |
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
Back to top |
|
|
vinu78
Active User
Joined: 02 Oct 2008 Posts: 179 Location: India
|
|
|
|
Hi Bill,
I have tried the following:
01 WS-INPUT PIC X(10).
01 WS-TEMP PIC 9(7)V9(3).
COMPUTE WS-TEMP = FUNCTION NUMVAL (WS-INPUT).
MOVE WS-TEMP TO WS-INPUT.
While compiling, I am getting the error message at the COMPUTE step as follows:
"WS-TEMP (NUMERIC NON-INTEGER)" and "WS-INPUT(ALPHANUMERIC)" did not follow the statement compatibility rules.
The statement was discarded.
Then I tried changing the WS-INPUT as 9(10) and got the following error:
Function argument "WS-INPUT" did not have the correct type for
function "NUMVAL". The statement was discarded.
Not sure how to get rid of this error. Plz help.
Thanks
Vinu |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
The statement compatability rules error is due to you attempting to move an alphanumeric variable to a numeric variable with a decimal point.
The invalid function argument is because NUMVAL only works on alphanumeric variables; numbers are already numeric and valued. |
|
Back to top |
|
|
|