Intrinsic Functions


Intrinsic functions are built-in functions that facilitate various operations without the need for extensive procedural logic. These functions offer a range of functionalities, from mathematical computations to string manipulations.

A function can be coded by specifying its name along with required arguments in PROCEDURE DIVISION. The functions are grouped into six categories based on the type of purpose served. They are -

  • Mathematical
  • Statistical
  • Date and Time
  • Financial
  • Character Handling
  • General

Below list specifies the intrinsic functions -

  • ACOS
  • ADD-DURATION
  • ANNUITY
  • ASIN
  • ATAN
  • CHAR
  • CONVERT-DATE-TIME
  • COS
  • CURRENT-DATE
  • DATE-OF-INTEGER
  • DAY-OF-INTEGER
  • DAY-TO-YYYYDDD
  • EXTRACT-DATE-TIME
  • DATE-TO-YYYYMMDD
  • DISPLAY-OF
  • FACTORIAL
  • FIND-DURATION
  • INTEGER
  • INTEGER-OF-DATE
  • INTEGER-OF-DAY
  • INTEGER-PART
  • LENGTH
  • LOCALE-DATE
  • LOCALE-TIME
  • LOG
  • LOG10
  • LOWER-CASE
  • MAX
  • MEAN
  • MEDIAN
  • MIDRANGE
  • MIN
  • MOD
  • NATIONAL-OF
  • NUMVAL
  • NUMVAL-C
  • ORD
  • ORD-MAX
  • ORD-MIN
  • PRESENT-VALUE
  • RANDOM
  • RANGE
  • REM
  • REVERSE
  • SIN
  • SQRT
  • STANDARD-DEVIATION
  • SUBTRACT-DURATION
  • SUM
  • TAN
  • TEST-DATE-TIME
  • TRIM
  • TRIML
  • TRIMR
  • UPPER-CASE
  • VARIANCE
  • UTF8STRING
  • WHEN-COMPILED
  • YEAR-TO-YYYY

Examples -


Scenario1 - Converts a numeric edited string to a numeric value.

Code-  COMPUTE WS-NUM = FUNCTION NUMVAL('123.45')

Result-     WS-NUM = 123.45

Scenario2 - Returns the integer portion of a numeric value.

Code-  COMPUTE WS-INT-PART = FUNCTION INTEGER(123.45)

Result-     WS-INT-PART = 123

Scenario3 - Converts a string to upper case.

Code-  MOVE FUNCTION UPPER-CASE('hello') TO WS-UPPERCASE-STRING

Result-     WS-UPPERCASE-STRING = HELLO

Scenario4 - Reverses the characters in a string.

Code-  MOVE FUNCTION REVERSE('hello') TO WS-REVERSED-STRING

Result-     WS-REVERSED-STRING = olleh

Scenario5 - Returns the date and time the program was compiled.

Code-  MOVE FUNCTION WHEN-COMPILED TO COMPILE-TIME