Easytrieve Replacing Records

Not every file change is a READ-WRITE on one employee row. Month-end sometimes replaces an entire extract: new sequential file, new GDG generation, or reloaded VSAM cluster built from authoritative source. Replacing records in Easytrieve means mass output—JOB INPUT the golden source, transform if needed, PUT or WRITE to CREATE output until EOF, verify counts, then operations swaps the dataset in catalog or JCL PROC. In-place update tutorials cover keyed maintenance; this page covers full refresh semantics, when replace beats update, backup and reconciliation discipline, sequential versus KSDS reload paths, SORT-before-reload ordering, FILE-STATUS on every PUT, and coordination with IDCAMS REPRO when Easytrieve is extract only. Beginners who PUT to DISP=OLD production without backup learn painful lessons—treat replace jobs as production change events, not casual report runs.

Progress0 of 0 lessons

Replace Versus Update Versus Append

File maintenance strategies
StrategyScopeTypical verbs
UpdateOne or few existing rowsREAD, MOVE, WRITE
AppendAdd rows at endPUT, WRITE ADD
ReplaceEntire file contents newCREATE output, PUT all rows
DeleteRemove rowsWRITE DELETE paths

Sequential Full Replace Pattern

text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
FILE SOURCE SEQUENTIAL FB(200 2000) FILE NEWFILE FB(200 2000) CREATE DEFINE SOURCE * layout DEFINE NEWFILE * same layout JOB INPUT SOURCE MOVE SOURCE-FIELDS TO NEWFILE-FIELDS PUT NEWFILE STATUS IF FILE-STATUS NE 0 STOP END-IF

JCL allocates NEWFILE DISP=(NEW,CATLG,DELETE) or writes to generation in GDG base. After successful run, operations point production JCL to new DSN or roll GDG. SOURCE may be DB2 extract, corrected master, or SORT output. Row count in FINISH must match control totals.

VSAM KSDS Reload Considerations

Replacing KSDS rarely uses millions of individual WRITE updates. Common pattern: unload or extract all rows, SORT by key, PUT or mass insert into new cluster defined with IDCAMS, REPRO or DEFINE in ops runbook, swap cluster name. Easytrieve FILE NEWMAST INDEXED CREATE with UPDATE and sorted JOB INPUT PUT loads consecutive keyed records when release supports mass insertion. Duplicate keys in source must be resolved before reload—SORT with duplicate handling or validation ERRFILE.

SORT Before Replace

KSDS reload expects key order. SORT activity or external DFSORT step orders source before PUT. Unsorted reload into KSDS causes load failures or silent key disorder depending on path. Document key fields in SORT statement matching INDEXED DEFINE key position.

CREATE RESET and Field Initialization

CREATE on FILE builds new dataset. RESET on FILE may zero numeric fields on read for input validation during transform. Output DEFINE should receive explicit MOVE for every business field—do not rely on uninitialized buffer on PUT. Variable-length output needs RECORD-LENGTH before each PUT per appending chapter.

Backup and Operational Swap

Production replace runbook: backup current DSN or GDG rollback point; run Easytrieve replace to new dataset; compare record counts and checksum samples; IDCAMS PRINT or compare utility; rename or alter catalog alias to cut over; retain backup retention per policy. Easytrieve finishes when PUT completes—cutover is operations governance.

FILE-STATUS and Reconciliation

STATUS on every PUT in replace loops. STOP or branch on non-zero FILE-STATUS—partial replace is worse than failed job with old file intact. FINISH displays input count, output count, rejected count. Control file from upstream must match within tolerance. Automate mismatch alert to on-call before swap.

GDG Replace Pattern

Define GDG base in JCL; each replace run creates new generation (+1). Consumers coded with (0) or relative generation receive latest after successful create. Easytrieve FILE does not manage GDG—JCL DD DSN=BASE.GDG(+1) does. Replacing via GDG preserves history for audit rollback.

When Not to Replace

  • Single field correction on few keys—use updating.
  • Adding nightly transactions only—use appending.
  • Large master with tiny delta—delta update cheaper than full reload.
  • Concurrent readers need SHR during business hours—schedule replace offline.

Common Replace Mistakes

  • PUT to production DISP=OLD without backup.
  • Unsorted KSDS reload input.
  • Output DEFINE layout mismatch with downstream COBOL.
  • No STATUS on PUT in million-row loop.
  • Count reconciliation skipped before catalog swap.
  • Confusing replace with in-place WRITE update.

Explain It Like I'm Five

Updating is erasing one wrong word in your notebook. Appending is adding a new page at the back. Replacing is ripping out the whole notebook and binding a brand-new one with all pages rewritten. You keep a photocopy of the old notebook (backup) and count pages (reconciliation) before giving everyone the new notebook.

Exercises

  1. Write SOURCE-to-NEWFILE PUT loop with STATUS and STOP on error.
  2. Document ops runbook steps for backup, run, verify, swap.
  3. Choose update versus replace for three business scenarios.
  4. Add FINISH counts for input and output records.
  5. Explain why KSDS reload usually needs SORT by key first.

Quiz

Test Your Knowledge

1. Replacing an entire file usually means:

  • Writing new output dataset replacing old content
  • One READ by key
  • TITLE change
  • MASK only

2. In-place salary fix uses:

  • Updating records chapter WRITE
  • Replacing entire master
  • REPORT only
  • SCREEN REFRESH

3. CREATE on output FILE allows:

  • Building new sequential or VSAM when JCL permits
  • Only read SYSPRINT
  • Skip DEFINE
  • Ignore STATUS

4. Before replacing production master you should:

  • Backup and validate row counts
  • Skip JCL
  • Omit STATUS
  • Use DISP=SHR only always

5. PUT reload from sorted input is common for:

  • QSAM or ESDS full replace
  • Indexed random READ only
  • Printer
  • MACRO expand
Published
Read time16 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 CREATE PUT file replace patternsSources: Broadcom Easytrieve 11.6 Language Reference CREATE, PUT, FILE sequential VSAMApplies to: Easytrieve full file replace and reload jobs