Creating a question field
Question fields store answers that the user enters when the report is run. The contents of a question field remain static throughout the generation of the report and are discarded when the report is complete.
Question fields allow a single report definition to be used to generate similar yet differing reports, depending on the user’s specific needs or preferences. Some examples of data that might be obtained through question fields are
- desired beginning and ending value for selection purposes.
- other selection criteria, such as minimum balance required.
- balance forward cut-off date or aging date.
- other values to be used in calculations, such as percentage to apply.
- other values that remains constant throughout the report but must be obtained from the user.
|1.||Select Design > Fields to create.|
You can select the Fields to create function from any of the Design function windows, enabling you to create temporary fields while specifying other report information.
When you select Fields to create, the Temporary Fields list is displayed. If you are creating a new report or adding temporary fields for the first time, the Available Field Types list is also displayed.
|2.||Select Question Fields from the Available Field Types list to display the Question Field Type window.|
|3.||Select the type of the data to be entered in your question field:|
Inherit (See Inherited question fields for details on this data type.)
The Question Field Definition window is displayed. See figure 1.
|4.||Enter data in each field as instructed below.|
As an example, let’s assume we want the user to define a range of order dates that will determine which records will be included in the report. First, we need to define two question fields to prompt the user for the starting and ending dates. (See figure 1.) Then we must define selection criteria based on the user’s responses to these prompts. (See Defining selection criteria.) The prompts that will be displayed to the user at report-generation time are shown in figure 2.
Enter a name to identify the field. This name must be unique among all temporary fields. It must begin with a letter and the remaining characters can be letters, digits, underscores (_), or dollar signs ($).
Our first question field is called START and our second called END.
Enter a description for the question field. The default description is the field name. This description is used as the default field header when this field is printed and displays when the field is listed in the Print Fields list, Sort Fields list, or the list of available fields.
We described our fields as Starting date and Ending date.
Enter the question that should prompt the user at report generation time. The maximum size is 40 characters. If you want a colon or other punctuation to display, enter it here.
Our prompt is Starting date: for the first field and Ending date: for the second field.
Select Yes if you want the user to be required to enter a value in this field. The default is No.
We’ve entered No because we want the fields to default to today’s date, so no response is necessary.
Enter the display format that should be used if this question field is selected as a field to print.
To display a list of existing formats, select Field functions > List selections. If the field is not a date or time field, a list of global formats from the repository is displayed. If the field is a date or time format, a list of predefined display formats is displayed. You should always use a format from the format list for date and time fields because if you enter your own format, ReportWriter treats the field as a normal decimal field. (See Appendix B: Date and Time Formats for a list of predefined redisplay formats.)
Select the format you want to use. See Modifying temporary fields for important information about modifying a temporary field’s format after it has been selected as a field to print.
We selected MM/DD/YY from the selection list.
Enter the default value, if any, that will be displayed after the prompt when the question is presented to the user. Maximum size is 80 characters.
If the question field type is date, you can specify the default value in the same ways the user can enter input in the field when the report is run. (This default value string is not converted to the expanded date until the report is run.) See If the value is a date… for a list of valid date formats.
We don’t want to display a default until the user presses Enter, so we’ll just leave this field blank.
Enter a message that will display on the information line at the bottom of the screen. Maximum size is 80 characters. If you don’t enter a message, the information line will be blank.
We’ll tell the user what information we’re looking for with the messages Enter the starting date for your report and Enter the ending date for your report.
|5.||Complete the additional, data-type-specific fields, referring to the details in Detail information for specific question field types.|
|6.||Exit the window to save your new question field definition.|
When you generate your report, ReportWriter creates an input window that contains referenced question fields (selected as a field to print or sort or in a calculation expression, selection criterion, subscript, range, or conditional). The fields are displayed in the window according to your definitions, in the order in which they were created. Each prompt appears on a line by itself, with a field for the user’s response to the right, as shown in figure 2. If all of the questions won’t fit into one input window, ReportWriter creates additional windows.
When report generation begins, these windows are placed on the screen, and the user is prompted to enter data in each field. If the user selects Abandon or Quit from the General menu during input, the input and subsequent report generation are terminated.
Alphanumeric question fields
Enter the length of the question field. If you want to use this value in a selection and you want the comparison to be case sensitive set the length to two characters longer than the desired length, so the user can enclose the value in quotation marks (“ ”).
Just press Enter to enter No if you don’t want the data the user enters to be forced into uppercase letters. To force all data to uppercase, enter Yes.
From the displayed selection window, select Left if you want the display of this field to be left-justified or Center if you want the display to be centered.
Numeric question fields
Enter the length of the question field.
Enter the number of characters to the right of the decimal point. The maximum number of characters after the decimal point is 10. The default number is 0.
If a decimal point is required, select Yes from the selection window. The default is No.
If a negative number is allowed, select Yes from the selection window. The default is No.
Blank if zero
If the question field is to be displayed as blank when it contains a value of 0, select Yes from the selection window. The default is No.
Select how you want the display to be justified: Left or Right.
Date question fields
A selection window containing the date storage formats for this question field is displayed. Select how you want the specified data to be stored by ReportWriter during report generation.
By default, the user must provide input in the format MMDDYY. See If the value is a date… for a list of valid date formats. To change the default date order used when entering dates, set the environment variable RPTDATE. If RPTDATE is set to 1, the input order is DDMMYY. If RPTDATE is set to 2, the input order is YYMMDD.
Default to today
To make this date field default to today’s date when the user presses Enter without entering any data, select Yes. If you don’t want the date to default to today, enter No (the default). Note that when the question field appears, today’s date will not be displayed in the field until the user presses Enter. If a default value is specified, the user can still get today’s date by clearing the question field and pressing Enter.
select how you want the user’s response to be justified: Left or Right.
Time question fields
There are no additional fields. Note that time question fields are limited to a length of 4.
User-defined question fields
Enter the length of the question field. If you want to use this value in a selection and you want the comparison to be case sensitive, set the length to two characters longer than the desired length, so the user can enclose the value in quotation marks (“ ”).
Just press Enter to enter No if you don’t want the data that the user enters to be forced into uppercase letters. To force all data to uppercase, enter Yes.
select how you want the display to be justified: Left or Center.
Enter a string of up to 30 characters to identify your user-defined data type.
Enter a user text string of up to 80 characters to be associated with the question field.
When a report contains a user-defined question field, ReportWriter calls the RPS_DATA_METHOD subroutine to format the data that the user enters in that field. ReportWriter also stores the data in that format, in case the data is later used in a selection comparison. If you don’t write your own RPS_DATA_METHOD subroutine, the data entered in the user-defined question field will be displayed and stored as entered.
An inherited question field adopts the characteristics of another field that you choose. You might want to use this feature when you will be comparing the question field against a field from your data file. When you select the data type Inherit in the Type field, a list of available fields from which to “inherit” characteristics is displayed. Select a field from the list. That field’s characteristics are copied into the question field input window. All inherited fields inherit the description, prompt, required flag, format, default value, information line, and justification of the field selected. Other inherited features are listed below.
If you select
- a date field, the data type for the question field is set to Date and the question field inherits the length and date format of the field you selected, as well as the “Default to today?” flag.
- an alpha field, the question field inherits the data type, length, and uppercase value of the field you selected.
- a decimal field, the question field inherits the data type, length, precision, and decimal required, negative allowed, and blank if zero values of the field you selected.
- an enumerated field, the question field will have an alpha data type and the same length as the enumerated field.
- a user-defined field, the question field inherits the data type, length, and data and text strings of the user-defined field.
An inherited time field always has a length of 4, regardless of the length of the field from which it is inherited.