Defining selection criteria

The “Selections to make” function enables you to choose which fields ReportWriter uses and compares in selecting the records for your report. You can define up to 25 selection criteria per report.

1. Select Design > Selections to display the Selection Criteria list. As you define selections, they are added to this list at the current cursor position.
2. Enter data in each field as instructed below.

We’ll continue the example from Creating a question field, in which we defined two question fields (START and END) to be used as selection criteria for our report.

We need to compare the Order initiated date field to the values the user enters in the START (Start date) and END (End date) fields to determine which records will be included in our report. We want to include all records for which the order date is greater than or equal to the user‑defined start date and less than or equal to the user‑defined end date.

Connect

If this is the first selection criterion you define, skip this field.

If this is the second (or subsequent) selection criterion, enter the connection operator (AND or OR) to indicate how this criterion is connected to the first criterion. AND designates that the two criteria must both be true for a record to match. OR designates that a record will be considered to match if one or the other criterion is true.

Comparisons occur from the top of the list to the bottom. For example,

a AND b OR c

is not the same as

b OR c AND a

To define parenthetical type selection criteria like (a AND b) OR (c AND d), see Evaluation order for parenthetical selection statements.

This field is blank for our first selection criterion. Once we’ve defined the first criterion (that is, that the order date is greater than or equal to the value the user enters in the START field), we’ll select AND as the connection operator, because we want both criteria to be true (not one or the other).

Field

Enter the name of the field you want to use as a selection field. Note that the fields you specify as selection criteria don’t have to be fields to print.

To display the list of available fields that can be used in the conditional, select Field functions > List selections. You can select fields from the list of available fields. See Choosing Fields for more information about selecting fields.

If you select an arrayed field, the Field Subscript window is displayed. See Selecting an arrayed field for details on entering subscript information for an arrayed field.

To use only part of a field in a selection, you can specify a range. See Using only part of a field for comparison (ranging).

For our example, we selected ORD_DATE from the list of available fields. (See figure 1.)

Compare

Select one of the comparison operators:

EQ = Equal to

NE = Not equal to

LE = Less than or equal to

LT = Less than

GE = Greater than or equal to

GT = Greater than

For the start date we selected GE.

Value

Enter either a specific value or the name of a field to which data in your records will be compared. For a detailed explanation of the rules that apply to comparisons and the type of data you can enter in this field, see Completing the Value field.

We selected START from the list of available fields for this criterion.

3. Exit the window to enter your selection criterion in the Selection Criteria list.
4. To define any additional selection criteria, select Selection functions > Add selection.

Completing the Value field

The following rules apply to comparisons.

If the field is numeric…

The value can be one of the following:

To display the list of available fields, select Field functions > List selections. See Choosing Fields for more information about selecting fields.

Decimal values are displayed in selection criteria in parentheses—for example, (1) or (FLD:F1).

If the field is alpha, user, or enumerated…

The value can be one of the following:

When used in a string that’s enclosed in double quotes, an asterisk is treated as a regular character, not a wildcard character. (For example, if you enter “*abc”, ReportWriter searches for that exact string: *abc.)

One form of wildcard matching is supported for case‑sensitive strings. For example, “abc”* represents any character string that starts with abc, and the comparison is case sensitive.

Asterisks and question marks can be used together. For example, ?ab* represents any string whose second and third characters are a and b.

When used in a string that’s enclosed in quotation marks, a question mark is treated as a regular character. (For example, if you enter “?abc”, ReportWriter searches for that exact string: ?abc.)

Alpha values are displayed in selection criteria in curly braces (for example, {ABC} or {FLD:F2}).

Additionally, if the field is user‑defined and you enter a string value (rather than a field), this value is passed to the RPS_DATA_METHOD subroutine. RPS_DATA_METHOD is a user‑replaceable subroutine in which you can reformat the input data. ReportWriter also stores the data in that format for future selection comparisons.

If the value is a date…

You can enter it in a variety of ways. For example, if today is August 6, 2013, the following date formats are all valid:

08‑06‑13

8‑6‑13

08/06/93

8/6/93

080613

Aug 6 2013

Aug 6 13

The default date is today’s date. If you omit any portion of the date, ReportWriter fills it in for you. For example, if you omit the year, ReportWriter fills in the current year; if you omit the month, ReportWriter fills in the current month; and so on. Therefore, formats like the following are also valid for the date August 6, 2013:

RETURN (no entry)

6

//2013

8/6

/6/13

Aug

Aug 6

The RPTDATE environment variable can be set to change the default order used when entering dates. If RPTDATE is not set or is set to 0, the order is month, day, year. If RPTDATE is set to 1, the order is day, month, year. If RPTDATE is set to 2, the order is year, month, day.

Asterisks (*) and question marks (?) are not allowed in date fields.

Date values are displayed in selection criteria in parentheses, for example, (1/1/13) or (FLD:F3).

If the value is a time…

You must enter the actual storage format. Time values are displayed in selection criteria in parentheses, for example, (123000).

If you press enter without typing any data…

The following default values are entered in the specified types of fields:

Field type

Value

Alpha

Enumerated

User

“ ”

(This tells ReportWriter to select only records in which the field is empty.)

Decimal

Implied‑decimal

Time

0

Date

Today’s date

Evaluation order for parenthetical selection statements

When specifying selection criteria, you can define parenthetical type selection criteria such as (a AND b) OR (c AND d). As with other selection statements, ReportWriter performs comparisons from the top of the list to the bottom.

For example, this:

(CMCLNT.CCOPEN).GT.(6/01/13)

(Account opened after June 1)

AND (CMCLNT.CCHOUR).EQ.(1)

(1‑hour time difference)

OR (CMCLNT.CCHOUR).EQ.(2)

(2‑hour time difference)

OR (CMCLNT.CCHOUR).EQ.(3)

(3‑hour time difference)

is not the same as this:

(CMCLNT.CCHOUR).EQ.(1)

OR (CMCLNT.CCHOUR).EQ.(2)

OR (CMCLNT.CCHOUR).EQ.(3)

AND (CMCLNT.CCOPEN).GT.(6/01/13)

If you use the first example as a selection statement, a record is selected if any of the following are true:

If you use the second example, a record is selected only when the time difference is one, two, or three hours and the account was opened after June 1, 2013.

The same precedence rules apply to conditional statements that are assigned to print fields, calculation fields, and break lines.

Defining selection criteria by copying

You can use the copy function to add a selection that’s similar to an existing one.

1. Highlight the selection you want to copy.
2. Select Selection functions > Copy selection. The Criterion Definition window is displayed with a copy of the current selection criterion.
3. Edit any value, including the connect or comparison operators.
4. Exit the window when you have finished making changes. The new selection criterion is added to the Selection Criteria list.