Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

General

Function-name

Each intrinsic function has a name that the programmer uses to address it. A function-name is a key word from a special list of COBOL words and is a necessary part of the function-identifier. Outside the function-identifier context, a key word can also be used as a user-defined word.

Returned value of a function

Each function that executes successfully returns a function result, the returned value. To determine the returned value, the function processes the data values supplied by the arguments specified in the function-identifier.
The function result is defined

  • by the length of the returned value in alphanumeric and national functions,

  • by the sign of the returned value, or by the integer in the case of numeric and integer functions,

  • or, in all remaining cases, by the returned value itself.

For the arguments particular rules apply: data type, number, length and value range of the arguments are determined by the definition of the function. The function returns a defined returned value only if these rules are observed.

Error default value

If a function is supplied with an invalid argument, the function result is undefined. A compiler option can be used in such cases to check the argument values and assign the function the error default value that indicates that the function has not executed successfully. A further compiler option can be used to ensure that the error is reported at run time (error messages COB9123 - COB9128). Refer to the "COBOL2000 User Guide" [1] for further information.

Date conversion

The Gregorian calendar is used in the date conversion functions.
The start date of Monday 1, January 1601 was selected to establish a simple relationship between the standard date and DAY-OF-WEEK; in other words, the integer date form 1 was a Monday, DAY-OF-WEEK 1.

Arguments

Arguments specify the values used when executing a function. The arguments are specified in the function-identifier (see section "Function-identifier") as identifiers, arithmetic expressions, or literals. The format description of each function indicates the number of arguments required (zero, one or more). For some functions the number of arguments can be variable.

Arguments belong to a particular data class or to a subset of a data class. There are the following argument types:

  • Numeric. An arithmetic expression must be specified. The value of the arithmetic expression, including the sign, is used to determine the function value.

  • Alphabetic. A data item of class alphabetic or an alphanumeric literal comprising exclusively alphabetic characters must be specified. The length of the argument can be used to determine the function value.

  • Alphanumeric. A data item of class alphabetic or alphanumeric or an alphanumeric literal must be specified. The length of the argument can be used to determine the function value.

  • National. A national data item or a national literal must be specified.The length of the argument can be used to determine the function value.

  • Integer. An arithmetic expression that always produces an integer value must be specified. The value of the arithmetic expression, including sign, is used to determine the function value.

  • Of class "object“.

  • Of class "pointer".

  • Type declaration.

  • Index. A data item with USAGE INDEX must be specified.

A table can be referenced if the format of a function permits argument repetition. Reference is made by specifying the data-name and any identifiers for the table, followed directly by subscription in which one or more subscripts is the word ALL.
If ALL is specified as a subscript, it has the same effect as specifying each table element at this subscript position.

Example

ALL subscripts in a three-dimensional table with ten items in each dimension.

FUNCTION MAX (TAB(ALL 2 ALL))

is the same as

FUNCTION MAX (TAB(1 2 1) TAB (1 2 2) ... TAB(1 2 10)
              TAB(2 2 1) TAB (2 2 2) ... TAB(2 2 10)
              .
              .
              TAB(10 2 1) TAB (10 2 2) ... TAB(10 2 10))

If the ALL subscript is linked with an OCCURS DEPENDING ON clause, the value range is determined by the object of the OCCURS DEPENDING ON clause. This object must be greater than zero at the time of evaluation of the arguments. If an argument subscripted with ALL is reference-modified, the reference-modifier refers to each implicitly referenced table item.

Function types

Functions are elementary data items. They return alphanumeric, national, numeric or index values, and cannot be receiving operands. There are the following types of function:

  • Alphanumeric functions. They belong to class and category alphanumeric.
    Alphanumeric functions have implicit USAGE DISPLAY.

  • National functions. They belong to class and category national.
    National functions have implicit USAGE NATIONAL.

  • Numeric functions. They belong to class and category numeric.
    A numeric function is always treated as signed.
    A numeric function can be used only in an arithmetic expression.
    A numeric function must not be referenced if an integer operand is required, even if evaluation of the function results in an integer value.

  • Integer functions. They belong to class and category "numeric".
    An integer function is always treated as signed.
    An integer function may be used only in an arithmetic expression.

  • Index functions. They belong to class and category index.