Easytrieve VALUE

Working storage fields exist before your first READ and after your last PRINT. Without explicit starting content, numeric W fields contain zero and alphabetic W fields contain blanks—predictable but not always what the business wants. The VALUE parameter on DEFINE sets initial-value when the field is allocated: DEFINE MONTH W 10 A VALUE 'JANUARY', DEFINE YEAR W 4 N VALUE 1999, DEFINE FLAGS W 2 B VALUE X'0000'. VALUE does not preload FILE record columns from dataset bytes. VALUE does not replace assignment inside JOB logic when records arrive. It establishes baseline state for counters, default flags, and constants referenced before first data line. This page explains literal forms, length matching, type compatibility, hex initialization, interaction with RESET, and contrast with runtime MOVE assignment.

Progress0 of 0 lessons

VALUE Syntax

Append VALUE initial-value to DEFINE after type and optional MASK. Initial-value must match field type—numeric literal for N P B U I, quoted string for A, hex X'...' for byte patterns on packed or binary. Maximum literal length 254 bytes.

text
1
2
3
4
5
6
DEFINE CURR-MONTH W 10 A VALUE 'JANUARY' DEFINE YEAR W 4 N VALUE 1999 DEFINE ECHO-SW W 1 A VALUE 'Y' DEFINE WS-FLAGS W 2 B VALUE X'0000' DEFINE TAX-RATE W 3 P 4 VALUE 0.0825 DEFINE SEED-PACKED W 2 P VALUE X'123F'

Default Initialization Without VALUE

Working storage defaults when VALUE omitted
TypeInitial contentWhen to add VALUE
A alphabeticBlanksDefault status code Y, month name
N P B U I numericZerosStarting counter 1, rate 0.0825
FILE fieldFrom file on READVALUE not used on FILE

Alphabetic VALUE

Quoted literals for type A. Length shorter than field pads per assignment rules—often trailing spaces. Length longer truncates. VALUE 'Y' on A 1 sets echo switch on in online examples. VALUE 'JANUARY' on A 10 fills month name working field before logic replaces with current month from date routine.

Numeric VALUE

Numeric literals without quotes when purely numeric—1999, 0, +125.50, 0.0825. Decimal point in literal is allowed. Assign into field with matching or smaller decimal capacity. VALUE on P field converts literal to packed internal form at initialization. VALUE 0 on counter W 4 N explicit though zero is default—documents intent for readers.

Hex VALUE for Packed and Binary

VALUE X'123F' on P 2 sets known packed pattern for tests. VALUE X'0000' on B 2 clears flags. Hex length must match byte count—four hex digits for two bytes. Useful in unit-style test programs and flag defaults where character literal is meaningless.

Length Mismatch Rules

When initial-value length differs from field-length, product truncates or pads per assignment rules documented for your release. VALUE 'YES' on A 1 may truncate to Y. VALUE 'AB' on A 10 pads with spaces. Test DISPLAY after compile when borderline lengths matter for online screens.

VALUE vs FILE Fields

FILE PAY-GROSS 94 4 P 2 reads packed bytes from input dataset each READ—VALUE does not apply to file layout lines in standard batch FILE definitions. Attempting to VALUE preload file column misunderstands data flow. Initialization jobs that PUT first record use assignment CUST-ID = 0 and NEXT-ID = 1 in JOB logic, not VALUE on FILE field.

VALUE and VARYING Fields

Default for varying field is zero-length string. When VALUE coded on VARYING field, value and length become default per DEFINE documentation. Advanced topic—fixed-length beginners focus on W fields first.

VALUE With RESET

RESET on W field returns field to initial value—including VALUE if specified—when JOB SCREEN or SORT executes. Pair VALUE default flag Y with RESET for echo switch that restores each job iteration. See INITIAL page for RESET lifecycle detail.

VALUE vs Runtime Assignment

VALUE runs at allocation—before JOB INPUT loop typically. WS-COUNT = 0 inside JOB resets each run explicitly. VALUE sets once unless RESET fires. MOVE and assignment in PROC change fields during processing. Choose VALUE for constants known at compile time; assignment for values computed from SYSDATE or file headers.

text
1
2
3
4
5
6
7
DEFINE WS-COUNT W 4 N VALUE 0 JOB INPUT PERSNL WS-COUNT = WS-COUNT + 1 IF WS-COUNT GT 9999 DISPLAY 'RECORD LIMIT' END-IF

Common VALUE Mistakes

  1. VALUE on FILE field expecting preload before READ.
  2. Unquoted alphabetic initial value—syntax error.
  3. Hex VALUE odd digit count—invalid literal.
  4. VALUE rate with wrong decimal count on P field—scaled wrong.
  5. Assuming VALUE re-applies every record without RESET.

Explain It Like I'm Five

VALUE is what you put in a lunch box before leaving home—crackers in the box from the start. Without VALUE, numeric boxes start empty with zero crackers and letter boxes start with blank paper. The lunch box from the file shelf gets filled when the file machine drops a record in—VALUE does not fill file boxes.

Exercises

  1. Define ECHO-SW A 1 with VALUE Y.
  2. Define TAX-RATE P 4 with VALUE 0.0825.
  3. Explain default for W 5 P without VALUE.
  4. Initialize flags with VALUE X'0000' on B 2.
  5. Contrast VALUE with assignment inside JOB loop.

Quiz

Test Your Knowledge

1. VALUE on DEFINE initializes:

  • Working storage field contents
  • JCL DD allocation
  • Entire input file
  • SYSPRINT

2. Numeric working storage without VALUE defaults to:

  • Zero
  • Spaces
  • HIGH-VALUES
  • LOW-VALUES

3. Non-numeric VALUE must be:

  • Enclosed in single quotes
  • Hex only
  • Eight bytes max
  • On FILE fields only

4. Maximum initial-value length is:

  • 254 bytes
  • 18 digits
  • 128 characters
  • 10 bytes

5. If VALUE literal is longer than field:

  • Truncated or padded per assignment rules
  • Compile error always
  • Expands field
  • Ignored
Published
Read time12 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 VALUE initial-value on working storageSources: Broadcom Easytrieve 11.6 DEFINE Statement, Getting Started working storageApplies to: Easytrieve VALUE parameter on DEFINE