Customer master data—names, addresses, credit terms, tax flags, contact preferences—feeds billing, collections, marketing mail, and regulatory reporting. When data stewards submit changes from web portals, branch forms, or vendor feeds, batch Easytrieve jobs validate transactions and produce updated master generations with audit trails. Unlike read-only report jobs, master update projects read change files, match on customer id, apply ADD CHANGE DELETE logic, reject invalid rows, and write new master output consumed by invoice generation and statement jobs later the same night. This tutorial explains change file layouts, merge-apply algorithms, validation modules, exception handling, audit history files, sequential versus VSAM update strategies, and control counts operations use before swapping production master.
1234567891011FILE CHGTRAN ACTION-CODE 1 A CUST-ID 9 NUM CUST-NAME 30 A ADDR-LINE1 30 A ADDR-LINE2 30 A CITY 20 A STATE-CODE 2 A ZIP-CODE 9 A CHG-DATE 8 NUM CHG-USER 8 A
ACTION-CODE values: A add, C change, D delete—document exact codes in header comment. CUST-ID is match key to master. Change file may carry full record image on change or partial fields with overlay semantics—shop standard must define whether blank ADDR-LINE2 means clear field or leave unchanged.
| Code | Meaning | Typical behavior |
|---|---|---|
| A | Add new customer | Insert if CUST-ID not in master; else exception duplicate |
| C | Change existing | Update fields if CUST-ID found; else exception not found |
| D | Delete / deactivate | Mark inactive flag or omit from new master per policy |
| R | Reactivate (if used) | Clear inactive flag on previously deleted customer |
Classic pattern: SORT master and changes by CUST-ID. Single pass merge: read master and change in lockstep comparing keys. When keys equal, apply change to master buffer and WRITE new master row. When change key lower, process add. When master key lower, copy master unchanged. Requires careful EOF handling on both files in JOB or two-step design with indexed lookup.
1234567891011121314JOB INPUT CHGTRAN PERFORM VALIDATE-CHANGE IF W-ERROR-FLAG EQ 'Y' PERFORM WRITE-EXCEPTION GOTO JOB END-IF IF ACTION-CODE EQ 'A' PERFORM PROCESS-ADD ELSE IF ACTION-CODE EQ 'C' PERFORM PROCESS-CHANGE ELSE IF ACTION-CODE EQ 'D' PERFORM PROCESS-DELETE END-IF W-APPLY-CNT = W-APPLY-CNT + 1
Alternative: random READ master by CUST-ID for each change when master is VSAM KSDS—simpler logic, heavier I/O. Batch rewrite sequential generation suits nightly volume with full backup.
123456789101112131415161718VALIDATE-CHANGE. PROC W-ERROR-FLAG = 'N' IF CUST-ID EQ ZEROES W-ERROR-FLAG = 'Y' W-ERROR-MSG = 'MISSING CUST ID' END-IF IF ACTION-CODE EQ 'A' AND CUST-NAME EQ SPACES W-ERROR-FLAG = 'Y' W-ERROR-MSG = 'NAME REQUIRED ON ADD' END-IF IF STATE-CODE NE SPACES SEARCH STATETAB WITH STATE-CODE GIVING ST-NAME IF NOT STATETAB W-ERROR-FLAG = 'Y' W-ERROR-MSG = 'INVALID STATE' END-IF END-IF END-PROC
Write AUDIT-FILE row on every applied change: CUST-ID, ACTION-CODE, CHG-DATE, CHG-USER, key fields before and after when policy requires field-level history. Audit file append-only GDG supports compliance queries. Separate from exception file which captures rejected transactions only.
Regulatory and AR policy often forbids physical delete. PROCESS-DELETE sets INACTIVE-FLAG Y and INACTIVE-DATE rather than omitting record from new master. Invoice jobs filter IF INACTIVE-FLAG NE Y. Hard delete reserved for test environments or GDPR programs with legal approval and documented retention destruction.
Operations backs up current master before swap. New generation renamed or repro loaded to VSAM only after control report sign-off. Rollback plan restores backup generation if downstream billing job fails.
12345678//CUSTUPD EXEC PGM=EZTPA00,REGION=0M //SYSPRINT DD SYSOUT=* //SYSIN DD DSN=MDM.LIB(EZTCUSTU),DISP=SHR //OLDMAST DD DSN=CUST.MASTER.CURRENT,DISP=SHR //CHGTRAN DD DSN=CUST.CHANGES(+1),DISP=SHR //NEWMAST DD DSN=CUST.MASTER.NEW(+1),DISP=(,CATLG,DELETE) //AUDIT DD DSN=CUST.AUDIT(+1),DISP=(,CATLG,DELETE) //EXCEPT DD DSN=CUST.CHNG.EXCEPT(+1),DISP=(,CATLG,DELETE)
Scheduler dependency: CUSTUPD completes before INVGEN and STMTGEN. Master refresh late in window may delay billing—monitor W-EXCEPT-CNT threshold that blocks swap when too many errors indicate bad vendor feed. Staged validation environment applies same job against copy master before production feed.
Customer master update is like keeping the class phone book current. Friends bring notes saying add this person, fix that address, or remove someone who moved away. Easytrieve checks each note makes sense, updates the phone book, and keeps a diary of every change. If a note is messy, it goes on the ask-the-teacher list instead of ruining the whole book.
1. Customer master update jobs typically read:
2. Action code ADD when customer already exists should:
3. Master update audit trail records:
4. Sequential master rewrite pattern writes:
5. Validation on address change often checks: