Selection criteria (6)
The Selection Criteria function allows you to create sets of criteria that File-AID uses to select records in a data file for processing. Option 6 consists of:
- Specifying a selection criteria dataset
- Editing existing or creating new selection criteria members.
File-AID provides selection criteria options and two kinds of selection criteria: formatted and unformatted. The selection criteria options allow you to specify:
- Where to begin record selection
- How to continue (selection intervals)
- When to stop
- Processing direction.
The selection criteria options can be combined with formatted and unformatted selection criteria.
Formatted selection criteria allow you to select records based on data within a field as specified by a record layout. Unformatted selection criteria allow you to select records based on free-form data specifications without using record layouts.
The Global Fields option allows you to define global fields which you can reference in any of the selection criteria sets.
Selection criteria can be existing or temporary. Each can consist of options, formatted, unformatted, or any combination of all three. Selection criteria can be applied in the Browse, Edit, Print, and Compare functions and the Copy and Search/Update utilities.
New and existing selection criteria can be created and maintained in the Selection Criteria function of File-AID (option 6) and in the functions that use selection criteria. Existing selection criteria are stored in a cataloged data set for use in the functions where you can apply them.
Temporary selection criteria are created from within the Browse, Edit, Copy, Print, Compare, or Search/Update function and are valid only for the duration of the function. Temporary selection criteria are not stored for future use unless you explicitly save them with the SAVE command.
With temporary selection criteria, you do not begin by specifying a selection criteria dataset, but proceed directly to creation of the criteria. When you finish creating the temporary selection criteria, they are applied and you continue with the Browse, Edit, Print, or Compare function or Copy or Search/Update utility.
The next section in this topic discusses the screen presentation order and navigation commands available for Selection Criteria. The remainder of the topic describes the screens you use to create new and edit existing selection criteria members.
Unicode Considerations
Selection Criteria accepts layouts including NATIONAL and/or NATIONAL Numeric fields. However, these fields are 'NOT SELECTABLE' and the RO (Relational Operator) column is protected.
Large Keyed Files Considerations
It is recommended that you specify a starting record key and a maximum number of records to select when you are using selection criteria to search for a matching or greater than record key (see Selection Criteria Options). The beginning part of a key or a complete key can be used as the starting record key. Since selection criteria causes File-AID to search records sequentially, providing a starting record key and max number of records to select can greatly reduce the processing time of large keyed files. Set Starting record key and Number of records to select in the Selection Criteria Options, option 1 on the Selection Criteria Menu.
Selection Criteria Considerations When Data Fields May Be Nonexistent
When defining selection criteria with reference to fields where data might not exist in some records, File-AID does not exclude those records from the selection test.
A positive selection operator, such as EQ (equal to), indicates to select the record for processing if the condition is true.
A negative selection operator, such as NE (not equal to), indicates to select the record for processing if the condition is false.
Therefore, when using a negative selection operator, File-AID can select records that don’t have data in those fields.
A typical case of this is seen with fields that are specified in a record layout with OCCURS DEPENDING ON. Some records may have several occurrences of the field, while other records may have only one or none.
For example, consider a record layout called CUSTOMER, having a field called BALANCE defined with up to 12 occurrences, one per month, depending on another field, called DURATION-OF-ACCOUNT. The 12th occurrence will not exist for customers who have had accounts with the company for less than a year.
Example:
Assume you have the following 3 records in your file:
Alice Alvarez has been a customer for 5 months and had monthly balances of 1000, 2000, 3000, 500, and 0.
Bruce Bandler has been a customer for 3 months and had monthly balances of 1000, 2000, and 3000.
Carlos Cramer has been a customer for 5 months and had monthly balances of 1000, 2000, 3000, 0, and 0.
The records look like this:
Alice Alvarez,05,1000,2000,3000,500,0
Bruce Bandler,03,1000,2000,3000
Carlos Cramer,05,1000,2000,3000,0,0
You specify: Select all records with BALANCE(4) NOT EQUAL TO 500
This is interpreted to mean: Select all records NOT having BALANCE(4) = 500
Records with nonexistent data in occurrence 4 will be included in the selection, and you get these records:
Bruce Bandler,03,1000,2000,3000
Carlos Cramer,05,1000,2000,3000,0,0
Since Bruce Bandler does not have a balance for month 4, he does not have a balance that equals 500, and his record is selected as being not equal to 500.
If you want to ensure that only one record is selected, include the DURATION-OF-ACCOUNT variable in the selection criteria:
Specify: Select all records with DURATION-OF-ACCOUNT >= 5 AND BALANCE(4) NOT EQUAL TO 500
This would ensure that records with nonexistent data for the fourth occurrence would not be considered for selection. You would get only one record:
Selection Criteria Considerations: Using GT, LT, and BT with Arrays
For a data item that is not part of an array, specifying BETWEEN (BT) has the effect of selecting all records where that data item is both Greater Than or Equal to the specified lower bound, AND simultaneously Less Than or Equal to the specified upper bound. If you specify instead a pair of conditions, Greater Than (GT) a lower bound, AND Less Than (LT) an upper bound, a data item must meet both criteria in order to be selected. So for individual data items the effect is similar.
When Selecting data from arrays, the BETWEEN operator behaves the same way as it does for individual data items. Use the BETWEEN (BT) operator when you want to select only records containing data items that are simultaneously Greater Than or Equal to a specified lower bound and Less Than or Equal to a specified upper bound.
However, when selecting data in arrays, do not try to select a set BETWEEN specified bounds by specifying a combination of GT and LT.
When you specify GT and LT together for an array, you are really selecting two subsets: All records having data items Less Than (LT) your upper bound AND all records having data items Greater Than (GT) your lower bound. Generally this will include many more records than the set between the two bounds.
Examples
Assume you have the following data records, containing an array with 5 occurrences of a 2-byte numeric field:
Record 1: 05,05,05,05,05
Record 2: 02,04,06,08,10
Record 3: 11,12,13,14,15
If you specify ANY with values BETWEEN 04 and 06, Records 1 and 2 will be selected.
If you specify ANY with values Greater Than 03 AND Less Than 07, all 3 records will be selected. The first 2 records have data items with values Less Than 07, and all 3 records have data items with values Greater Than 03.
Selection Criteria Considerations for Invalid Numeric Data Fields
File-AID/MVS does not consider invalid numeric data to be NOT EQUAL TO (NE) to a numeric constant, because invalid data is not a value that can be evaluated. Use NOT VALID (NV) or NOT VALID UNSIGNED (NU) instead. The logic behind the product behavior can be understood, using the following example:
A numeric field represents a monetary value. If you specify Selection Criteria of: NOT EQUAL TO 0 (zero), you would not expect records with invalid numeric values, to be selected.
This section provides information about the following topics: