Key Takeaways: Intrinsic Functions

  1. All intrinsic functions require the FUNCTION keyword unless FUNCTION ALL INTRINSIC is declared in the REPOSITORY paragraph. Functions are pure — they return values without modifying arguments.

  2. String functions (LENGTH, UPPER-CASE, LOWER-CASE, TRIM, REVERSE) are essential for data cleansing and case-insensitive comparisons. LENGTH returns allocated size, not content length — use TRIM first for content length.

  3. NUMVAL and NUMVAL-C convert alphanumeric to numeric but abend on invalid input. Always use TEST-NUMVAL or TEST-NUMVAL-C first for defensive validation.

  4. Statistical functions (MEAN, MEDIAN, VARIANCE, STANDARD-DEVIATION, MIN, MAX, RANGE, SUM) are built-in capabilities that most other procedural languages lack. They eliminate hand-coded accumulator patterns.

  5. ORD-MAX and ORD-MIN return positions, not values — essential when you need to know WHICH element is highest/lowest, not just the value.

  6. The ALL subscript with statistical functions processes every declared table entry. For partially loaded tables, this produces incorrect results. Use explicit loops for partial tables.

  7. Date functions (CURRENT-DATE, INTEGER-OF-DATE, DATE-OF-INTEGER) enable correct date arithmetic without hand-coded calendar logic. They handle leap years, month lengths, and century boundaries correctly.

  8. Financial functions (PRESENT-VALUE, ANNUITY) directly support loan, investment, and insurance calculations. ANNUITY returns a ratio — multiply by principal to get the periodic payment.

  9. Functions can be nested for powerful patterns: FUNCTION UPPER-CASE(FUNCTION TRIM(ws-input TRAILING)) combines trimming and case conversion in a single expression.

  10. Legacy != Obsolete: COBOL's intrinsic function library, expanded in 1989, 2002, and 2014, provides domain-specific capabilities that rival or exceed many modern languages for business computing.