Purpose
Returns TRUE or FALSE to indicate whether an alphanumeric field is a valid candidate for a MOVE to a numeric field or can be used in a computation without a data exception occurring.
Syntax
►►──── NUMERIC ( value ) ─────────────────────────────────────────────────────►◄
Parameters
An alphanumeric value tested by the function.
Value can be:
Usage
For EBCDIC or group values, NUMERIC checks the field in isolation, without regard to possible target fields of a move or computation. For example, '999999' will test as a numeric field (TRUE), but an error would occur if this were moved to a field with the picture of 9(4) COMP-3.
NUMERIC does not support validation of floating point numbers.
Because CA ADS and EVAL do not check the DECIMAL POINT IS clause of the OLM SYSGEN statement, NUMERIC does not either. Therefore, a period (.) and a comma (,) will always be the decimal point and the thousands separator respectively.
The types of fields tested for numeric and the tests applied to those fields are:
|
Field data type |
Test NUMERIC applies |
|---|---|
|
Binary |
Always returns a TRUE value. |
|
Packed decimal |
Follows the IBM standard for what a packed field should contain; and additionally checks for a maximum field length of 16 bytes. |
|
Zoned decimal |
Follows the IBM standard for what a zoned decimal field should contain; and additionally checks for a maximum field length of 31 bytes. |
|
EBCDIC or group values |
One of the following must be true:
|
|
All other types |
Returns a FALSE value. |
In general, a single number embedded in an EBCDIC field that may contain a leading sign is considered NUMERIC.
The table below shows valid and invalid examples of NUMERIC values:
|
Valid examples |
Invalid examples |
|---|---|
|
3 |
. |
|
4.4 |
-+4 |
|
+6 |
.5. |
|
.5 |
- . 6 |
|
-9 |
|
Example
In the following example, NUMERIC tests whether MYALPHANUM contains a valid number:
IF (NUMERIC(MYALPHANUM)) THEN
CALL NUMCALC.
ELSE
CALL NUMERROR.
Initial value of MYALPHANUM: 123
Statement evaluates TRUE.
Initial value of MYALPHANUM: M123
Statement evaluates FALSE.
|
Copyright © 2014 CA.
All rights reserved.
|
|