Remarks
|
If SEL-RANGE is used in a Global Logic, and operand is a scratch variable, that scratch variable must be defined in the EXTERN statement.
For Company Division files, the @COMP system variable must be included in the argument to SEL-RANGE to force PROIV to initialise correctly the key to be used. Unless @COMP is included, the SEL-RANGE will not work as intended. E.g.:
$END_KEY = @COMP + $SCRATCH)
SEL-RANGE ($END_KEY)
The key value is the upper limit of the range of records to be selected. The lower limit is the beginning of the file or a beginning key value as specified in default logic. Note also that in the above example the Scratch Variable used in the SEL-RANGE, $END_KEY must not subsequently be altered because its value is used later in the timing cycle.
SEL-RANGE can be used only in logic in the Key Mapping on Sort/Select event process point. If used in any other logic, the statement is treated as a comment.
Processing of the primary file starts at a record containing a key specified in the logic. If no beginning key value is specified, processing begins with the first record in the file.
Processing of the primary file terminates when the value of the key field(s) exceeds the value specified as the operand.
The operand end key value may be shorter in length than the file key. If so the shorter length is used for the comparison (left to right).
A numeric field, (i.e. one with data type NK), cannot be specified as part of the key referenced by operand.
|
Example 1
|
Single Element Key - Key Field CUSTNO (length = 8)
CUSTNO = M
$RANGE = P
SEL-RANGE($RANGE)
The above default logic reads and processes all records from the primary file that have customer numbers which begin with M, N, O, and P.
RANGE = P
SEL-RANGE($RANGE)
The above default logic reads and processes all records from the beginning of the primary file up to and including those customer numbers that begin with P.
|