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

Better way when 'moving alphanumeric character to numeric


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

New User


Joined: 23 Oct 2006
Posts: 10

PostPosted: Wed Nov 01, 2006 3:36 pm
Reply with quote

Hello, Sir.
Could you please advise what's the better way when 'moving alphanumeric character to numeric value ' ?
One way: determine if the alphanumeric just only contains numeric value.
Cobol sentence: IF WORK-PM IS NUMERIC then ...
Another way: use NUMVAL function(A question, is there any other Function? )
Cobol sentence: COMPUTE WORK-PM = FUNCTION NUMVAL(WORK-AM) then...

What's the better way and is there any other better function than NUMVAL ?

Thanks.
Back to top
View user's profile Send private message
ranjitbhingare

New User


Joined: 30 Nov 2005
Posts: 94
Location: PUNE

PostPosted: Wed Nov 01, 2006 3:57 pm
Reply with quote

Hi,

I do work with IBM and most of the time we use

IF WS-VARIABLE IS NUMERIC
STATEMENTS
END-IF.

Regards,

Ranjit
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Wed Nov 01, 2006 7:29 pm
Reply with quote

Hi There,

I also agree with Renjith we usually used IS NUMERIC
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Nov 01, 2006 10:13 pm
Reply with quote

If your source field only contains 0-9 and/or valid sign, the IF NUMERIC will work. But if your source field contains an edited numeric value (leading or trailing spaces, the IF NUMERIC will fail; if you need to extract valid numeric data from an alpha-numeric field, you have to use NUMVAL or NUMVAL-C
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 Moving Or setting POINTER to another ... COBOL Programming 2
No new posts Convert HEX to Numeric DB2 3
No new posts Panvalet - 9 Character name - Issue c... CA Products 6
No new posts Find a record count/numeric is multip... COBOL Programming 1
No new posts String has hex character need to conv... COBOL Programming 3
Search our Forums:

Back to Top