Easytrieve Function Cheat Sheet

Built-in functions compute values inside expressions—format dates for titles, take absolute differences, test field content, or read system information. Unlike MOVE or IF standing alone, functions nest inside assignment and condition lines. This cheat sheet groups functions by category with typical usage patterns and notes on Report Generator versus Easytrieve Plus availability. Names vary by release; pilot compile on your LPAR before embedding in production. When a function is missing, use category tutorial fallback patterns (overlay, INDEX, PROC). Cross-link to function-categories index and per-category pages for depth beyond this quick table.

Progress0 of 0 lessons

Invocation Pattern

Functions take arguments in parentheses. Arguments may be fields, literals, or nested expressions. Result type must fit target field in assignment. Mismatch causes compile diagnostics or truncation. Some functions are niladic—no arguments—like current date helpers referencing system context.

text
1
2
3
4
5
WS-TODAY = DATE-FUNCTION() IF ABS(VAR-A - VAR-B) GT TOLERANCE DISPLAY 'VARIANCE' END-IF WS-EDITED = EDIT(NUM-FIELD, 'ZZ,ZZ9.99')

String Functions

String functions manipulate alphanumeric fields—length, trim, scan, substring where available. Classic Easytrieve without rich builtins uses DEFINE overlay subfields and INDEX loops; modern Plus catalogs add more direct calls. Always check length limits—eight-character targets truncate.

String family (representative—verify release)
Function / patternPurpose
INDEX / scan loopsFind character position in string
Overlay subfieldsReference portion of field without copy
TRIM / pad helpersRemove spaces or pad to length (Plus)
SUBSTR / segmentExtract substring when in catalog

Date and Time Functions

Date functions support report headers, age calculations, and period filters. SYSDATE system field often supplements functions for current date. Packed and display date formats need consistent masks—document internal format in comments. Calendar edge cases (leap year, month-end) deserve unit tests on test LPAR.

Date family
ItemPurpose
SYSDATE / SYSTIMESystem date and time fields (not functions but paired use)
Date extractionYear, month, day from date field
Date arithmeticAdd days or months per catalog macros/functions
%DATECALC macroMacro alternative on some releases

Numeric and Math Functions

Numeric family
FunctionPurpose
ABSAbsolute value
MAX / MINLarger or smaller of values
MOD / remainder patternsDivision remainder for grouping
SQRT / powerAdvanced math where documented (Plus)

Conversion and Formatting

Conversion changes representation—numeric to character, packed to zoned. Formatting applies EDIT masks for human-readable output without changing stored value semantics. Report LINE masks overlap formatting functions—choose one consistent approach per program.

Conversion and formatting
PatternPurpose
EDIT(field, mask)Picture edit for display
Numeric to alphaConvert for concatenated messages
Alpha to numericParse digits when validated first

Testing Functions

Testing family
PatternPurpose
Numeric testVerify field contains digits
Alpha testVerify alphabetic content
SPACES testBlank field detection in IF

File and System Functions

File and system
ItemPurpose
File status helpersQuery open or EOF state per release
SYSUSERID / environmentJob user context for audit footers
RUN date / timeBatch run timestamp in headers

Report Functions

Report writer may expose functions for page number, line count, or break level in TITLE and LINE expressions—consult report functions tutorial. Mixing report functions with batch FILE logic in same PROC requires knowing when report engine context is active.

Category Index Links

Tutorial paths by category
CategoryTutorial path
String/functions/string
Date/functions/date
Numeric/functions/numeric
Math/functions/math
Conversion/functions/conversion
Formatting/functions/formatting
Testing/functions/testing
File/functions/file
System/functions/system
Report/functions/report

Fallback When Function Missing

  1. Check Application Reference for alternate name or macro.
  2. Use PROC loop with INDEX for string scan.
  3. Use DEFINE overlay for substring extract.
  4. Use EDIT masks on REPORT LINE for display.
  5. CALL external routine if policy allows.

Common Function Mistakes

  • Assuming Plus catalog on Report Generator compile.
  • Wrong argument type—alpha where numeric required.
  • Ignoring truncated assignment target length.
  • Date format mismatch between function result and compare field.
  • Using function where statement required or vice versa.

Explain It Like I'm Five

Functions are mini-calculators inside your sentence. Instead of writing ten steps to get today's date on the report, a date function gives you the date in one piece. The cheat sheet lists which calculators exist for strings, numbers, and dates—your school may have a smaller calculator than another school, so try on your computer before the big test.

Exercises

  1. Write assignment using ABS on variance field pseudocode.
  2. Pick category for formatting dollar amounts on report.
  3. Document pilot compile steps for one undocumented function name.
  4. Describe overlay fallback for substring when SUBSTR absent.
  5. Map five tasks to function categories from this sheet.

Quiz

Test Your Knowledge

1. Built-in functions are used inside:

  • Expressions on assignment or IF lines
  • JCL DD statements only
  • REPORT FILE clause only
  • Macro definitions only

2. Date functions typically help with:

  • Current date, extraction, and calendar arithmetic
  • VSAM key definition
  • Sort keys only
  • JCL CLASS

3. Function availability depends on:

  • Product level and release maintenance
  • TSO user ID only
  • LRECL size
  • BLOCK size only

4. When no substring function exists, classic pattern uses:

  • Field overlay and INDEX with OCCURS
  • SQL only
  • Cannot parse strings
  • STOP statement

5. ABS and MAX belong to:

  • Numeric or math function families
  • File functions
  • JCL parameters
  • SCREEN maps
Published
Read time17 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve function categories and Application Reference patternsSources: Broadcom Easytrieve 11.6 and Plus Application Reference function indexesApplies to: Easytrieve built-in function quick reference