COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

14 Intrinsic Functions
An intrinsic function is a function that your program can use, but does not need to declare. It returns
a value that is computed at the time of reference during the execution of the object program.
Like an identifier, an intrinsic function has a class and category, and you can use an intrinsic
function wherever you can use an identifier of the same class and category as a sending data
item. An intrinsic function call, which has the format
FUNCTION function_name (arguments)
is considered an identifier. For example, this is allowed:
MOVE FUNCTION NUMVAL (STRING-ITEM) TO NUM-ITEM.
You cannot use an intrinsic function as a receiving data item (in a CALL statement, for example).
(For explanations of class and category, see Data Levels, Classes, and Categories (page 77).)
Intrinsic Function Types
The type of an intrinsic function is the type of the value it returns. An intrinsic function can be:
Alphanumeric Intrinsic Functions
Numeric Intrinsic Functions
Integer Intrinsic Functions
Variable-Type Intrinsic Functions
You can use an integer function wherever you can use a numeric operand, but you cannot use a
numeric function where an integer operand is required, even if a particular reference to the numeric
function returns an integer value.
You can nest intrinsic functions; that is, you can use one intrinsic function as the argument of
another. The function that is used as the argument must be of the type required for that argument.
For example,
FUNCTION MAX ( FUNCTION INTEGER(X) FUNCTION INTEGER-PART(X) )
is allowed because the functions INTEGER and INTEGER-PART are integer functions and the function
MAX accepts integer arguments.
FUNCTION UPPER-CASE ( FUNCTION FACTORIAL(5) )
is not allowed because the function FACTORIAL is an integer function and the function UPPER-CASE
requires an alphanumeric argument.
Alphanumeric Intrinsic Functions
An alphanumeric intrinsic function returns an alphanumeric value (a string of one or more
alphanumeric characters).
Table 98 Alphanumeric Intrinsic Functions
Value ReturnedFunction Name
Character in specified position of program collating
sequence
CHAR Function
Current date and time and difference from Greenwich
mean time
CURRENT-DATE Function
Its argument with all letters set to lowercaseLOWER-CASE Function
Its argument with characters in reverse orderREVERSE Function
Intrinsic Function Types 655