Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Edited numeric variable cannot be used in arithmatic

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

New User


Joined: 05 Jul 2006
Posts: 2

PostPosted: Thu Dec 07, 2006 2:28 pm    Post subject: Edited numeric variable cannot be used in arithmatic
Reply with quote

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
View user's profile Send private message

h.dinesh

New User


Joined: 06 Dec 2006
Posts: 46
Location: Chennai

PostPosted: Thu Dec 07, 2006 3:13 pm    Post subject:
Reply with quote

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
View user's profile Send private message
sameet83

New User


Joined: 05 Jul 2006
Posts: 2

PostPosted: Thu Dec 07, 2006 4:44 pm    Post subject:
Reply with quote

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
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 128
Location: kerala,india

PostPosted: Thu Dec 07, 2006 6:07 pm    Post subject:
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Dec 10, 2006 5:02 am    Post subject:
Reply with quote

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
View user's profile Send private message
h.dinesh

New User


Joined: 06 Dec 2006
Posts: 46
Location: Chennai

PostPosted: Mon Dec 11, 2006 12:51 pm    Post subject:
Reply with quote

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
View user's profile Send private message
cynderilla

New User


Joined: 07 Dec 2006
Posts: 5
Location: chennai

PostPosted: Mon Dec 11, 2006 5:57 pm    Post subject: Edited numeric variable cannot be used in arithmatic
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Dec 12, 2006 2:22 am    Post subject:
Reply with quote

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
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 Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts Return a Non Numeric value from REXX Learncoholic CLIST & REXX 3 Fri Sep 01, 2017 8:33 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us