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.
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 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.
1234567JOB INPUT INFILE IF NOT NUMERIC(AMOUNT) ERROR-CODE = 10 PRINT NUM-EXCEPTION ELSE DEPT-TOTAL = DEPT-TOTAL + AMOUNT END-IF
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 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.
| Category | Question answered | Typical IF action |
|---|---|---|
| Numeric test | Are all digits valid? | Route to numeric exception |
| Alphabetic test | Letters only? | Reject for manual correction |
| Blank test | All spaces or empty? | Skip or flag mandatory field miss |
| Alphanumeric test | Allowed character set? | Validate codes before table lookup |
| Sign / range test | Within business bounds? | Combine with GT LT after class passes |
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.
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.
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.
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.
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.
1. Testing functions help you:
2. IF NOT NUMERIC on amount field before ADD prevents:
3. Blank testing on required name field:
4. Testing functions versus IF field EQ LOW-VALUES:
5. Data quality pipelines use testing functions: