Purpose

SEL-RANGE is used to select a range of records from the primary file (first file defined) for processing.
 

Syntax

SEL-RANGE(operand)
 

Operation

operand is the name of an alphanumeric or wide scratch variable, or value variable, which contains the concatenated key value.
 

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.
 

Example 2

Multiple Field Key - Key Fields STATE-CD (length = 2) and COUNTY-CD (length = 3)

STATE-CD = 04 and $LIMIT = 04015
SEL-RANGE($LIMIT)

The above default logic reads and processes all records from the primary file with a STATE-CD of 04 and COUNTY-CD of 001 through 015. $LIMIT = '15'


SEL-RANGE($LIMIT)

The above default logic reads and processes all records from the beginning of the primary file up to and including those records with a STATE-CD of 15.


STATE-CD = 04 and COUNTY-CD = 016 and $LIMIT = 04099
SEL-RANGE($LIMIT)

The above default logic reads and processes all records from the primary file with a STATE-CD of 04 and a COUNTY-CD ranging from 016 through 099 inclusively.
 

Comment on this topic

Topic ID: 520110

 
 
 

Table of Contents

Index

Glossary

-Search-

Back