Easytrieve DEFINE Statement

The DEFINE statement is how you declare fields—on files, in working storage, as overlays, and with optional report and initialization attributes. Broadcom syntax allows DEFINE explicitly or omits the keyword when field lines immediately follow a FILE statement. Every parameter has a job: location says where bytes start, length and type say how to interpret them, MASK says how to print them, VALUE says what they contain before logic runs. Master DEFINE and you can transcribe any copybook, build scratch variables for tax calculations, and attach HEADING text reports inherit automatically. This page walks the full format diagram from the 11.6 language reference, explains each parameter group, and shows patterns from payroll training programs beginners still maintain in production.

Progress0 of 0 lessons

DEFINE Format Diagram

Broadcom lists DEFINE as field name, location, attributes (length type decimals EVEN), optional VARYING model, UPDATE for SQL, HEADING, INDEX, MASK, OCCURS, VALUE, and RESET. Activity-section DEFINE requires the DEFINE keyword; Library FILE-following lines may omit it for readability in data dictionary listings.

text
1
2
3
4
5
6
DEFINE field-name start-location field-length type [decimals] [EVEN] [HEADING 'title'] [MASK ('edit-mask' | HEX)] [VALUE initial-value] [INDEX index-field] [OCCURS n]

Field Name Rules

One to 128 characters. Must begin with A-Z, 0-9, or national character # @ $. Cannot be all numeric. Cannot be a delimiter. Hyphens and underscores are common in shop standards. EMP-NO and EMPNO both valid if unique. Reserved words and system names like SYSDATE are restricted—see naming conventions page.

Location Parameters

DEFINE location options
LocationMeaningExample
integerStart byte in current FILE recordGROSS 94 4 P 2
WWorking storageWS-TAX W 5 P 2
SStatic storageCURR-DATE S 6 N
parent +offsetOverlay on defined fieldHIRE-MM DATE-OF-HIRE 2 N
* +nRelative to prior field endRare in beginners FILE layouts

Attributes: Length, Type, Decimals, EVEN

Length is byte count for fixed fields. Type letter selects interpretation—A alphabetic, N zoned, P packed, B binary, U unsigned packed, I integer 2/4/8, M and K for DBCS variants. Decimal positions 0-18 follow type on quantitative numerics. EVEN on P only forces even digit count with leading zero nybble X'012F' style layout.

text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
FILE PERSNL FB(150 1800) NAME 17 16 A LAST-NAME NAME 8 A PAY-GROSS 94 4 P 2 DEPT 98 3 N DATE-OF-HIRE 136 6 N HIRE-MM DATE-OF-HIRE 2 N HIRE-DD DATE-OF-HIRE +2 2 N HIRE-YY DATE-OF-HIRE +4 2 N DEFINE SALARY W 4 P 2 DEFINE BONUS W 4 P 2 DEFINE SERVICE W 2 N DEFINE CURR-DATE S 6 N

HEADING for Reports

HEADING supplies default column titles when field appears on REPORT LINE without explicit heading override. Literal in quotes follows HEADING keyword. Multiple font numbers supported in advanced report writer options. Reduces duplicate TITLE/HEADING maintenance when many reports share Library definitions.

MASK Parameter

MASK accepts named mask identifier A through Y for reuse, BWZ to blank zero amounts, literal edit pattern in quotes, or HEX for hexadecimal display. Alphanumeric fields support MASK HEX only among numeric masks. Quantitative fields get system default masks when MASK omitted—commas and decimals on totals.

VALUE Initialization

VALUE sets initial content when field is allocated. DEFINE YEAR W 4 N VALUE 1999 from training manual. Numeric VALUE uses literals or hex X'123F'. Alphabetic VALUE uses quoted strings. FILE fields read from dataset—VALUE does not preload file content. Working storage without VALUE: numeric zero, alphabetic blanks.

INDEX and OCCURS Arrays

OCCURS maximum-occurrences creates array-like field group. INDEX names field holding current subscript. Total size limited by FLDMAX option in options table. Subscript manipulation in logic references index field defined on same DEFINE or sibling DEFINE.

VARYING Fields

VARYING with model-field-name defines variable-length fields following model layout. Excluded from some HEX display contexts per screen formatting documentation. Advanced topic—beginners stick to fixed length until copybook requires varying.

UPDATE for SQL Files

UPDATE on DEFINE marks SQL column fields modifiable by UPDATE statement. Requires UPDATE authorization on column. FILE-level UPDATE applies to all fields when specified on FILE statement. Batch FILE processing ignores UPDATE unless SQL file type in use.

DEFINE in Activity Section

Working storage needed only mid-job may be DEFINED in Activity before first reference. DEFINE keyword required outside Library FILE block. Pattern: open JOB, DEFINE temporaries, process records. Late DEFINE still must precede use—compiler does not forward-reference.

Type Capacity Reference

Maximum length and decimals by type
TypeMax bytesDecimals
A32767*N/A
N180-18
P100-18
B80-10
U90-18
I8 (2/4/8 only)0

Asterisk on A length reflects table file ARG DESC limits of 254 bytes in some contexts— verify FLDMAX for your installation.

Common DEFINE Mistakes

  1. Omitting DEFINE keyword in Activity when required.
  2. Overlay parent undefined or defined after child.
  3. I field length not 2, 4, or 8.
  4. EVEN on non-P field.
  5. VALUE expecting to preload FILE record bytes.

Explain It Like I'm Five

DEFINE is filling out a name tag sticker for each box of data. You write the name, which shelf it sits on, how big the box is, and whether it holds letters or money. Optional stickers say how to print it nicely (MASK) or what to put inside before you start (VALUE).

Exercises

  1. Write FILE PERSNL with five fields omitting DEFINE keyword.
  2. Add DEFINE working storage salary bonus service fields.
  3. Split date into three overlays on parent.
  4. Add HEADING and MASK to a numeric amount field.
  5. State when DEFINE keyword cannot be omitted.

Quiz

Test Your Knowledge

1. DEFINE keyword may be omitted when:

  • Fields follow immediately after the associated FILE statement
  • Never
  • Only in JCL
  • Only for type A

2. Location W on DEFINE means:

  • Working storage
  • Write-only file
  • Wide character
  • Week number

3. Maximum field name length is:

  • 128 characters
  • 8 characters
  • 254 characters
  • 18 characters

4. EVEN parameter applies to:

  • Packed decimal P fields only
  • All types
  • A only
  • JCL DD

5. VALUE on numeric working storage without VALUE initializes to:

  • Zero
  • Spaces
  • HIGH-VALUES
  • Random
Published
Read time15 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 DEFINE statement full formatSources: Broadcom Easytrieve Report Generator 11.6 DEFINE Statement language referenceApplies to: Easytrieve DEFINE field declaration