Easytrieve Variable Default Values

Default values answer a simple question before your first assignment runs: what is in the variable right now? For working storage, Easytrieve answers predictably—numeric variables start at zero, alphabetic variables start as blanks. That predictability is why beginners can code WS-COUNT W 4 N and increment immediately without a separate clearing step. FILE variables have no product default in that sense; they mirror whatever bytes the current record holds. VALUE on DEFINE replaces the product default with an explicit literal you choose at compile time. RESET makes that literal—or the product default when VALUE is absent—the restoration target at JOB boundaries. Understanding defaults by data type prevents false assumptions: a packed amount field does not default to spaces, a name field does not default to zero, and a varying name field defaults to zero length until you assign content. This page catalogs default behavior for each variable and type combination beginners encounter in batch report programs and online SCREEN activities.

Progress0 of 0 lessons

Product Defaults for Working Storage

Default allocation values when VALUE is omitted
DEFINE typeDefault contentBeginner notes
N (zoned numeric)Numeric zeroUnsigned display numeric; safe counter start
P (packed decimal)Packed zeroImplied decimal positions honored in arithmetic
B (binary)Binary zeroAll bits off; mind length for comparisons
U / I (floating)Floating zeroLess common in classic batch; verify shop standards
A (alphabetic)SpacesFull field length filled with blank characters
M / K (DBCS)Type-appropriate blank or zero fillDouble-byte rules per release; test DISPLAY
Varying AZero lengthNo visible characters until assignment or VALUE

Numeric Zero Defaults

Zoned N, packed P, and binary B working storage fields without VALUE contain numeric zero at program start. For WS-TOTAL W 9 P 2, that means a packed zero with two decimal places implied—not spaces, not LOW-VALUES, not HIGH-VALUES. You can increment WS-TOTAL in the first statement of the first JOB without explicit clearing. Comparison tests behave accordingly: IF WS-TOTAL EQ 0 or IF WS-TOTAL ZERO may succeed before any assignment depending on constant usage in your shop. Contrast with FILE packed fields on input: the first READ may load non-zero garbage if the upstream file was never validated.

text
1
2
3
4
5
6
7
8
DEFINE WS-COUNT W 6 N DEFINE WS-AMT W 7 P 2 DEFINE WS-BITS W 2 B * At program start: * WS-COUNT = 0 (zoned) * WS-AMT = 0.00 (packed) * WS-BITS = X'0000' (binary zero)

Alphabetic Blank Defaults

A fields initialize to spaces across the entire declared length. WS-NAME W 30 A holds thirty blank characters before any MOVE or assignment. That matters for concatenation, comparison, and report output: an empty name field prints as blanks, not zeros. Tests like IF WS-NAME EQ SPACE or IF WS-FLAG EQ ' ' evaluate against that default state. Trailing spaces in fixed-length fields are normal—not a bug—unless business rules require trimming via edit masks or string functions in advanced topics.

text
1
2
3
4
5
6
DEFINE WS-NAME W 30 A DEFINE WS-FLAG W 1 A IF WS-FLAG EQ ' ' WS-FLAG = 'N' END-IF

VALUE Overrides Product Defaults

VALUE replaces the automatic default with a compile-time literal. DEFINE STATUS W 1 A VALUE Y starts as Y instead of blank. DEFINE RATE W 3 P 2 VALUE 7.50 starts at that packed amount instead of zero. VALUE length must fit the field definition—overlong literals cause compile errors. VALUE becomes the initial state RESET restores on W fields coded with RESET. Without RESET, VALUE still sets only the starting point at allocation; assignments during the run change the live value until the program ends.

text
1
2
3
DEFINE ECHO-SW W 1 A VALUE 'Y' RESET DEFINE BASE-RT W 3 P 2 VALUE 8.25 DEFINE WS-CNT W 4 N VALUE 100

ECHO-SW returns to Y at each JOB with RESET. BASE-RT stays 8.25 until overwritten—no RESET on that line. WS-CNT starts at 100 once; without RESET it keeps incrementing across JOBs if your logic adds to it.

W vs S Default Timing

W and S fields receive the same product defaults at program allocation. The difference is not the default bytes but what happens later: W with RESET snaps back to VALUE or product default at JOB SCREEN SORT boundaries; S retains whatever value assignments produced unless you clear it. Two DEFINE WS-X W 5 N lines are invalid; one W and one S with the same name also collide. Defaults apply once per allocation per name in the dictionary.

FILE Fields: No Allocation Default

FILE statement field lines do not trigger working storage allocation defaults. NAME 17 20 A on FILE PERSNL is a view into the PERSNL record buffer. Before the first READ, buffer content may be undefined or leftover from a prior operation depending on runtime internals—do not write logic that assumes blanks or zeros on FILE fields pre-READ. After READ, bytes come from the dataset. Before PUT on output files, you assign defaults explicitly in JOB logic if the business requires blank names or zero amounts on new records.

text
1
2
3
4
5
JOB INPUT PERSNL IF GROSS NOT NUMERIC GROSS = 0 END-IF END-JOB

Overlay and Subfield Defaults

Overlay variables share parent storage. HIRE-MM on DATE-OF-HIRE does not get a separate default allocation—it reflects whatever bytes occupy those positions in the parent field. If parent DATE-OF-HIRE is blank on a new output record you cleared with MOVE SPACE, overlays are blank too. If parent holds LOW-VALUES from a bad READ, overlays inherit that bit pattern. Initialize the parent buffer when you need predictable subfield defaults.

OCCURS Array Defaults

OCCURS on W fields allocates each element with the same product defaults as a scalar field of that type—each numeric element zero, each alphabetic element blank. VALUE on an OCCURS definition can supply initial content per documentation rules for your release. RESET on OCCURS W arrays restores every element when the activity starts. Arrays without VALUE behave like repeated scalar defaults across the occurrence count.

System Constants vs Variable Defaults

ZERO, SPACE, HIGH-VALUES, and LOW-VALUES are language constants for comparisons and MOVE operations—not automatic defaults unless you assign them. A W field does not default to HIGH-VALUES; you must MOVE HIGH-VALUES TO field if that is the sentinel your shop uses for missing data. Confusing constant names with allocation defaults leads to IF tests that never match because the field still holds product zero or blank.

SQL NULL and Default Semantics

SQL nullable columns do not default host variables to SQL NULL conceptually—indicator variables carry null state. Uninitialized indicators before fetch produce undefined behavior. After fetch with NULL indicator set, host variable bytes may still show prior content; logic must branch on indicator, not on host field default rules. This differs from W allocation defaults and belongs in SQL integration testing checklists.

Defaults in Comparisons and Reports

Default zero numeric fields participate in SUM and arithmetic immediately. Default blank alpha fields print as empty columns on LINE statements. MASK formatting may turn zero amounts into blank display per mask characters—display default differs from storage default. WHEN PRINTING, verify whether business users want zero amounts shown as 0.00 or suppressed; storage still holds zero until assignment changes it.

Version and Release Notes

Core default rules for W and S numeric zero and alphabetic blank are stable across Broadcom 11.x documentation. DBCS M and K defaults and varying field edge cases should be verified against your installation manual if you process double-byte names or variable-length online fields. Deprecated constant behaviors live on the constants-by-release page—not variable default allocation.

Common Default Value Mistakes

  • Assuming FILE numeric fields are zero before READ.
  • Expecting VALUE on FILE layout line to set defaults.
  • Testing IF FILE-NAME EQ SPACE on numeric FILE field.
  • Forgetting VALUE length must match field size.
  • Using W default rules on SQL host variables without indicator discipline.
  • Expecting overlay subfield to default independently of parent.

Explain It Like I'm Five

Default values are what the computer puts in your box before you touch it. Number boxes get zero marbles. Letter boxes get empty space characters like invisible padding. You can put a sticky note on the box saying start with five marbles—that is VALUE. File boxes do not get prefilled by the computer; they arrive with whatever was shipped in the truck. Little boxes drawn inside a big box copy whatever the big box holds—they do not get their own separate starter pack.

Exercises

  1. State default contents for W 8 P 2 and W 8 A without VALUE.
  2. Add VALUE to a flag field; explain difference from blank default.
  3. Write IF test distinguishing uninitialized FILE numeric from zero default W numeric after bad READ.
  4. Define OCCURS W array; explain default per element.
  5. Contrast MOVE ZERO with omitting VALUE on numeric W field.

Quiz

Test Your Knowledge

1. Alphabetic W 20 A without VALUE contains at start:

  • Twenty spaces
  • Twenty zeros
  • LOW-VALUES
  • Unpredictable bytes

2. Packed decimal W 5 P 2 without VALUE starts as:

  • Zero with implied decimal
  • Spaces
  • HIGH-VALUES
  • Compile error

3. VALUE on DEFINE changes default by:

  • Replacing product default with explicit literal at allocation
  • Changing FILE DCB
  • Setting JCL symbol
  • Only affecting reports

4. FILE field defaults are:

  • No product default—content comes from dataset on READ
  • Always zero
  • Always blank
  • Copied from SYSDATE

5. Varying alphanumeric default length is:

  • Zero until VALUE or assignment sets content
  • Always 254
  • Same as fixed A
  • Always 1
Published
Read time15 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 working storage default zero and blank allocation rulesSources: Broadcom Easytrieve 11.6 DEFINE Statement VALUE, Getting Started, Define Files and FieldsApplies to: Easytrieve variable default values by type