Easytrieve LENGTH

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.

Progress0 of 0 lessons

Field-Length Parameter

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.

text
1
2
3
4
5
NAME 17 16 A PAY-GROSS 94 4 P 2 DEPT 98 3 N EMPNO 1 6 N WS-TOTAL W 9 N 2

Maximum Length by Type

DEFINE maximum field-length by data format
TypeMax bytesNotes
A alphabetic32767*254 for some table ARG DESC fields
N zoned18One digit per byte in display form
P packed10Two digits per byte except sign nybble
B binary8Often 4 in practice for COMP
U unsigned packed9No sign nybble
I integer8Only 2, 4, or 8 allowed

Character Length PIC X Mapping

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.

Numeric Display Length PIC 9

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 to Easytrieve length examples
COBOLLength bytesType
PIC X(20)20A
PIC 9(6)6N
PIC S9(7)V99 COMP-35P 2
PIC S9(9) COMP4B 0 or I 4

Packed Length and Digit Capacity

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.

Length With Overlays

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 and Total Size

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.

Length and Record Boundaries

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.

Length vs Report Column Width

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.

Common Length Mistakes

  • Using PIC digit count for COMP-3 byte length.
  • TYPE I with length 3 or 5—invalid sizes.
  • Overlay child longer than parent.
  • Confusing decimal positions with extra length bytes.
  • VALUE literal longer than field—truncation per assignment rules.

Explain It Like I'm Five

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.

Exercises

  1. Map PIC X(16) and PIC 9(6) to length and type.
  2. State max bytes for P and N types.
  3. Calculate end byte for field at 98 length 3.
  4. Explain PIC S9(7)V99 COMP-3 length in bytes.
  5. Describe OCCURS 100 on field length 5 total bytes.

Quiz

Test Your Knowledge

1. Field-length on DEFINE is measured in:

  • Bytes
  • Digits only
  • Columns 1-72
  • Records

2. Maximum packed P field length is:

  • 10 bytes
  • 18 bytes
  • 254 bytes
  • 4 bytes

3. Type I valid lengths are:

  • 2, 4, or 8 bytes only
  • 1 through 18
  • Any up to 254
  • 10 only

4. PIC X(16) in COBOL maps to Easytrieve length:

  • 16 bytes type A
  • 16 digits type N
  • 8 bytes
  • 32 bytes

5. OCCURS array total size is limited by:

  • FLDMAX option and length times occurrences
  • JCL only
  • REPORT LINESIZE
  • Eight bytes always
Published
Read time13 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 field-length bytes and type maximumsSources: Broadcom Easytrieve 11.6 DEFINE Statement attributes sectionApplies to: Easytrieve field byte length definition