POSITION attribute
The POSITION attribute can be used only with string-overlay defining and specifies the bit, character, graphic or widechar within the base variable at which the defined variable is to begin.
n = N(b) - N(d) + 1
where N(b) is the number of bits, characters, graphics or widechars in the base variable, and N(d) is the number of bits, characters, graphics or widechars in the defined variable.
The expression is evaluated and converted to an integer value at each reference to the defined item.
If the POSITION attribute is omitted, POSITION(1) is the default.
- The POSITION attribute can contain only an integer.
- The base variable must not be subscripted.
The base variable must refer to data in connected storage.
DCL C(10,10) BIT(1),
X BIT(40) DEF C POS(20);
DCL E PIC'99V.999',
Z1(6) CHAR(1) DEF (E),
Z2 CHAR(3) DEF (E) POS(4),
Z3(4) CHAR(1) DEF (E) POS(2);
DCL A(20) CHAR(10),
B(10) CHAR(5) DEF (A) POSITION(1);
The first 50 characters of B consist of the first 50 characters of A. POSITION(1) must be explicitly specified. Otherwise, simple defining is used and gives different results.