Specifying a Function
The general format of a function-identifier is:
Format >>-FUNCTION--function-name-1--+----------------------+----------> | .------------. | | V | | '-(----argument-1-+--)-' >--+--------------------+-------------------------------------->< '-reference-modifier-'
- function-name-1
- Function-name-1 must be one of the Intrinsic Function names.
- argument-1
- Argument-1 must be an identifier, literal (other than a figurative constant), or arithmetic expression.
- reference-modifier
- Can be specified only for functions of the category alphanumeric or DBCS.
The following examples show an intrinsic function invocation for an alphanumeric source statement and a numeric source statement.
The alphanumeric source statement:
MOVE FUNCTION UPPER-CASE("hello") TO DATA-NAME.
replaces each lowercase letter in the argument with the corresponding
uppercase letter, resulting in the movement of HELLO into DATA-NAME.The numeric source statement,
COMPUTE NUM-ITEM = FUNCTION MEAN(A B C)
Adds the values of A, B, and C then divides by 3, and places the result
in NUM-ITEM.Within a Procedure Division statement, each function-identifier is evaluated at the same time as any reference modification or subscripting associated with an identifier in that same position would be evaluated.
