IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

using a alpha-numeric variable for computation


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sameetshetty

New User


Joined: 19 Jan 2007
Posts: 11
Location: bangalore

PostPosted: Thu Mar 01, 2007 2:47 pm
Reply with quote

hi,
I have a variable
ws-amount-ch pic x(18).

the data in this variable could be any of the foll.
Code:
                  11111.01
                     22222
                 222222.12

All of the data in ws-amount-ch will be right justfied.

I have to do some computation using the ws-amount-ch field. Could any one please tell as too how can i use this variable to perform arithmatic operation.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu Mar 01, 2007 4:13 pm
Reply with quote

use
Code:

 INSPECT WS-AMOUNT-CH REPLACING ALL SPACES BY ZEROS.
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Thu Mar 01, 2007 5:32 pm
Reply with quote

sameet wrote

Quote:
I have to do some computation using the ws-amount-ch field. Could any one please tell as too how can i use this variable to perform arithmatic operation.


In order to perform arithmetic operations ,move the alphanumeric variable X(18) to numeric variable 9(18) and perform your desired arithmetic operations.After operations,if you need you can move it again to alpha numeric variable.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu Mar 01, 2007 5:44 pm
Reply with quote

Quote:

perform arithmetic operations ,move the alphanumeric variable X(18) to numeric variable 9(18)

That is implied. You can not use alphanumerics in computation..
But you will have to first replace spaces in that variable, ..right?
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu Mar 01, 2007 6:05 pm
Reply with quote

Please refer following link for a great discussion on the same topic
[url]
ibmmainframes.com/viewtopic.php?t=18229
[/url]
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Mar 01, 2007 6:11 pm
Reply with quote

sameetshetty,

Unless you have the COBOL intrinsic function NUMVAL, you will have to replace the leading blanks and somehow align to and then squeeze out to decimal point.

Bill
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Convert HEX to Numeric DB2 3
Search our Forums:

Back to Top