View previous topic :: View next topic
|
Author |
Message |
sameet83
New User
Joined: 05 Jul 2006 Posts: 2
|
|
|
|
Hi,
I have a variable WS-PERCENT PIC 9.99. It can have a value of .89 . I want to convert this data to 89.00. I tried multiplying WS-PERCENT by 100 but got a compilation error saying edited numeric variable cannot be used in arithmatic statement.
Could anyone please let me know as to how can I convert this data.
Thanks
Sameet |
|
Back to top |
|
|
h.dinesh
New User
Joined: 06 Dec 2006 Posts: 46 Location: Chennai
|
|
|
|
Sameet,
Please try this...
77 WS-VAR1 PIC 9.99.
77 WS-VAR2 PIC 99.99.
77 WS-VAR3 PIC 99V99.
77 WS-VAR4 PIC 9V99.
MOVE .89 TO WS-VAR4
MOVE WS-VAR4 TO WS-VAR1
MOVE WS-VAR1 TO WS-VAR3
COMPUTE WS-VAR3 = WS-VAR3 * 100
MOVE WS-VAR3 TO WS-VAR2
DISPLAY WS-VAR2
Dinesh |
|
Back to top |
|
|
sameet83
New User
Joined: 05 Jul 2006 Posts: 2
|
|
|
|
Hi Dinesh,
The above code works if the input is 0.89. i get a S0C7 error for
MOVE .89 TO WS-VAR4 .
Currently I have changed my i/p data format to 0.89 and the above code works fine.
Thanks a lot Dinesh.
Thanks
Sameet |
|
Back to top |
|
|
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 127 Location: kerala,india
|
|
|
|
hello sameet
you are getting the compilation error because you are using a edited pic item
you can declare another variable
Code: |
01 WS-PERCENT-C PIC 9V99.
01 WS-PERCENT PIC 99.99.
01 RESULT PIC 99V99.
|
Now use WS-PERCENT for display purpose (ie move value of WS-PERCENT-C
to WS-PERCENT and display WS-PERCENT)
use WS-PERCENT-C for arithmetic operation (ie
Code: |
COMPUTE RESULT = WS-PERCENT-C * 10000 |
)
Code: |
01 WS-PERCENT-C PIC 99V99.
01 WS-PERCENT PIC 99.99.
01 RESULT PIC 99V99.
|
Code: |
MOVE 0.89 TO WS-PERCENT-C.
COMPUTE RESULT = WS-PERCENT-C * 10000.
MOVE WS-PERCENT-C TO WS-PERCENT.
DISPLAY WS-PERCENT.
|
|
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Sameet,
Try this:
Code: |
01 WS-PERCENT PIC 99.99
01 WS-PERCENT-NUM PIC 99V99
MOVE WS-PERCENT TO WS-PERCENT-NUM
COMPUTE WS-PERCENT = WS-PERCENT-NUM * 100 |
Note that I changed the PIC of WS-PERCENT to 99.99 to make it large enough to contain 89.00 after the COMPUTE. |
|
Back to top |
|
|
h.dinesh
New User
Joined: 06 Dec 2006 Posts: 46 Location: Chennai
|
|
|
|
hi Sameet,
The code works fine for other nos. also. It doesn't depends on 0.89.
I think you are trying to do computation on numeric edited field. If you could paste the code which is giving error then it will be easier to understand the problem.
Dinesh |
|
Back to top |
|
|
cynderilla
New User
Joined: 07 Dec 2006 Posts: 5 Location: chennai
|
|
|
|
Hi sammet,
U got that error because we cannot do arthimatic operation's
on numeric edited variables.
instead of that we can use general varibles for the arthmatic operation's
n after that we can move it to edited variables.
n the ouput depend's upon the edited variable if it's shorter than the output,it will be truncated. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
HI ALL,
A num/ed var can be used as the receiving var in a compute, ex.:
COMPUTE WS-NUM-ED = 2 * 2 |
|
Back to top |
|
|
|