Host structures in COBOL

A COBOL host structure is a named set of host variables that are defined in your program's WORKING-STORAGE SECTION or LINKAGE SECTION.

Requirements: Host structure declarations in COBOL must satisfy the following requirements:
  • COBOL host structures can have a maximum of two levels, even though the host structure might occur within a structure with multiple levels.
  • A host structure name can be a group name whose subordinate levels name elementary data items.
  • If you are using the IMS coprocessor, do not declare host variables or host structures on any subordinate levels after one of the following items:
    • A COBOL item that begins in area A
    • Any SQL statement (except SQL INCLUDE)
    • Any SQL statement within an included member
    When the IMS precompiler encounters one of the preceding items in a host structure, it considers the structure to be complete.

When you write an SQL statement that contains a qualified host variable name (perhaps to identify a field within a structure), use the name of the structure followed by a period and the name of the field. For example, for structure B that contains field C1, specify B.C1 rather than C1 OF B or C1 IN B.

Host structures

The following diagram shows the syntax for declaring host structures.

Read syntax diagramSkip visual syntax diagram level-11 variable-name . level-223var-1A4
A
Read syntax diagramSkip visual syntax diagramnumeric-usage.PICTUREPICISpicture-stringinteger-decimal-usage.char-inner-variable.SQL TYPE ISTABLE LIKEtable-nameAS LOCATOR.
Notes:
  • 1 level-1 indicates a COBOL level between 1 and 47.
  • 2 level-2 indicates a COBOL level between 2 and 48.
  • 3 For elements within a structure, use any level 02 through 48 (rather than 01 or 77), up to a maximum of two levels.
  • 4 Using a FILLER or optional FILLER item within a host structure declaration can invalidate the whole structure.

Numeric usage items

The following diagram shows the syntax for numeric-usage items that are used within declarations of host structures.

Read syntax diagramSkip visual syntax diagramUSAGEISCOMPUTATIONAL-1COMP-1COMPUTATIONAL-2COMP-2VALUEISconstant

Integer and decimal usage items

The following diagram shows the syntax for integer and decimal usage items that are used within declarations of host structures.

Read syntax diagramSkip visual syntax diagramUSAGEISBINARYCOMPUTATIONAL-4COMP-4COMPUTATIONAL-5COMP-5COMPUTATIONALCOMPPACKED-DECIMALCOMPUTATIONAL-3COMP-3DISPLAYSIGNISLEADING SEPARATECHARACTERVALUEISconstant

CHAR inner variables

The following diagram shows the syntax for CHAR inner variables that are used within declarations of host structures.

Read syntax diagramSkip visual syntax diagramPICTUREPIC IS picture-string USAGEISDISPLAYVALUEISconstant