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.
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.
123456DEFINE field-name start-location field-length type [decimals] [EVEN] [HEADING 'title'] [MASK ('edit-mask' | HEX)] [VALUE initial-value] [INDEX index-field] [OCCURS n]
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 | Meaning | Example |
|---|---|---|
| integer | Start byte in current FILE record | GROSS 94 4 P 2 |
| W | Working storage | WS-TAX W 5 P 2 |
| S | Static storage | CURR-DATE S 6 N |
| parent +offset | Overlay on defined field | HIRE-MM DATE-OF-HIRE 2 N |
| * +n | Relative to prior field end | Rare in beginners FILE layouts |
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.
1234567891011121314FILE 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 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 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 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.
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 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 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.
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 | Max bytes | Decimals |
|---|---|---|
| A | 32767* | N/A |
| N | 18 | 0-18 |
| P | 10 | 0-18 |
| B | 8 | 0-10 |
| U | 9 | 0-18 |
| I | 8 (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.
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).
1. DEFINE keyword may be omitted when:
2. Location W on DEFINE means:
3. Maximum field name length is:
4. EVEN parameter applies to:
5. VALUE on numeric working storage without VALUE initializes to: