Skip to main content
Module 4 · Lesson 2 of 28/16 in the course~16 min
Module lessons (2/2)

Base-1, OCCURS and SEARCH tables

Lesson preview5 hands-on exercises readyCourse COBOL · Module 4 — Hierarchical Records and Tables OCCURS

Allocate static arrays with OCCURS N TIMES, strictly base-1 indexing, PERFORM VARYING scans, and INDEXED BY / SEARCH searches.

What you'll learn in this lesson

  • Allocate fixed-size vectors and group tables via the OCCURS N TIMES clause.
  • Access elements via strictly base-1 indexes (WS-ITEM(1) .. WS-ITEM(N)) using PERFORM VARYING.
  • Distinguish between numeric subscripts in WORKING-STORAGE and INDEXED BY optimized for SEARCH (linear) and SEARCH ALL (binary).

Overview

In COBOL, lists of homogeneous elements are called tables and are declared by adding the OCCURS clause to any field of level 02–49 (never on the level 01!).

You can apply OCCURS to both elementary fields and entire group records:

Sections covered in this lesson

  1. 11. Declaration with OCCURS and Basic Rule-1
  2. 22. Populating and Scanning with PERFORM VARYING
  3. 33. Table pre-loaded via REDEFINES (Static decoding table)
  4. 44. High speed searches: INDEXED BY + SEARCH / SEARCH ALL
  5. 5Try it yourself
Pro Lesson · Module 4 — Hierarchical Records and Tables OCCURS

Unlock "Base-1, OCCURS and SEARCH tables" and the full Course COBOL curriculum

Allocate static arrays with OCCURS N TIMES, strictly base-1 indexing, PERFORM VARYING scans, and INDEXED BY / SEARCH searches.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Course COBOL plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.