Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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 Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Casting a Binary Number to Numeric in... Bob Steinkraus Java & MQSeries 6 Tue Aug 09, 2016 5:58 pm
This topic is locked: you cannot edit posts or make replies. Alphanumeric to Numeric move on UNIX mistah kurtz COBOL Programming 16 Wed Jul 27, 2016 8:47 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us