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
 

 

using a alpha-numeric variable for computation

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: using a alpha-numeric variable for computation
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: 685
Location: Earth

PostPosted: Thu Mar 01, 2007 4:13 pm    Post subject:
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: Chennai

PostPosted: Thu Mar 01, 2007 5:32 pm    Post subject: Re: using a alpha-numeric variable for computation
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: 685
Location: Earth

PostPosted: Thu Mar 01, 2007 5:44 pm    Post subject:
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: 685
Location: Earth

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

Please refer following link for a great discussion on the same topic
[url]
http://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: 3158
Location: Tucson AZ

PostPosted: Thu Mar 01, 2007 6:11 pm    Post subject:
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    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