An "Array Data Structure" is a data structure defined with keyword
DIM. An array data structure is like a multiple-occurrence data structure,
except that the index is explicitly specified, as with arrays.
A "Keyed Array Data Structure" is an array data structure
with one subfield identified as the search or sort key.
The array data structure is indexed by (*) and followed
by the specification of the key subfield.
For example, consider array data structure FAMILIES with one scalar
subfield NAME, and another array subfield CHILDREN.
To use the FAMILIES data structure as an array data structure keyed
by NAME, specify FAMILIES(*).NAME.
To use the first CHILDREN element as the key, specify FAMILIES(*).CHILDREN(1).
Notes:
Keyword DIM is allowed for data structures defined as QUALIFIED.
When keyword DIM is coded for a data structure or LIKEDS subfield, array
keywords CTDATA, FROMFILE, and TOFILE are not allowed. In addition, the following
data structure keywords are not allowed for an array data structure:
DTAARA
OCCURS.
For a data structure X defined with LIKEDS(Y), if data structure Y is
defined with keyword DIM, data structure X is not defined as an array data
structure.
If X is a subfield in array data structure DS, then an array index must
be specified when referring to X in a qualified name. In addition, the array
index may not be * except in the context of a keyed array data structure.
Within a fully qualified name expression, an array index
may only be omitted (or * specified) for the right-most name.
An array data structure can be sorted using the SORTA (Sort an Array) operation code.
The array is sorted using one of the subfields as a key.
An array data structure can be searched
using the %LOOKUP built-in function.
The array is searched using one of the subfields as a key.
Here are some examples of statements using keyed array
data structure expressions that are not valid.
Assume that TEAMS is an array data structure with scalar subfield MANAGER and
data structure subfield EMPS.
These statements are not valid because TEAMS is an array data structure.
A non-array key subfield must be specified.
SORTA TEAMS;
SORTA TEAMS(*);
These statements are not valid because TEAMS(1).EMPS is an array data structure.
A non-array key subfield must be specified.
SORTA TEAMS(1).EMPS;
SORTA TEAMS(1).EMPS(*);
This statement is not valid because TEAMS(*).EMPS(*) specifies two different arrays to be sorted.
Only one (*) may be specified.
SORTA TEAMS(*).EMPS(*).NAME;
These statements are not valid because all arrays in the qualified name must be indexed. Both the TEAMS and the EMPS subfields must be indexed;
one must be indexed with (*).