Identifying a special condition using an expression
In this example, you create a report that displays specific text whenever the data meets certain conditions by using the FORM.CONDITIONS panel with the FORM.DETAIL panel.
About this task
You can format your report in different ways with this method, depending on conditions you want QMF to test for. You specify an expression for any tests or conditions on the FORM.CONDITIONS panel. Then you associate a FORM.DETAIL panel with each test. When the test evaluates to true for the data in a particular row, QMF formats the report the way you specify on the associated FORM.DETAIL panel. When the test does not evaluate to true, you can specify a different format on another FORM.DETAIL panel.
In this example, you create
a condition that prints the text
*** Needs Raise *** in
the report for all employees with salary plus commissions less than
- Run the query and display the report.
For this example, use this query:
SELECT ID, NAME, JOB, DEPT, SALARY, COMM FROM Q.STAFF
- On the QMF command
The FORM.CONDITIONS panel displays.
- Type an ID number for the expression. You can use any number
from 1 through 999.
For this example, you need to create two conditions: one for employees who earn greater than or equal to $17,000.00, and one for employees who earn less than $17,000.00.
Type 1 for the first expression and
2for the second expression.
- In the CONDITIONAL EXPRESSION field,
type the first expression, using form variables to specify the columns
according to their position numbers in the SELECT statement of the
For this example, type the following:
&5 + NULL(&6) >= 17000.00
This is the first condition, which finds each row for which the employee's total earnings (SALARY+COMM) are greater than or equal to $17,000.00.
For the second condition, type the following, which finds each row for which the employee's total earnings are less than $17,000.00:
&5 + NULL(&6) < 17000.00
- Type YES in the PASS
NULLS field to process nulls for this example.
If you want to process nulls, you can create a REXX program like NULL to substitute a 0 (or whatever value is appropriate) for the null value. Then you can use that value in the calculation. A sample NULL program is shown in Displaying a calculated value on a report. The following figure shows how to use the NULL program in the CONDITIONAL EXPRESSION field of the FORM.CONDITIONS panel.
Now that you have defined the conditions you want to display on the report, use the FORM.DETAIL panel to create a report variation for each condition. This type of report formatting is called conditional formatting.
You can select a report variation without associating it with a specific condition, or associate it with a condition such as those you entered on the FORM.CONDITIONS panel.
- On the QMF command
The FORM.DETAIL panel displays.
- In the Select Panel Variation field, type C1 to associate this report format variation with the first condition on the FORM.CONDITIONS panel, where the employee makes greater than or equal to $17,000.00. For this variation, do not enter any detail text.
- Create a report variation for the second condition. For this example, move the cursor to Var 1 of 1.
1and press Enter. (You can also enter
NEXTon the QMF command line.)
A second FORM.DETAIL panel displays.
- In the Select Panel Variation field,
C2to associate this report format variation with the second condition on the FORM.CONDITIONS panel, where the employee makes less than $17,000.00.
- For this example, type
*** Needs Raise ***for the first line of detail block text, as shown in the following figure. Change the alignment to column 60. QMF displays the text on the report when this condition is true.
- Change the width of the report so that the detail block
text appears. On the QMF command
- In the Report text line width field, type 80 to change the report width to 80 columns.
- Press the Report function key to see the changed report,
which is shown in the following figure.