With iSUB defining, you can create a defined array that consists of designated elements from a base array. The defined and base arrays must be arrays of scalars, may comprise any data types, and must have identical attributes (apart from the dimension attribute).
The defined variable must have the dimension attribute. In the declaration of the defined array, the base array must be subscripted, and the subscript positions cannot be specified as asterisks.
A iSUB variable is a reference, in the subscript list for the base array, to the dimension of the defined array. At least one subscript in the base array's subscript-list must be an iSUB expression which, on evaluation, gives the required subscript in the base array. The value of i ranges from 1 to n, where n is the number of dimensions in the defined array. The number of subscripts for the base array must be equal to the number of dimensions for the base array.
If a reference to a defined array does not specify a subscript expression, subscript evaluation occurs during the evaluation of the expression or assignment in which the reference occurs.
The value of i is specified as an integer. Within an iSUB expression, an iSUB variable uis treated as REAL FIXED BINARY(31,0) variable.
A subscript in a reference to a defined variable is evaluated even if there is no corresponding iSUB in the base variable's subscript list.
An iSUB-defined variable may not appear in the data-list of a GET DATA or PUT DATA statement.
Examples:
DCL A(10,10) FIXED BIN
X(10) FIXED BIN DEF( A(1SUB,1SUB) );
X is a one-dimensional array that consists of the diagonal of A: X(i) refers to the same storage as A(i,i).
DCL B(5,10) FIXED BIN
Y(10,5) FIXED BIN DEF( A(2SUB,1SUB) );
Y is a two-dimensional array that consists of the elements of B with the bounds transposed: Y(i,j) refers to the same storage as X(j,i).