Programs that MOVE data to reference-modified, variable-length groups might
produce different results depending on whether the length used for the variable-length
group is evaluated by using the actual length or the maximum length.
You might see a difference if the variable-length group meets all of the
following criteria:
- If it is a receiver
- If it contains its own OCCURS DEPENDING ON object
- If it is not followed by a nonsubordinate item (also referred to as a
variably located data item)
- If it is reference-modified and a length is not specified
For example, Group
VAR-LEN-GROUP-A contains an
ODO object and an OCCURS subject and is followed by a variably located data
item.
01 VAR-LEN-PARENT-A.
02 VAR-LEN-GROUP-A.
03 ODO-OBJECT PIC 99 VALUE 5.
03 OCCURS-SUBJECT OCCURS 10 TIMES DEPENDING ON ODO-OBJECT.
04 TAB-ELEM PIC X(4).
02 VAR-LOC-ITEM PIC XX.
01 NEXT-GROUP.
MOVE ALL SPACES TO VAR-LEN-GROUP-A(1:).
Group
VAR-LEN-GROUP-B contains an ODO object
and an OCCURS subject and is
not followed by a variably located data
item. VAR-LOC-ITEM follows the OCCURS subject, but does
not follow
VAR-LEN-GROUP-B.
01 VAR-LEN-PARENT-B.
02 VAR-LEN-GROUP-B.
03 ODO-OBJECT PIC 99 VALUE 5.
03 OCCURS-SUBJECT OCCURS 10 TIMES DEPENDING ON ODO-OBJECT.
04 TAB-ELEM PIC X(4).
03 VAR-LOC-ITEM PIC XX.
01 NEXT-GROUP.
MOVE ALL SPACES TO VAR-LEN-GROUP-B(1:).
In the above examples, MOVE ALL SPACES TO VAR-LEN-GROUP-A (1:) would
give the same results with any NOCMPR2 program (VS COBOL II,
Release 3.x, VS COBOL II,
Release 4, or Enterprise COBOL).
They all use the actual length in this case.
MOVE ALL SPACES TO VAR-LEN-GROUP-B (1:) would give different
results for the following programs compiled with NOCMPR2:
- VS COBOL II,
Release 3.x uses the actual length of the group as defined by the current
value of the ODO object (the actual length of the group is set to spaces using
the ODO object value).
- VS COBOL II,
Release 4 and Enterprise COBOL use
the maximum length of the group (the entire data item is set to spaces using
the ODO object value).
If a program contains a reference-modified, variable-length group receiver
that contains its own ODO object and is not followed by variably located data
and whose reference modifier does not have a length specified, the following
message is issued:
- IGYPS2298-I
- The reference to variable-length group "data name" will be evaluated using
the maximum length of the group. Execution results might differ from VS COBOL II, Release 3.x.