Easytrieve Array Dimensions

Dimensioning an array means deciding how many elements exist and how large each element is. In Easytrieve those two numbers live on DEFINE: field length and type set element size, OCCURS sets repetition count, INDEX names the subscript. A payroll tax table with fifty states might be STATE-CODE OCCURS 50 with each element ten bytes, consuming five hundred bytes in working storage. A character walk buffer uses OCCURS 80 with one-byte elements. Wrong dimensions on FILE definitions shift every following field in the record—silent data corruption until totals disagree with control counts. This page teaches size formulas, FLDMAX interaction, INDEX field sizing, nested repeating groups, alignment with copybooks, and comparison tables beginners use when translating COBOL OCCURS DEPENDING or fixed-count tables into Easytrieve Library entries.

Progress0 of 0 lessons

Element Size Versus Occurrence Count

Two independent knobs control array footprint. Element size comes from length and type on DEFINE—4 P 2 is four bytes per rate, 16 A is sixteen bytes per name. Occurrence count is the integer after OCCURS. Total contiguous storage is their product. The product applies whether location is W, S, or a byte offset on FILE. Report writers and MOVE statements see one element at a time based on INDEX; the product still reserves all slots in memory or in the record image.

Sample dimension calculations
DEFINE patternBytes per elementOCCURSTotal bytes
W 3 P 231236
W 10 A1050500
W 1 A18080
W 4 N49993,996
Group 25 bytes258200

FLDMAX and Installation Limits

Broadcom documents FLDMAX in the options table as the maximum field length. The entire OCCURS group is one field for this purpose—not one element. If FLDMAX is 32767 and your array needs 40000 bytes, compilation or generation fails until you shrink OCCURS, shrink element length, or ask operations to raise FLDMAX where policy allows. Raising FLDMAX increases memory pressure for every large field in every step—not a casual change. Document array sizing in program headers so maintainers know why OCCURS 500 was chosen instead of 501.

FILE Record Dimension Alignment

On FILE, start location plus total array length must match the data dictionary. Example: LINE-ITEM starts at byte 101, each occurrence is 30 bytes, OCCURS 5 spans bytes 101–250. If you declare OCCURS 4, byte 251 fields read wrong data. Cross-check against COBOL copybook OCCURS or SLIDE documentation. FB and VB records differ: on variable-length files, repeating groups usually sit in fixed portions; do not assume OCCURS extends into variable region without layout proof.

text
1
2
3
4
5
6
7
FILE INVOICE FB(280 2800) INV-NO 1 10 A INV-DATE 11 6 N LINE-ITEM 17 30 A OCCURS 8 INDEX LINE-SUB INV-TOTAL 257 8 P 2 * 30 × 8 = 240 bytes for lines starting at 17 → ends before 257

INDEX Field Dimensioning

INDEX names a separate numeric field. It must hold values from 1 through OCCURS maximum. OCCURS 12 needs at least two zoned digits if you use type N 2; OCCURS 200 needs N 3 or wider. Unsigned packed U fields work when shops prefer packed subscripts. Do not reuse a one-byte INDEX for OCCURS 100—overflow wraps or truncates depending on assignment rules and produces intermittent wrong-element bugs hardest to diagnose in production month-end jobs.

Choosing INDEX field width
Maximum OCCURSSuggested INDEX typeNotes
1–9N 1 0 or N 2 0Prefer N 2 for growth headroom
10–99N 2 0Standard for small tables
100–999N 3 0Common for code tables
1000+N 4 0 or I 4Verify FLDMAX first

Nested and Group Element Dimensions

An element can be a group: LINE-ITEM contains PROD-CODE 10 A and QTY 5 N inside each occurrence. Group length is sum of child lengths (15 in this example). OCCURS applies to the whole group. Nested OCCURS—rows and columns—uses an outer OCCURS on the row group and inner OCCURS on a field within the group, each with its own INDEX. Easytrieve does not use COBOL-style OCCURS 5 OCCURS 10 in one clause; structure nested DEFINE lines mirror copybook hierarchy. Draw a diagram before coding nested layouts.

text
1
2
3
4
DEFINE ROW W 15 A OCCURS 10 INDEX ROW-SUB DEFINE COL-VAL W 3 N OCCURS 5 INDEX COL-SUB * Within each ROW overlay, declare COL-VAL nested— * shop standards vary; verify against 11.6 DEFINE nesting rules

One-Dimensional Versus Table-Like Uses

Pure one-dimensional arrays index a single list. Two-dimensional logic uses two INDEX fields: ROW-SUB and COL-SUB, with nested OCCURS or computed offset into a flattened OCCURS n×m array. Flattening OCCURS 50 on a fifty-byte row where each row holds ten five-byte columns is one pattern; nested OCCURS is another. Flattening simplifies one loop; nesting mirrors COBOL readability. Pick based on maintenance team familiarity.

Varying Length and OCCURS Restrictions

VARYING length fields follow special rules in the Language Reference. Combining VARYING with OCCURS may be restricted or require specific release features. Beginners should use fixed-length elements in OCCURS until experienced with product limits. Character parsing arrays use fixed one-byte elements, not varying strings per slot.

Dimension Planning Checklist

  1. Document element byte length from DEFINE length and type, not display picture.
  2. Multiply by OCCURS; compare to FLDMAX.
  3. On FILE, verify start plus total fits before next field offset.
  4. Size INDEX to max OCCURS with one digit headroom for loop logic.
  5. Estimate REGION: sum all large OCCURS groups in the program.
  6. Peer-review against source copybook or interface spec.

Common Dimension Mistakes

  • Using display width instead of storage length for packed fields.
  • OCCURS count off by one versus copybook TIMES value.
  • INDEX too narrow for planned table growth.
  • Ignoring pad bytes between occurrences in legacy record layouts.
  • Assuming VB records allow unlimited OCCURS without length checks.

Explain It Like I'm Five

Dimensions tell you how many same-sized blocks sit in a row and how big each block is. If each block is three LEGO studs wide and you have twelve blocks, you need thirty-six studs of table space. The INDEX dial only goes as high as the number of blocks—if you have twelve blocks, a dial that stops at nine is too small. On a file record, the blocks must start exactly where the blueprint says or you read someone else's data by mistake.

Exercises

  1. Calculate total bytes for OCCURS 24 of a 4-byte packed amount field.
  2. Given LINE 20 bytes OCCURS 6 starting at 100, find ending byte before next field at 250.
  3. Choose INDEX length for OCCURS 150.
  4. Draw nested OCCURS 3 × 4 grid with two INDEX fields labeled.
  5. Explain why FLDMAX matters before raising OCCURS from 100 to 500.

Quiz

Test Your Knowledge

1. Total bytes for DEFINE ITEM W 5 N OCCURS 20 is approximately:

  • 100 bytes (5 × 20)
  • 25 bytes
  • 20 bytes only
  • FLDMAX always

2. OCCURS on a FILE field must match:

  • Physical repeating group in the record layout
  • JCL LRECL only
  • Number of JOB statements
  • REPORT lines

3. FLDMAX controls:

  • Maximum length of a single field definition including OCCURS group
  • Maximum JCL lines
  • Maximum PROC depth
  • Terminal rows

4. Nested OCCURS (group within group) requires:

  • Separate INDEX fields for each OCCURS level
  • One INDEX for entire program
  • No INDEX
  • SORT only

5. INDEX field length should:

  • Hold the maximum occurrence number
  • Always be 1 byte
  • Match element length
  • Equal LRECL
Published
Read time15 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 DEFINE OCCURS sizing and FLDMAXSources: Broadcom Easytrieve 11.6 Language Reference DEFINE, Options Table FLDMAXApplies to: Easytrieve array dimension planning