Easytrieve Built-in Functions Overview

Built-in functions extend Easytrieve expressions beyond simple field arithmetic. Instead of coding ten lines of PROC logic to format today's date for a report header, a date function may return a ready-made value in one assignment. Instead of walking a string byte by byte with INDEX loops, a substring or scan function—where your release provides it—may extract the token you need. Functions are not statements on their own; they appear inside expressions on assignment lines, IF conditions, and some report edit contexts. Broadcom documents function catalogs primarily in Easytrieve Plus Application Reference indexes, while Report Generator sites may expose a smaller subset. Beginners migrating from COBOL INSPECT or SQL SUBSTR expect one universal function list—production reality requires checking your installation manual before assuming a name exists. This overview explains invocation syntax, major function categories, type and performance considerations, fallback patterns when no function fits, and how per-function tutorial pages in this section deepen each family.

Progress0 of 0 lessons

Functions Versus Statements

Statements drive program flow—JOB INPUT, IF, PRINT, FILE. Functions compute values within expressions. NET = GROSS - TAX uses arithmetic operators only. HEADER-DATE = DATE-FUNC() uses a function call on the right side—exact function name and parentheses syntax depend on your release documentation. You cannot typically place a bare function call as its own top-level statement line unless grammar defines it as a callable form. Think of functions as vocabulary inside formulas, not as standalone job steps.

text
1
2
3
4
5
6
7
* Assignment using a function result (names vary by release) WS-TODAY = $DATE WS-ABS-AMT = ABS(VARIANCE) IF ABS(DELTA) GT TOLERANCE PRINT EXCEPTION-RPT END-IF

General Invocation Pattern

Most built-ins follow function-name open-paren argument-list close-paren. Some vendors prefix function names with dollar sign or other sigils in Plus documentation—verify literal spelling in your manual; do not guess from other languages. Arguments may be fields, literals, or nested expressions. Return type must fit the receiving field on assignment— assigning a long formatted string into A 8 truncates or errors per rules. Nested calls ABS(MAX(A,B)) are valid when inner return type satisfies outer parameter requirements.

Function use contexts
ContextExample patternNotes
AssignmentTARGET = FUNC(source)Store function result
IF conditionIF FUNC(x) EQ yBranch on computed value
Nested expressionNET = A + FUNC(B)Combine with operators
Report editVaries by releaseConfirm REPORT grammar

Function Categories

Broadcom and legacy CA manuals group built-ins by purpose. This tutorial section mirrors those families with dedicated index pages and eventual per-function depth. Use the category index when you know the task—format a date, test numeric sign, pad a string—not the function name yet.

Major built-in function families
CategoryTypical tasksTutorial index
StringSubstring, length, trim, scan, concatenate/functions/string
DateCurrent date, extract day/month/year, date math/functions/date
NumericABS, sign, min/max, rounding helpers/functions/numeric
MathSQRT, power, logarithm where documented/functions/math
ConversionType conversion, packed to display, radix/functions/conversion
FormattingEDIT masks, picture strings for output/functions/formatting
TestingNumeric class tests, blank detection/functions/testing
FileFile status, name, sequence helpers/functions/file
SystemTime, user, job environment values/functions/system
ReportPage number, line count, report writer aids/functions/report

String Functions

String functions manipulate alphabetic and alphanumeric fields—extract segments, find delimiters, measure length, or pad for output. Availability varies: classic Report Generator code often uses INDEX with OCCURS 1 A and overlay fields instead of a SUBSTR function. Easytrieve Plus adds richer string builtins documented in Application Reference. When a function exists, prefer it for readability over ten-line INDEX loops. When it does not, procedural string handling remains the portable pattern. Watch fixed-length padding: functions may not trim trailing spaces unless documented—compare results against business rules on A fields.

Date and Time Functions

Date functions return current system date, extract components, or convert between internal packed layouts and display formats. Payroll and billing jobs use them for cycle headers, age calculations, and cutoff comparisons when DATE fields align formats before relational operators apply. Time functions complement batch timestamps in audit trails. Always match internal representation—CCYYMMDD character, packed Julian, or numeric month-day-year—between function output and Library DEFINE types. Mixing formats causes silent wrong comparisons in IF EFF-DATE GT CUTOFF even when function output looks correct on PRINT.

text
1
2
3
4
5
* Illustrative date header pattern (function names per your manual) RPT-DATE = $DATE RPT-TIME = $TIME TITLE 'PAYROLL REGISTER AS OF ' RPT-DATE

Numeric and Math Functions

ABS returns absolute value—common for variance checks IF ABS(ACTUAL - BUDGET) GT LIMIT. MIN and MAX select extremes across arguments or field pairs. Sign tests complement relational operators on negative amounts. Math functions—square root, logarithm—appear in statistical or scientific batch jobs less often than payroll, but documentation lists them for Plus installations. Implied decimal scales propagate: ABS on P 2 currency stays monetary scale. Assign function results into fields with matching precision to avoid truncation.

Conversion and Formatting Functions

Conversion functions translate between data types—packed to zoned, binary to display, character digits to numeric—without manual PROC nibble logic. Formatting functions apply edit masks similar to COBOL PIC clauses for human-readable SYSPRINT or report columns. EDIT and mask parameters vary by release; copy examples from your manual rather than from other sites. Conversion errors surface at compile time when argument types mismatch; runtime errors appear when source data contains non-numeric characters in supposedly numeric fields.

Testing and Validation Functions

Testing functions classify field content—is numeric, is alphabetic, is blank—before MOVE or arithmetic. Validation jobs gate processing: IF NOT NUMERIC-FUNC(INPUT-FLD) skip bad records to exception file. Combine with NE and EQ filters for data quality pipelines feeding downstream systems. Do not assume every site documents the same test function names—grep your Application Reference index for NUMERIC, ALPHA, or BLANK entries.

File, System, and Report Functions

File functions expose runtime file status or metadata—useful in error PROCs after READ failures. System functions return job name, step information, or environment values for audit headers. Report functions supply page numbers, line counts, or report writer state inside TITLE or LINE expressions. These tie Easytrieve batch output to operational context without hard-coding literals that change every run.

When No Built-in Exists

Easytrieve predates modern string libraries. Portable fallback patterns include: overlay fields in Library for substring views; INDEX with OCCURS for byte walks; DO WHILE loops for delimiter parsing; arithmetic for date math when date functions unavailable; EDIT masks for display without separate format function. Document fallback in comments when function availability differs between dev and prod releases. Consider EZT Plus upgrade when maintainers spend more time reimplementing builtins than writing business logic.

Performance Considerations

Function call cost is usually small versus file I/O. Calling functions inside tight loops on millions of records still adds up—hoist invariant calls outside loops when possible. WS-TODAY = DATE-FUNC once per job beats per-record date retrieval for headers. Nested string functions on long fields cost more than simple numeric ABS—profile hot paths if runtime exceeds batch window. Correctness beats micro-optimization: wrong format function wastes more operator time than a few extra CPU microseconds.

Version and Installation Checks

  1. Locate Application Reference function index for your product level.
  2. Compile one-line test program calling the function before production use.
  3. Verify return type fits target DEFINE field length and type.
  4. Compare function output against known manual examples.
  5. Document function name and release in program header comment.

Common Built-in Function Mistakes

  • Assuming COBOL or SQL function names exist in Easytrieve unchanged.
  • Wrong argument count or type per manual—compile errors or garbage results.
  • Assigning formatted date string into numeric date field without conversion.
  • Calling per record when once-per-job suffices.
  • Ignoring trailing spaces on alphabetic function results.
  • Using Plus-only functions on Report Generator-only compile site.

Explain It Like I'm Five

Built-in functions are tools the language already knows how to use. You ask for today's date and it hands you the answer instead of you counting calendars on your fingers. You ask how long a word is and it tells you the length instead of you spelling it on blocks one by one. Not every toolbox has every tool—your school might have crayons but not glitter glue. Check which tools your Easytrieve has in its manual before you plan a craft project.

Exercises

  1. List three function categories and one task each handles.
  2. Write pseudocode assigning a date function result to a header field.
  3. Explain difference between a function and a MOVE statement.
  4. Describe fallback when SUBSTR function is unavailable on your site.
  5. Identify one function you would call once per job versus per record and why.

Quiz

Test Your Knowledge

1. Built-in functions in Easytrieve are invoked:

  • Inside expressions on assignment or IF lines
  • Only in JCL
  • Only in REPORT TITLE
  • Only at compile time

2. Easytrieve Plus function catalog differs from base Report Generator because:

  • Plus extends the function library per release documentation
  • They are identical always
  • Functions exist only on Linux
  • Functions replace FILE statements

3. DATE-related built-ins typically return or accept:

  • Formatted or packed date values per function
  • JCL job names
  • DD statement lengths
  • Sort keys only

4. When no built-in exists for a string need, Easytrieve often uses:

  • Field overlay, INDEX with OCCURS, or procedural loops
  • SQL only
  • COBOL CALL always
  • Cannot process strings

5. Function argument types must:

  • Match documented parameter types or convert per rules
  • Always be alphabetic
  • Always be packed
  • Be omitted
Published
Read time17 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve Plus Application Reference function index; Report Generator subset varies by siteSources: Broadcom EZT Plus 6.3 Application Reference, Easytrieve Report Generator 11.6 Programming GuideApplies to: Easytrieve built-in function invocation and categories