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.
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.
123456DEFINE 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'
| Type | Initial content | When to add VALUE |
|---|---|---|
| A alphabetic | Blanks | Default status code Y, month name |
| N P B U I numeric | Zeros | Starting counter 1, rate 0.0825 |
| FILE field | From file on READ | VALUE not used on FILE |
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 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.
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.
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.
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.
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.
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 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.
1234567DEFINE 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
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.
1. VALUE on DEFINE initializes:
2. Numeric working storage without VALUE defaults to:
3. Non-numeric VALUE must be:
4. Maximum initial-value length is:
5. If VALUE literal is longer than field: