View previous topic :: View next topic
|
Author |
Message |
Ragav86
New User
Joined: 27 Jan 2010 Posts: 37 Location: chennai
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|