The OVERLAY keyword overlays the storage of one subfield with that
of another subfield, or in a fixed-form definition, with that of the data structure itself.
This keyword is allowed only for data structure subfields.
Specifying OVERLAY(name:*NEXT) positions the subfield at the next available position within the overlaid field. (This will be the first byte past all other subfields prior to this subfield that overlay the same subfield.)
The name parameter must be the name of a subfield defined previously
in the current data structure, or in a fixed-form definition,
the name of the current data structure.
In a free-form definition, use the POS keyword to position
a subfield within the data structure.
D MsgInfo DS QUALIFIED
D MsgId 7
D MsgPrefix 3 OVERLAY(MsgId)
If the subfield name, specified as the first parameter for the OVERLAY keyword, is an array and its element length is longer than the length of the subfield being defined, the array elements of the subfield being defined are not stored contiguously. Such an array is not allowed as the Result Field of a PARM operation or in Factor 2 or the Result Field of a MOVEA operation.
Examples
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... *
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++++++++++++++++++++
D DataStruct DS
D A 10 DIM(5)
D B 5 OVERLAY(A)
D C 5 OVERLAY(A:6)
| A(1) | A(2) | A(3) | A(4) | A(5) | |||||
| B(1) | C(1) | B(2) | C(2) | B(3) | C(3) | B(4) | C(4) | B(5) | C(5) |
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... *
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
D DataStruct DS
D A 5
D B 1 OVERLAY(A) DIM(4)
| A | ||||
| B(1) | B(2) | B(3) | B(4) | |
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... *
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
* Define subfield overlay positions explicitly
D DataStruct DS
D PartNumber 10A
D Family 3A OVERLAY(PartNumber)
D Sequence 6A OVERLAY(PartNumber:4)
D Language 1A OVERLAY(PartNumber:10)
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... *
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
* Define subfield overlay positions with *NEXT
D DataStruct DS
D PartNumber
D Family 3A OVERLAY(PartNumber)
D Sequence 6A OVERLAY(PartNumber:*NEXT)
D Language 1A OVERLAY(PartNumber:*NEXT)