Every name your program uses in IF, PRINT, assignment, and REPORT LINE must be defined before reference. Field definitions are that contract: field-name, where bytes live, how many bytes, what type they are, and optional decoration like MASK for print editing or VALUE for initialization. FILE statements describe record layouts on datasets; DEFINE statements describe working storage and overlays. Together they form the data dictionary anchor of the Library section. One wrong length on a packed salary field shifts every following field—department code reads as tax amount, reports look plausible, auditors find million-dollar errors. This overview introduces the attribute families beginners must master before diving into DEFINE, POSITION, LENGTH, and DECIMALS detail pages.
| Aspect | FILE fields | DEFINE fields |
|---|---|---|
| Purpose | Map record layout on dataset | Working storage, overlays, late vars |
| Location | Numeric start position in record | W, S, or overlay on parent |
| Keyword | After FILE statement | DEFINE optional after FILE |
| Data source | Bytes from READ | Program-computed values |
12345678FILE PERSNL FB(150 1800) NAME 17 16 A PAY-GROSS 94 4 P 2 DEPT 98 3 N DATE-OF-HIRE 136 6 N DEFINE WS-TAX W 5 P 2 DEFINE WS-NET W 5 P 2
Name: one through 128 characters, starting with letter or national character, not all numeric. Location: byte position in file, W working storage, S static storage, or overlay on another field. Length: byte count for fixed fields. Type: A M K N P B U I letter. Decimal positions: optional on numeric types for quantitative fields. These five decisions determine every read, assignment, and SUM behavior downstream.
HEADING supplies default column titles on reports. MASK customizes numeric edit patterns or HEX display. VALUE sets initial content for working storage. INDEX links to array index fields for OCCURS tables. UPDATE marks SQL-updatable fields. RESET participates in varying field reset semantics. EVEN applies to packed even-digit fields. Beginners add these after core layout is correct—MASK cannot fix wrong type.
| Parameter | Purpose |
|---|---|
| HEADING | Default report column title literal |
| MASK | Edit pattern or HEX for display |
| VALUE | Initial value at allocation |
| INDEX | Array index field name |
| OCCURS | Repeat field maximum count |
| VARYING | Variable-length field model |
DATE-OF-HIRE 136 6 N with HIRE-MM DATE-OF-HIRE 2 N reuses parent bytes without new positions. Overlay reduces transcription errors when month day year are contiguous in file. Offset +2 skips two bytes from parent start. Overlay type should match usage— splitting N parent into N children is typical.
W fields are recomputed during job processing—counters, tax scratch, loop variables. S fields persist per static storage rules—CURR-DATE in samples uses S for run date set once. Choose S when value must survive across procedure calls within run without re-fetching. Choose W for per-record or per-calculation temporaries.
Duplicate unqualified names cause compile errors or ambiguous references. File-qualifier prefix ties field to specific file when same logical name appears in multiple layouts: FILE1:EMPNO versus FILE2:EMPNO. Macros generating standard layouts rely on consistent naming across programs in a data dictionary discipline.
Transcribe COBOL or PL/I copybooks byte-for-byte into FILE definitions. Verify total record length matches FB LRECL. Use hex dump on sample records when copybook is suspect. SYNC and filler bytes in COBOL still consume positions—skip them in Easytrieve position counting or include as FILLER A fields for documentation.
Matching type and length to actual file storage avoids runtime conversion overhead. Declaring zoned N on packed COMP-3 file forces conversion every read—measurable on million-record jobs. Correct Library definitions are performance investment, not bureaucracy.
Field definitions are name tags on boxes in a long row of storage lockers. Each tag says which locker number, how wide the box is, and whether it holds letters or money numbers. If you put the tag on the wrong locker, you open someone else's stuff and think it is yours. FILE tags lockers on the input shelf; DEFINE tags scratch pads on your desk.
1. FILE field definitions map fields to:
2. DEFINE W creates fields in:
3. Field names must be unique:
4. Overlay syntax uses:
5. Decimal positions on DEFINE designate: