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: 686
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: 686
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: 686
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 Validate if a Value from the file is ... balacsv2 COBOL Programming 8 Mon Jun 19, 2017 11:52 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm


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