Types of functions

The topic introduces types of functions in COBOL.

COBOL has the following types of functions:

  • Alphanumeric
  • Boolean
  • Date-time
  • DBCS
  • National
  • Numeric
  • Integer

Alphanumeric functions are of class and category alphanumeric. The value returned has an implicit usage of DISPLAY without the NATIVE phrase. The number of character positions in the value returned is determined by the function definition.

Boolean functions are of class and category boolean. The value returned has an implicit usage of DISPLAY, and is either a boolean true (B"1") or a boolean false (B"0").

Date-time functions are of the class date-time and category date, time, or timestamp. The value returned has an implicit usage of DISPLAY. The number of character positions in the value returned is determined by the function definition.

DBCS functions are of the class and category DBCS. The value returned has an implicit usage of DISPLAY-1, and the number of character positions in the value returned is determined by the function definition.

National functions are of class and category national. The value returned has an implicit usage of NATIONAL and is represented in national characters (UTF-16). The number of character positions in the value returned is determined by the function definition.

Numeric functions are of class and category numeric. The returned value is always considered to have an operational sign and is a numeric intermediate result. For more information, see Using numeric intrinsic functions in the COBOL for Linux® on x86 Programming Guide.

Integer functions are of class and category numeric. The returned value is always considered to have an operational sign and is an integer intermediate result. The number of digit positions in the value returned is determined by the function definition. For more information, see Using numeric intrinsic functions in the COBOL for Linux on x86 Programming Guide.