Key Takeaways — Chapter 4: Data Description Mastery

  1. PICTURE clauses define both type and format. Numeric symbols (9, V, S, P) define computational data. Alphanumeric symbols (X, A) define text. Edited symbols (Z, *, $, +, -, B, 0, /) create human-readable display formats. Master all three categories.

  2. Always use S for signed numeric fields. Omitting the sign indicator silently converts negative values to positive — a bug that has caused real financial losses in production systems.

  3. Choose USAGE deliberately. COMP-3 (packed decimal) for financial/monetary data. COMP (binary) for subscripts and counters. COMP-1/COMP-2 (floating point) never for money. DISPLAY for fields in flat file I/O. COMP-5 for system API parameters.

  4. COMP-3 is the enterprise COBOL workhorse. It provides exact decimal arithmetic, ~50% space savings over DISPLAY, and hardware-accelerated performance on IBM z/Architecture. Every financial field should be COMP-3.

  5. Level 88 condition names are indispensable. They turn cryptic code values into readable business logic, decouple PROCEDURE DIVISION code from specific values, and serve as living documentation. Every coded field should have 88-levels.

  6. REDEFINES enables variant records. The pattern of a type discriminator followed by REDEFINES variants is the standard approach for multi-format records in COBOL. Always validate the type before accessing variant fields.

  7. OCCURS DEPENDING ON requires discipline. Always set the DEPENDING ON field before referencing table elements or writing the record. Forgetting this is a common source of subtle bugs.

  8. INDEXED BY outperforms subscripts. Indexes store byte offsets, eliminating multiplication at runtime. Use INDEXED BY for frequently searched or iterated tables.

  9. Use INITIALIZE, not MOVE SPACES, for group items. INITIALIZE respects the type of each subordinate item. MOVE SPACES to a group item corrupts any COMP or COMP-3 fields within it.

  10. Data descriptions are documentation. Well-designed record layouts with meaningful names, consistent prefixes, 88-levels, and clear grouping communicate the business domain to every developer who reads them. Readability is a feature.

  11. Design for the future. Include FILLER for expansion. Use consistent naming prefixes. Group related fields. These practices save enormous maintenance effort over the decades-long life of COBOL systems.

  12. Understand storage alignment. SYNC can improve performance for binary fields but changes physical record size. Avoid SYNC in file records unless all programs agree on the layout.