Easytrieve Field Definitions Overview

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.

Progress0 of 0 lessons

FILE vs DEFINE

Two definition mechanisms
AspectFILE fieldsDEFINE fields
PurposeMap record layout on datasetWorking storage, overlays, late vars
LocationNumeric start position in recordW, S, or overlay on parent
KeywordAfter FILE statementDEFINE optional after FILE
Data sourceBytes from READProgram-computed values
text
1
2
3
4
5
6
7
8
FILE 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

Core Attributes Every Field Shares

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.

Optional Characteristics

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.

Optional DEFINE parameters
ParameterPurpose
HEADINGDefault report column title literal
MASKEdit pattern or HEX for display
VALUEInitial value at allocation
INDEXArray index field name
OCCURSRepeat field maximum count
VARYINGVariable-length field model

Overlays and Subfields

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.

Working Storage W and Static S

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.

Uniqueness and Qualifiers

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.

Copybook Alignment 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.

Definition Order Rules

  1. Define FILE before referencing file in JOB INPUT.
  2. Define field before use in IF, PRINT, assignment.
  3. Parent field before overlay children in source.
  4. Macro-expanded definitions behave as if written inline.

Performance and Conversion

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.

Common Definition Mistakes

  • One-byte position shift from miscounted COBOL filler.
  • Wrong type P vs N on financial fields.
  • Duplicate field names across FILE and DEFINE.
  • Overlay offset +2 when copybook says +1.
  • Missing decimal positions on amounts that should SUM.

Explain It Like I'm Five

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.

Exercises

  1. Write FILE with three fields: name A, salary P 2, dept N.
  2. Add DEFINE working storage tax and net P 2 fields.
  3. Split six-byte date into three two-byte overlays.
  4. List five core attributes every field needs.
  5. Explain one consequence of duplicate field names.

Quiz

Test Your Knowledge

1. FILE field definitions map fields to:

  • Positions within a file record
  • JCL job name only
  • Terminal screen rows
  • Binder card

2. DEFINE W creates fields in:

  • Working storage
  • JES spool
  • Link stack
  • REPORT section only

3. Field names must be unique:

  • Across files and working storage in the program
  • Only in one FILE
  • Only on reports
  • Never

4. Overlay syntax uses:

  • Parent field name plus optional +offset
  • REPORT LINE only
  • JCL DD
  • MACRO ENDMACRO

5. Decimal positions on DEFINE designate:

  • Quantitative signed fields with implied decimals
  • Alphabetic length
  • Comment lines
  • EOF handling
Published
Read time14 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 FILE DEFINE field attribute modelSources: Broadcom Easytrieve 11.6 DEFINE Statement, Describe Files and Fields, Library sectionApplies to: Easytrieve field definition fundamentals