Easytrieve Updating Records

Report writers read files; production systems also change them—salary adjustments, status codes, balance corrections, slot flags. Easytrieve updating is not a single mystery verb; it is FILE UPDATE authority, correct JCL disposition, retrieving the target record into the buffer with READ or GET HOLD, modifying DEFINE fields, and applying WRITE to commit the new image in place on VSAM KSDS or RRDS. Batch and CICS differ on HOLD defaults. Beginners copy read-only JOB INPUT examples then wonder why WRITE fails: UPDATE was missing on FILE or DISP was SHR while another job held exclusive use. This page walks the full update lifecycle, compares browse-and-update with keyed READ-update, explains NOHOLD overrides, documents FILE-STATUS error branches, and contrasts updating with appending sequential output via PUT. Master indexed and relative file pages before changing production masters.

Progress0 of 0 lessons

Prerequisites for Updates

Update checklist before coding WRITE
RequirementWhere setWhy it matters
FILE UPDATELibrary FILE statementAuthorizes update verbs
Correct FILE typeINDEXED or RELATIVE for VSAMQSAM not in-place rewrite
JCL dispositionDD DISP OLD or approved SHRAvoid record lock conflicts
Password if neededFILE PASSWORDVSAM cluster security
Record in bufferREAD or GET HOLDWRITE rewrites current buffer

FILE UPDATE Declaration

text
1
2
3
4
5
6
FILE PAYMAST INDEXED UPDATE FB(250 1800) DEFINE PAYMAST EMP-KEY 9 1 SALARY P 9.2 10 STATUS A 1 20

UPDATE on FILE tells Easytrieve and the access method that maintenance verbs are allowed. For SQL files, UPDATE means columns marked updatable can change and DELETE/INSERT paths need it. For VSAM, combine with appropriate OPEN mode implied by first verb. CREATE is separate— building new datasets—not the same as rewriting existing slots.

Retrieve Then Modify Pattern

Two dominant patterns exist. Keyed update: MOVE key from transaction to master key field, READ master STATUS, branch on not-found, MOVE new salary or status into buffer fields, WRITE master STATUS. Browse update: JOB INPUT on indexed master with UPDATE so each GET HOLD loads next record, IF logic decides change, MOVE fields, WRITE, loop continues. Pick keyed when input file drives sparse updates; pick browse when every master record needs inspection.

text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
FILE CHANGES SEQUENTIAL FB(40 27920) FILE PAYMAST INDEXED UPDATE FB(250 1800) DEFINE CHANGES C-EMP 9 1 C-NEW P 9.2 10 DEFINE PAYMAST EMP-KEY 9 1 SALARY P 9.2 10 JOB INPUT CHANGES MOVE C-EMP TO EMP-KEY READ PAYMAST STATUS IF NOT PAYMAST PUT ERRFILE EXIT END-IF MOVE C-NEW TO SALARY WRITE PAYMAST STATUS IF FILE-STATUS NE 0 PUT ERRFILE END-IF

GET HOLD and NOHOLD

Outside CICS, when FILE has UPDATE, Easytrieve may automatically hold records during GET so rewrite is possible. HOLD on GET explicitly requests hold; invalid without UPDATE. NOHOLD overrides automatic hold for read-only pass through same FILE declaration in another activity. In CICS, default is NOHOLD; HOLD prevents browse GET—use READ to retrieve for update. Mixing online and batch examples without noting environment causes production surprises.

WRITE Semantics

WRITE file-name applies the current buffer image to the record positioned or held in that file. STATUS sets FILE-STATUS for branch on duplicate key, authority, or I/O errors. WRITE is not for appending new sequential QSAM rows—that is PUT on output FILE. Confusing WRITE and PUT is a frequent maintenance bug. After failed WRITE, do not assume the master still matches buffer—re-READ before retry.

Batch Versus CICS Update Flow

Hold behavior summary
EnvironmentDefault hold on GETTypical update retrieve
Batch z/OSHOLD when FILE UPDATEGET HOLD or READ
CICS onlineNOHOLD defaultREAD for update

Concurrency and Locking

DISP=SHR allows readers while updaters may need careful SHAREOPTIONS on VSAM define. Exclusive DISP=OLD suits nightly batch refresh. Long-held records during GET HOLD block other updaters on same row—minimize logic between GET and WRITE. FINISH procedures should not leave files in ambiguous hold state; CLOSE when activity ends releases resources.

FILE-STATUS and Error Files

Always branch on STATUS after READ and WRITE in maintenance jobs. Write rejected records to sequential ERRFILE with PUT for reconciliation. Count successes in working storage; compare FINISH totals to input control counts. DUPLICATE on rewrite may mean logic error or duplicate key cluster definition—do not retry blindly in a loop.

Updating Versus Appending

Updating changes existing rows in place on VSAM. Appending adds new rows at end of sequential or ESDS via PUT without prior READ. Replacing entire file content may use output sequential CREATE plus PUT from transformed input—different chapter. Salary correction is update; monthly new-hire extract to interface file is append.

SQL Table Updates

SQL FILE with UPDATE allows changing defined columns; FILE without UPDATE limits which columns change. DELETE and INSERT need UPDATE and DBMS grants. SQL maintenance often uses embedded SQL verbs rather than VSAM WRITE—see SQL file chapter when DB2 is the target, not KSDS.

Testing Update Jobs

  1. Clone master to test cluster; never first-run on production DISP=OLD.
  2. Verify READ returns expected before image.
  3. Apply WRITE once; re-READ to confirm after image.
  4. Test not-found and duplicate branches.
  5. Run concurrent read job with SHR to validate sharing policy.

Common Update Mistakes

  • FILE UPDATE omitted.
  • WRITE without prior READ or GET HOLD.
  • Buffer fields not updated before WRITE.
  • Wrong JCL DISP causing lock or authority failure.
  • Using PUT instead of WRITE on KSDS master.
  • Applying batch HOLD assumptions on CICS programs.

Explain It Like I'm Five

Updating is erasing something on a worksheet and writing a new number in the same box—not adding a brand-new page at the back. First you must open the right workbook (READ), find the right row (key), change the pencil marks in your copy (MOVE to buffer fields), then press save on that row (WRITE). UPDATE is permission to save. If someone else locked the workbook (JCL or sharing), save fails and you write the problem in an error diary (ERRFILE).

Exercises

  1. Write FILE UPDATE and keyed READ-WRITE salary change from change file input.
  2. Add STATUS branches and ERRFILE PUT on not-found and WRITE failure.
  3. Document batch versus CICS HOLD differences in your own words.
  4. List when PUT is correct versus WRITE for a given job design.
  5. Design FINISH totals comparing input changes to successful updates.

Quiz

Test Your Knowledge

1. UPDATE on FILE is required to:

  • Authorize in-place record changes on update-capable files
  • Print reports only
  • Define SYSPRINT
  • Skip JCL DD

2. In batch, GET HOLD with FILE UPDATE:

  • Holds current record for rewrite
  • Only sorts data
  • Opens SQL
  • Closes all files

3. CICS online default for GET hold is:

  • NOHOLD; use READ to update
  • Always HOLD
  • Never open files
  • SQL only

4. After changing buffer fields you typically:

  • WRITE file-name to apply changes
  • Only PRINT
  • Only TITLE
  • Recompile only

5. JCL DISP for exclusive update often uses:

  • OLD or appropriate exclusive disposition
  • Only dummy
  • SYSOUT=*
  • Never allocated
Published
Read time16 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 UPDATE FILE WRITE GET HOLDSources: Broadcom Easytrieve 11.6 Language Reference UPDATE, WRITE, GET, FILEApplies to: Easytrieve VSAM and update-capable file maintenance