Easytrieve Field INITIALization

Initialization is what a field contains before your logic trusts it—and what it returns to when a new processing phase begins. Easytrieve does not use a separate INITIAL keyword on DEFINE like some languages use INITIAL IS. Instead, initialization comes from product defaults: numeric working storage to zero, alphabetic to blanks; from VALUE on DEFINE for explicit starting literals; from RESET on W fields that restore initial state when JOB, SCREEN, or SORT starts; and from runtime MOVE or assignment in activity logic that clears buffers before PUT or loops. FILE fields initialize from whatever bytes the dataset contains on READ—garbage in means garbage out until validated. Beginners confuse compile-time VALUE with per-record clearing inside JOB—they are different lifecycles. This page unifies initialization concepts so you choose the right mechanism for counters, flags, new VSAM files, and multi-job programs in one source deck.

Progress0 of 0 lessons

Initialization Mechanisms Overview

How fields get starting values
MechanismApplies toWhen it runs
Default zeros/blanksW S numeric and AField allocation
VALUE on DEFINEWorking storageAllocation with explicit literal
RESET on DEFINEW fields onlyEach JOB SCREEN SORT start
READ from fileFILE fieldsEach record read
MOVE / assignment in JOBAny defined fieldWhen statement executes

Default Initialization

Without VALUE, numeric working storage fields contain zero at start. Alphabetic W and S fields contain spaces. Predictable for counters WS-COUNT W 4 N starting at zero before loop increments. Do not assume FILE fields are zero on first READ—uninitialized file data may hold LOW-VALUES or prior run residue until validated with IF NUMERIC or FLDCHK debug.

text
1
2
3
DEFINE WS-COUNT W 4 N DEFINE WS-NAME W 16 A * At start: WS-COUNT = 0, WS-NAME = spaces

VALUE Explicit Initialization

VALUE sets initial state at allocation—DEFINE ECHO-SW W 1 A VALUE 'Y' in online examples, DEFINE YEAR W 4 N VALUE 1999 in training manual. Becomes baseline RESET restores. See VALUE page for literal forms and length rules. Use when default zero or blank is wrong for business default flag or constant rate.

RESET Lifecycle

RESET on W field definition tells product to restore field to initial value—including VALUE if present—whenever JOB, SCREEN, or SORT activity executes. Useful for counters and flags that must start fresh each job pass in multi-activity programs. RESET with OCCURS allowed on array W fields. RESET not valid on overlay redefined fields. Multiple RESET fields reset in definition order.

text
1
2
3
4
5
6
7
8
9
DEFINE REC-COUNT W 6 N VALUE 0 RESET DEFINE ECHO-SW W 1 A VALUE 'Y' RESET JOB INPUT FILE1 REC-COUNT = REC-COUNT + 1 JOB INPUT FILE2 * REC-COUNT restored to 0 by RESET at JOB start REC-COUNT = REC-COUNT + 1

Second JOB sees counter zero again because RESET fired at JOB boundary. Without RESET, counter would accumulate across jobs in same run—sometimes desired, often bug.

RESET and Report Spooling

Broadcom notes RESET is not performed during printing of spooled reports when W fields used in report processing. Sequenced reports spool work files—non-static W accumulators may hold values from pre-sequence processing that differ from values at format time. Static S fields or careful job design avoids wrong averages. Read Getting Started warning on W-type fields in sequenced reports before building scratch totals.

FILE Field Initialization From Dataset

FILE fields receive record bytes on READ or PUT context. New VSAM file initialization job sets CUST-ID = 0 and NEXT-ID = 1 then PUT CUST—assignment in JOB, not VALUE on FILE DEFINE. First record seeds control file. Batch programs reading production extracts inherit whatever upstream wrote—validate before arithmetic.

text
1
2
3
4
5
JOB INPUT NULL CUST-ID = 0 NEXT-ID = 1 PUT CUST STOP

Runtime MOVE Initialization

Activity logic clears buffers before building output records. MOVE SPACE TO alpha fields, zero patterns to numeric groups. Example from manuals: initialize numeric and alpha fields before concatenation or PUT. Runs every time statement executes—not once at compile like VALUE. Use inside PROC before writing trailer or after reading header.

text
1
2
3
4
INIT-RECORD. PROC MOVE SPACE TO OUT-NAME OUT-ADDR WS-AMT = 0 END-PROC

VARYING Field Initial State

Varying alphanumeric default is zero-length string until VALUE supplies default content and length. Fixed-length beginners encounter this when advancing to variable-length name fields in online programs.

Initialization vs Validation

Initialization sets starting value. Validation checks after READ—IF ACCT NUMERIC, IF DATEVAL YES. LOW-VALUES in file numeric fields pass initialization concept but fail validation—use FLDCHK in PARM DEBUG during test. Do not conflate initialized working storage with clean file data.

Choosing the Right Approach

  1. Default zero or blank sufficient—omit VALUE for counters starting at zero.
  2. Known constant at compile—VALUE on DEFINE.
  3. Fresh counter each JOB—VALUE 0 with RESET.
  4. Per-record output buffer—MOVE or assignment in PROC each iteration.
  5. New file seed record—assignment plus PUT in init JOB.

Common INITIAL Mistakes

  • Expecting VALUE to zero FILE fields before READ.
  • Missing RESET when second JOB should restart counter.
  • Using W accumulator in sequenced report without understanding spool timing.
  • Assuming uninitialized FILE numeric is zero—test with DISPLAY HEX.
  • RESET on overlay field—invalid per documentation.

Explain It Like I'm Five

Initialization is setting up toys before play. Empty number toys start at zero, letter toys start blank. VALUE puts a sticker saying start at five instead. RESET cleans the toy back to the sticker number when a new game round starts. File toys come filled from the delivery box— you do not choose their starting stuff from home stickers.

Exercises

  1. Define counter with VALUE 0 and RESET; explain second JOB behavior.
  2. Write init JOB putting CUST-ID zero and NEXT-ID one.
  3. State default for W 10 A without VALUE.
  4. Contrast VALUE with MOVE SPACE in PROC.
  5. Explain why FILE GROSS is not initialized by VALUE.

Quiz

Test Your Knowledge

1. Alphabetic W field without VALUE initializes to:

  • Blanks
  • Zeros
  • LOW-VALUES
  • Question marks

2. RESET on W field returns field to:

  • Initial value when JOB SCREEN or SORT runs
  • File EOF
  • Random
  • Compile time only

3. RESET applies to:

  • W working storage fields only
  • All FILE fields
  • JCL only
  • REPORT titles

4. FILE field bytes on first READ come from:

  • Dataset record content
  • VALUE on DEFINE
  • SYSDATE
  • Compiler zeros

5. RESET with OCCURS arrays:

  • Allowed on W array fields
  • Never allowed
  • Only on FILE
  • Only with MASK
Published
Read time13 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 VALUE RESET default initialization rulesSources: Broadcom Easytrieve 11.6 DEFINE Statement RESET VALUE, Getting Started, Application GuideApplies to: Easytrieve field initialization and RESET