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

how to convert character to numeric data type in cobol


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

New User


Joined: 14 Mar 2007
Posts: 24
Location: gurgaon

PostPosted: Wed May 14, 2008 8:15 pm
Reply with quote

How to convert character to numeric data type in cobol???
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed May 14, 2008 8:20 pm
Reply with quote

Usually a move will work, or maybe a redefine.....
Or try the intrinsic function NUMVAL.....
How about an example of what you consider "character" and "numeric" data?
Back to top
View user's profile Send private message
krishnasaikiah

New User


Joined: 14 Mar 2007
Posts: 24
Location: gurgaon

PostPosted: Wed May 14, 2008 8:27 pm
Reply with quote

Can you please cite me an example??

Time pic x(8) to time pic 9(8)


this is my requirement....
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed May 14, 2008 8:58 pm
Reply with quote

krishnasaikiah wrote:
Time pic x(8) to time pic 9(8)
If the x(8) is valid numeric (no spaces):
05 timex pic x(8).
05 time9 redefines timex pic 9(8).
or:
move timex to time9.
If the x(8) is not valid numeric (some spaces):
Compute time9 = function numval (timex).
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed May 14, 2008 9:16 pm
Reply with quote

Hello,

Quote:
Time pic x(8) to time pic 9(8)
this is my requirement....
Time is often HH:MM:SS. What is in your x(8) field?

How will you use a time field defined as 9(8)? As an 8-digit value, time is not very useful icon_confused.gif
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed May 14, 2008 9:23 pm
Reply with quote

Good catch, I didn't even think of the dataname 'time' as anything other than a dataname.....Even NUMVAL won't work......
I guess we just have to wait & see......
Back to top
View user's profile Send private message
krishnasaikiah

New User


Joined: 14 Mar 2007
Posts: 24
Location: gurgaon

PostPosted: Wed May 14, 2008 11:25 pm
Reply with quote

Hi all,
I have typed my column name as time..it is not time it is date column...
i need to convert my date field which is x(8)...CCYYMMDD..to 9(8) CCYYMMDD....
I hope now it is clear to alll
Thanks in advance
krishna
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed May 14, 2008 11:32 pm
Reply with quote

Hello,

If you have already verified that the data field has a valid value, a simple REDEFINES will give you the 9(8) you want.
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 Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top