Bad data costs more than missing data. A trailer count off by one stops payment files. Duplicate claim numbers double-pay. Invalid product codes silently bucket revenue into unknown. Data validation projects exist to catch those problems before production masters and warehouses absorb them. Easytrieve is a strong fit: sequential reads, TABLE lookups, control break summaries on error types, exception reports business users actually read, and ERROR-FILE layouts partners reprocess. This tutorial covers standalone validation jobs, inline validation gates in ETL, balance and hash controls, duplicate detection patterns, JCL sequencing with COND codes, service level agreements with external file senders, and audit documentation regulators expect. Implementation reuses validation and error-handling frameworks from design patterns—this page shows how those frameworks assemble into production validation portfolios scheduled every morning before the business day starts.
12345678910111213141516171819202122JOB PERFORM INIT-VALIDATE JOB INPUT PARTNER-FILE ADD 1 TO READ-COUNT PERFORM VALIDATE-RECORD IF VAL-STATUS NE ZERO PERFORM HANDLE-VALIDATION-ERROR ELSE WRITE CLEAN-FILE ADD 1 TO OK-COUNT END-IF END-JOB REPORT VALIDATION-EXCEPTIONS JOB INPUT ERROR-FILE CONTROL ERROR-CODE LINE ERR-KEY ERR-CODE ERR-MSG END-REPORT PERFORM TERM-VALIDATE STOP
CLEAN-FILE feeds downstream load only when OK-COUNT positive and trailer checks pass. ERROR-FILE drives exception REPORT grouped by ERROR-CODE for analyst triage. INIT-VALIDATE loads TABLE rules effective today—rate tables, valid code lists.
| Category | Examples | Typical severity |
|---|---|---|
| Format | Numeric fields, date calendar, field length | Record reject |
| Referential | Account exists, product active | Record reject |
| Business | Amount within limit, status transition valid | Record reject |
| Control | Trailer count, hash total, batch balance | Hard stop |
| Duplicate | Same key twice in file | Record or file reject |
After detail loop, PERFORM VALIDATE-TRAILER compares accumulated AMOUNT-SUM to trailer field from last record or separate trailer READ. Count validation compares READ-COUNT to header expected count when provided. Mismatch sets severity 4—STOP before CLEAN-FILE released to load JCL. Document penny tolerance if floating rounding differs—usually zero tolerance for money on mainframe integer arithmetic.
123456789101112VALIDATE-TRAILER. PROC IF READ-COUNT NE HDR-REC-COUNT MOVE 80 TO VAL-STATUS PERFORM LOG-FATAL STOP END-IF IF AMOUNT-SUM NE TRL-AMOUNT MOVE 81 TO VAL-STATUS PERFORM LOG-FATAL STOP END-IF END-PROC
Sequential duplicate keys: compare current key to SAVE-KEY; if equal set duplicate error. Full-file duplicate detection requires SORT on key then JOB INPUT with CONTROL or compare adjacent records. Choose pattern based on partner SLA—within-file duplicates only versus database uniqueness simulation.
1234//STEP10 EXEC PGM=EZTPA00,REGION=0M // DD ... PARTNER file //STEP20 EXEC PGM=EZTPA00,REGION=0M,COND=(0,NE,STEP10) // DD ... LOAD uses CLEAN from STEP10
Load step runs only when validation return code zero. Some shops also test ERROR-FILE empty with IDCAMS or separate Easytrieve COUNT job. Document RC meanings in run book—RC 4 warning with rejects, RC 8 fatal trailer failure.
Validation jobs enforce contractual data quality: file must arrive by 06:00, trailer mandatory, maximum reject rate 0.1 percent. TERM-VALIDATE DISPLAY reject percentage; IF over threshold STOP and page on-call. ERROR-FILE returned to partner through secure transfer completes feedback loop. Track error code trends weekly—rising code 41 means master sync problem not partner typo.
REPORT VALIDATION-EXCEPTIONS uses CONTROL ERROR-CODE so analysts see sections per failure type. LINE includes record key, message, snippet of offending field. TITLE carries partner name and run date from reusable report framework. Limit detail lines per code if volume huge—summary LINE with COUNT per code in AFTER-BREAK plus sample first ten keys.
| Approach | When to use |
|---|---|
| Standalone validation step | Multiple downstream consumers need same CLEAN-FILE |
| Inline in ETL | Single load target, simpler JCL |
| Standalone for partner only | External SLA and reject return required |
Log READ-COUNT OK-COUNT ERR-COUNT to immutable audit file with timestamp and program version. Exception REPORT PDF archived to document management. Validation rules versioned in Library with change ticket reference in INIT DISPLAY. Regulators ask prove what rules applied on trade date—version stamp answers.
Before groceries go in the fridge, someone checks the delivery: eggs not cracked, list matches the receipt, nothing expired. Bad items go back to the store list. Data validation is that check for computer files. The fridge only opens when the good groceries pass—downstream load step is the fridge.
1. Standalone validation jobs typically:
2. Balance control validation compares:
3. Partner file validation often runs:
4. Exception report in validation project:
5. Reprocess workflow reads: