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

How to check the Numeric in Char field


IBM Mainframe Forums -> CA Products
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Ragav86

New User


Joined: 27 Jan 2010
Posts: 37
Location: chennai

PostPosted: Wed Mar 14, 2012 6:20 pm
Reply with quote

Hi how to check Numeric condition on char field.. can any one help this..

Code:

PARM      DEBUG (DMAP PMAP)       
FILE TEST                         
TEST1 1 3 A                       
*                                 
WS-DATA W 2 A                     
*                                 
WS-D   W 2 N                     
*                                 
JOB INPUT(NULL)                   
WS-DATA = '0 '                   
IF WS-DATA NUMERIC               
 DISPLAY WS-DATA ' NUMERIC'       
ELSE                             
 DISPLAY WS-DATA 'NOT NUERIC'     
END-IF                           
                                 
MOVE WS-DATA TO WS-D             
IF WS-DATA NUMERIC               
 DISPLAY WS-DATA ' NUMERIC'       
ELSE                             
 DISPLAY WS-DATA 'NOT NUERIC'     
END-IF                           


Output:
Code:

0 NOT NUERIC
0 NOT NUERIC
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Mar 14, 2012 8:57 pm
Reply with quote

There must be something I'm missing. You've already done it.

"0 " (zero followed by blank) is not NUMERIC. Your snippet displays "NOT NUMERIC" twice, as it should.

So, what is your problem?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Mar 14, 2012 9:15 pm
Reply with quote

Code:
DISPLAY WS-DATA ' NUMERIC'       
DISPLAY WS-DATA 'NOT NUERIC'


possibly Ragav86 has overlooked the fact that when NUMERIC is true
the literal has an embedded space,

whereas when
Quote:
NOT NUERIC
there is no leading space in the literal.

all things considered, you are correct Bill,
but
Code:

0 NOT NUERIC
0 NOT NUERIC


Ragav86 does not see two spaces, only one, and it is because his literals are not defined the same.

that and he misspelled numeric in the NOT literal.......
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Mar 14, 2012 9:25 pm
Reply with quote

Good spot dbz. I can't make any more sense of it than that...

Looking further, the second IF still tests the original field, not the place it has been MOVEd to.

MOVE in Easytrieve is an interesting sort of thing. If you do it at field level it does a MOVE without any conversion, as though both/all fields are defined as A. This can readily trip those used to the way MOVE works in Cobol.

Personally, for fields, I'd always use assignments (=) (other than when you need to use a MOVE :-) ).
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 -> CA Products

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top