Length is the third number on most FILE and DEFINE lines—the byte count of storage the field occupies. Sixteen on NAME 17 16 A means sixteen character bytes from position seventeen. Four on PAY-GROSS 94 4 P 2 means four packed bytes holding up to seven digits plus sign in COMP-3 layout. Length is not digit count for packed fields, not display width on reports, and not COBOL picture size without translation. Wrong length shifts every later field in the record and produces silent data corruption that passes compile. This page explains byte measurement, maximum lengths per type, mapping COBOL PIC to Easytrieve length, OCCURS array sizing, VARYING models, and how length interacts with position to bound the record layout.
Broadcom requires field-length in bytes for every fixed field on DEFINE and FILE. Pattern: name, position, length, type, optional decimals. Length must be unsigned integer compatible with type maximums. Zero length is invalid for fixed fields. VARYING fields use model field instead of fixed length in specialized syntax.
12345NAME 17 16 A PAY-GROSS 94 4 P 2 DEPT 98 3 N EMPNO 1 6 N WS-TOTAL W 9 N 2
| Type | Max bytes | Notes |
|---|---|---|
| A alphabetic | 32767* | 254 for some table ARG DESC fields |
| N zoned | 18 | One digit per byte in display form |
| P packed | 10 | Two digits per byte except sign nybble |
| B binary | 8 | Often 4 in practice for COMP |
| U unsigned packed | 9 | No sign nybble |
| I integer | 8 | Only 2, 4, or 8 allowed |
COBOL PIC X(n) is one byte per character in standard single-byte layouts—length n type A. PIC X(16) NAME becomes 16 A. DBCS fields use M or K types with different length rules for double-byte characters—beginners at ASCII-only shops rarely encounter them until multinational name fields appear.
PIC 9(n) display numeric uses n bytes zoned—length n type N with optional decimals for V clause. PIC 9(7)V99 COMP-3 is not length 9—it is five packed bytes with two decimal positions P 5 2. Confusing display digit count with packed byte count is the dominant length error in copybook transcription.
| COBOL | Length bytes | Type |
|---|---|---|
| PIC X(20) | 20 | A |
| PIC 9(6) | 6 | N |
| PIC S9(7)V99 COMP-3 | 5 | P 2 |
| PIC S9(9) COMP | 4 | B 0 or I 4 |
Packed byte length n holds up to 2n minus 1 decimal digits plus sign in last nybble. Five bytes P holds nine digits plus sign. EVEN on P changes even-digit rules with leading zero nybble. Choosing P 4 2 for amounts exceeding four-byte packed capacity causes overflow on assignment or wrong values on read.
Child overlay length plus offset must not exceed parent length. DATE-OF-HIRE 6 N with HIRE-MM 2, HIRE-DD 2 at +2, HIRE-YY 2 at +4 totals six—exact fit. Child length 8 on parent 6 exceeds boundary—invalid layout. LAST-NAME 8 on NAME 16 uses first half only—valid.
OCCURS n multiplies storage: field-length times maximum-occurrences. Array of ten five-byte packed fields consumes fifty bytes contiguous in layout when defined with OCCURS. Maximum occurrences 32767 per documentation; practical limit is FLDMAX installation option. INDEX field is separate four-byte binary allocated automatically.
End byte equals start plus length minus one. Sum of fields need not fill entire record—trailing bytes may be unused. Used bytes must fit LRECL. Sort and merge utilities assume consistent record length across file. Variable-length files use different FILE parameters—not fixed length discussion here.
Report LINE prints fields with editing—MASK may widen output beyond storage length with commas and signs. Storage length still governs read and assignment. Do not set FILE length to report column width—set to file layout truth.
Length is how many boxes on the shelf the field needs. A name might need sixteen boxes in a row. A money amount might need four smaller special boxes that squeeze digits together. If you reserve too few boxes, the number spills into the next person's boxes and mixes everything up.
1. Field-length on DEFINE is measured in:
2. Maximum packed P field length is:
3. Type I valid lengths are:
4. PIC X(16) in COBOL maps to Easytrieve length:
5. OCCURS array total size is limited by: