Support for variable-length arrays

A variable-length array is defined in a COBOL copybook by an OCCURS DEPENDING ON (ODO) clause, and in a PL/I copybook by a dimension attribute where the lower or upper bounds (or both) are defined by REFER options.

The following considerations apply if you are using a template that contains variable-length arrays:
  • A record structure can contain multiple variable-length arrays; however, the fields that define the size of the arrays (the ODO or refer objects) must all be in the record before the first variable-length array item.
  • If any of the following are true:
    • (COBOL copybook only.) The object is out of the range specified by the ODO clause.
    • The record length does not match the calculated length of a record with the number of array items specified by the object.
    then, if you are editing the data set, the prefix area contains the description =LGTH, indicating that the record was not selected because of incorrect length.
  • If you change the value of an object field, then the number of items in the array expands or contracts automatically.

    New items are inserted at the end of the current array (and before any fields that follow the array); numeric items are initialized to zero, and alphanumeric items are initialized to blanks.

    Similarly, items are deleted from the end of the array, and any fields subsequent to the end of the table are not affected.

    For PL/I, the number of items in an array is determined by subtracting the lower bound of the dimension attribute from the upper bound and then adding one. If both the lower and upper bounds are specified using REFER options, changing the value of either of the refer object fields inserts or deletes array items accordingly.

  • (COBOL copybook only.) You cannot change the object field to a value outside the range specified by the ODO clause. (FM/Db2 supports an ODO lower value of 0.)
  • (COBOL copybook only.) Inserting a new record results in a record with the minimum number of array items specified by the ODO definition. For example:
    • Given the following ODO clause:
      ODO-ONE OCCURS 0 TO 10 TIMES DEPENDING ON ODO-CNTRL-ONE.
      if you insert a new record, the ODO-CNTRL-ONE field is initialized to zero, with no ODO-ONE array items in the new record.
    • Given the following ODO clause:
      ODO-ONE OCCURS 5 TO 7 TIMES DEPENDING ON ODO-CNTRL-ONE.
      ODO-CNTRL-ONE is initialized to 5, with five ODO-ONE array items in the new record.
  • (PL/I copybook only.) Inserting a new record results in a record with zero array items. Upper and lower bound refer object fields are initialized to zero.

Related tasks