DIM(*AUTO:max) and DIM(*VAR:max) declare arrays with a maximum dimension but a current size that changes at runtime.
DIM(*AUTO:max): The array grows automatically when elements are assigned beyond the current size.%ELEMreturns the current number of active elements.DIM(*VAR:max): The current size must be explicitly set via%ELEM(arr) = n. Elements beyond the current size are logically inaccessible.
DCL-S Names CHAR(20) DIM(*AUTO:100);
Names(1) = 'Alice';
Names(2) = 'Bob';
DSPLY %CHAR(%ELEM(Names)); // 2 (current active count)
DSPLY %CHAR(%ELEM(Names:*MAX)); // 100 (maximum dimension)
The maximum dimension bounds the storage; %ELEM reports the current active element count.