The OVERLAY keyword overlays the storage of one subfield with that of another subfield, or with that of the data structure itself. This keyword is allowed only for data structure subfields.
The Name-entry subfield overlays the storage specified by the name parameter at the position specified by the pos parameter. If pos is not specified, it defaults to 1.
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 following rules apply to keyword OVERLAY:
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)
Allocation of fields in storage:
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)
Allocation of fields in storage:
A | ||||
B(1) | B(2) | B(3) | B(4) |
The following example shows two equivalent ways of defining subfield overlay positions: explicitly with (name:pos) and implicitly with (name:*NEXT).
*.. 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)