Controlling the number of rows
Methods are provided to set and get the total number of rows in a read-only or editable list of records.
Set the number of rows when using a static array
When using a static array in DISPLAY ARRAY
or INPUT
ARRAY
, you must specify the actual number of rows with the SET_COUNT()
built-in function or with the COUNT
dialog attribute. Both of them are only taken
into account when the interactive instruction starts.
DEFINE arr ARRAY[100] OF ...
... (fill the array with x rows)
CALL set_count(x)
DISPLAY ARRAY arr TO sa.*
...
END DISPLAY
When using multiple list subdialogs in a DIALOG
block, the
SET_COUNT()
built-in function is unusable, as it defines the
total number of rows for all lists. The only way to define the number of rows when
using a static array in multiple dialogs is to use the COUNT
attribute.
Consider using dynamic arrays instead of static arrays.
Set the number of rows when using a dynamic array
DISPLAY ARRAY
or INPUT
ARRAY
, the total number of rows is automatically defined by the array
variable
(array.getLength()
).DEFINE arr DYNAMIC ARRAY OF ...
... (fill the array with x rows)
DISPLAY ARRAY arr TO sa.*
...
END DISPLAY
However, special consideration has to be taken when using the paged mode of
DISPLAY ARRAY
. In this mode, the dynamic array only holds a
page of the complete row set shown to the user: In paged mode, you must specify the
total number of rows with the ui.Dialog.setArrayLength()
method.
Defining the maximum number of rows in INPUT ARRAY
In an INPUT ARRAY
dialog allowing row creation with the insert or append
actions, there is by default no limit for the total number of rows. To specify the maximum number of
rows an INPUT ARRAY can accept, define the MAXCOUNT
attribute:
Get the number of rows in a list
To get the current number of rows in a DISPLAY ARRAY
or
INPUT ARRAY
, use either the ui.Dialog.getArrayLength()
or the ARR_COUNT()
function.
getArrayLength()
method can be used inside or outside the
context of the list dialog, as it takes the screen array as parameter to identify the list dialog.
For example, when implementing a DIALOG
block with two DISPLAY
ARRAY
subdialogs, you can query the number of rows of a list in the code block of another
list
controller:DIALOG ...
DISPLAY ARRAY arr1 TO sa1.*
ON ACTION check
IF DIALOG.getArrayLength("sa2")] > 1 THEN
...
END IF
END DISPLAY
DISPLAY ARRAY arr2 TO sa2.*
END DISPLAY
END DIALOG
ARR_COUNT()
function must be used in the context of the
DISPLAY ARRAY
or INPUT ARRAY
dialog, or just
after executing such dialog. For example, it can be used just after an INPUT
ARRAY
dialog, to get the number of rows left in the
list:INPUT ARRAY arr FROM sa.*
...
END INPUT
IF NOT int_flag THEN
FOR i=1 TO arr_count()
...
END FOR
END IF
The ARR_COUNT()
function returns the number of rows for the last
executed dialog, until a new list dialog is started.