Calling a Function in WHEN Criteria

How to:

You can call a function in WHEN criteria as part of a Boolean expression.

Syntax: How to Call a Function in WHEN Criteria

WHEN({function|value} relation {function|value});

or

WHEN NOT(function)

where:

function

Is a function.

value

Is a value or logical expression.

relation

Is an operator that determines the relationship between the value and function, for example, LE or GT.

Example: Calling a Function in WHEN Criteria

This request checks the values in LAST_NAME against the result of the CHKFMT function. When a match occurs, the request prints a sort footing.

TABLE FILE EMPLOYEE
PRINT DEPARTMENT BY LAST_NAME
ON LAST_NAME SUBFOOT
"*** LAST NAME <LAST_NAME DOES MATCH MASK"
WHEN NOT CHKFMT(15, LAST_NAME, 'SMITH          ', 'I6');
END

The output is:

LAST_NAME        DEPARTMENT
---------        ----------
BANNING          PRODUCTION
BLACKWOOD        MIS
CROSS            MIS
GREENSPAN        MIS
IRVING           PRODUCTION
JONES            MIS
MCCOY            MIS
MCKNIGHT         PRODUCTION
ROMANS           PRODUCTION
SMITH            MIS
                 PRODUCTION
*** LAST NAME SMITH DOES MATCH MASK
STEVENS          PRODUCTION