Easytrieve Testing Functions

Testing functions guard the boundary between messy file data and trusted batch logic. Feed files from upstream systems contain blank social security fields, alphabetic characters in amount columns, and low-values placeholders where operators skipped entry. Arithmetic on corrupt packed fields aborts the job or worse—completes with wrong totals that finance discovers weeks later. Testing builtins classify field content before MOVE, ADD, or SUM: is this amount numeric, is this name blank, does this code contain only letters. When a test fails, IF branches route the record to EXCEPTION-FILE PRINT or increments ERROR-COUNT instead of poisoning running totals. Easytrieve Plus Application Reference groups these under testing or validation function indexes; classic Report Generator programs sometimes emulate tests with IF field EQ SPACES or explicit byte loops. This index explains testing categories, typical invocation in IF, interaction with LOW-VALUES and SPACES constants, data quality pipeline placement, performance on large files, and procedural fallbacks when your installation lacks a specific builtin name.

Progress0 of 0 lessons

Why Validate Before Process

Batch jobs imply trust: every record matches FILE layout. Reality violates trust daily. Optional fields arrive blank. Interface files pad numeric fields with spaces. Hex low-values mean uninitialized in one system and valid sentinel in another. Testing functions express business rules in one readable IF instead of twenty lines of byte inspection PROC. Fail fast on read—detect bad row before adding GROSS to DEPT-TOTAL. Operations teams prefer exception reports with row keys over ABEND codes requiring restart from top.

Numeric Class Tests

Numeric testing asks whether every byte in a field is a valid digit (and sign nibble for packed types) before ADD or MULTIPLY. Typical pattern: IF NOT NUMERIC-TEST(AMOUNT) PRINT BAD-NUM-RPT—exact function name from your manual. Without builtin, shops compare each byte or MOVE to test field with REDEFINES. Numeric test on display N field differs from packed P—define tests on the type actually read from file. Implied decimal does not affect digit validity; 999.99 storage still must be numeric nibbles throughout.

text
1
2
3
4
5
6
7
JOB INPUT INFILE IF NOT NUMERIC(AMOUNT) ERROR-CODE = 10 PRINT NUM-EXCEPTION ELSE DEPT-TOTAL = DEPT-TOTAL + AMOUNT END-IF

Alphabetic Class Tests

Name, address, and status code fields often require letters only—or alphanumeric without punctuation. Alphabetic test functions return false when digits or special characters appear. Use before concatenating names for mail merge output. Case sensitivity follows collating rules; test documentation for whether lowercase a-z allowed on your code page. Contrasts with numeric test: a field cannot pass both unless test definitions allow alphanumeric subset explicitly documented.

Blank and Empty Detection

Blank test treats spaces as empty—critical for A fields where SPACES fill unused length. IF BLANK(NAME) flags missing employee name on hire record. Distinguish blank from LOW-VALUES: hex 00 may not display as space but still fails business not-empty rule. Some manuals provide separate tests; others require IF NAME EQ SPACES OR NAME EQ LOW-VALUES. Document site convention in program header when both sentinels appear in feeds.

Testing function categories
CategoryQuestion answeredTypical IF action
Numeric testAre all digits valid?Route to numeric exception
Alphabetic testLetters only?Reject for manual correction
Blank testAll spaces or empty?Skip or flag mandatory field miss
Alphanumeric testAllowed character set?Validate codes before table lookup
Sign / range testWithin business bounds?Combine with GT LT after class passes

Combining Tests With Relational Operators

Class test first, range second: IF NUMERIC(AMT) AND AMT GT 0 AND AMT LT 999999.99. Short- circuit logic saves CPU when first failure skips expensive table lookup. NOT wraps test: IF NOT BLANK(REMARK) processes only rows with comment text. Avoid double negative without parentheses—IF NOT NOT NUMERIC is confusing in maintenance review.

Exception File Pattern

Define EXCEPTION-FILE in Library mirroring input layout plus ERROR-CODE field. On test failure, MOVE input record to exception buffer, set code, PUT or PRINT to exception. Good records continue main path. Reconciliation job counts ERROR-CODE frequencies for operations dashboard. Testing functions make IF condition readable; ERROR-CODE documents which test failed for support staff.

Testing Versus DEFINE Types

DEFINE type P declares intent that field holds packed decimal; testing verifies runtime content matches intent. Compiler cannot know upstream file corruption. Do not skip tests because FILE definition looks correct—interfaces change without notice. Conversely, passing numeric test does not guarantee business correctness—AMOUNT numeric but negative when policy requires positive still needs IF AMT LT 0 after class test.

Performance on Large Files

Per-record test cost is tiny versus READ. Testing every field on wide copybook records adds up—test only fields participating in math or mandatory output. Hoist invariant tests when field not used in inner loop. Million-row files still I/O bound; readable validation beats bare ADD that ABENDs hour three of batch window.

Procedural Fallbacks Without Builtins

  1. IF FIELD EQ SPACES for blank alphabetic detection.
  2. DO WHILE loop with INDEX over OCCURS 1 A inspecting each byte.
  3. MOVE to numeric work field inside IF NUMERIC-style PROC returning flag.
  4. CALL external validation routine when builtins missing on older compile level.

Common Testing Mistakes

  • Testing display field while file supplies packed—or reverse.
  • Assuming blank test trims trailing spaces on fixed fields automatically.
  • Skipping validation on trailer records assumed safe.
  • Using edited A field in numeric test after FORMAT corrupts class.
  • One ERROR-CODE for all failures—support cannot diagnose without distinct codes.
  • Testing after ADD already corrupted accumulator on bad row.

Explain It Like I'm Five

Testing functions are bouncers at a party. Before someone enters the dance floor for math games, the bouncer checks their ticket—is it a real number ticket, a name ticket, or empty? Wrong ticket goes to the help desk line instead of breaking the dance floor. Easytrieve uses bouncers so one bad ticket does not ruin everyone's counting game.

Exercises

  1. Write IF pseudocode routing non-numeric AMOUNT to exception before ADD.
  2. Explain blank versus LOW-VALUES on A 10 name field.
  3. Design ERROR-CODE values for numeric, blank, and range failures.
  4. Order tests for IF on AMOUNT: numeric, positive, under ceiling.
  5. Describe procedural fallback when NUMERIC builtin unavailable.

Quiz

Test Your Knowledge

1. Testing functions help you:

  • Validate field content before processing
  • Sort files faster
  • Allocate DD names
  • Compile macros

2. IF NOT NUMERIC on amount field before ADD prevents:

  • Arithmetic on non-digit characters
  • All file reads
  • REPORT titles
  • JCL execution

3. Blank testing on required name field:

  • Routes incomplete records to exception output
  • Always deletes records
  • Opens new file
  • Sets EOF

4. Testing functions versus IF field EQ LOW-VALUES:

  • Both can detect uninitialized or empty patterns—semantics differ
  • Identical always
  • LOW-VALUES illegal
  • Testing functions JCL only

5. Data quality pipelines use testing functions:

  • Early in JOB before calculations
  • Only after STOP
  • Only in SCREEN
  • Never in batch
Published
Read time15 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom EZT Plus testing function index; per-name verification requiredSources: Broadcom EZT Plus 6.3 Application Reference, Easytrieve data validation patternsApplies to: Easytrieve testing and validation built-in functions