VALIDVALUE

VALIDVALUE returns a value that indicates whether the value of an expression matches one of the elements in a variable's value set.

Read syntax diagramSkip visual syntax diagramVALIDVALUE( x, y)
x
A reference that must have the VALUELIST or VALUERANGE attribute.
y
An expression that is to be tested against the value set for x. If x has a computational type, then y must also have a computational type and will be converted, if necessary, to the same type as x;

If x has an ordinal type, then y must have the same ordinal type.

If y is omitted, it defaults to x. VALIDVALUE(x) is equivalent to VALIDVALUE(x,x).

VALIDVALUE returns a BIT(1) value '1'B if:
  • x has the VALUELIST attribute and its contents are one of the elements in that list.
  • x has the VALUERANGE attribute and its contents are within that range.
Otherwise, it returns '0'B.
If x has the VALUERANGE attribute , the VALIDVALUE test includes the two endpoint values. For example given the declare
dcl x  fixed dec(5) valuerange( 1900, 2100 );
the test
if validvalue( x ) then
is equivalent to
if (1900 <= x) & (x <= 2100) then