Prerequisites for This Example Create a Data Model and Tabular Layout

34-4 Oracle Reports Users Guide to Building Reports To create parameters and add a group filter:

1. In the Object Navigator, under the Data Model node, click the User Parameters

node.

2. Choose Edit Create to create a new user parameter under the User Parameters

node. 3. If the Property Inspector is not already displayed, right-click the new user parameter P_1, then choose Property Inspector to display the Property Inspector, and set the following properties: ■ Under General Information, set the Name property to CUTOFF_CNT. ■ Under Parameter, set the Datatype property to Number, set the Width property to 1, and set the Initial Value property to 3. 4. Repeat the steps above to create another user parameter, using the following property settings this time: ■ Under General Information, set the Name property to INCR_CNT. ■ Under Parameter, set the Datatype property to Number, set the Width property to 3, and set the Initial Value property to 0.

5. In the Object Navigator, under the Data Model node, expand the Groups node,

then double-click the properties icon next to the G_CNAME group to display the Property Inspector, and set the following properties: ■ Under Group, set the Filter Type property to PLSQL, then click the PLSQL Filter property field to display the PLSQL Editor. 6. In the PLSQL Editor, use the template to enter the following PLSQL code: function G_CNAMEGroupFilter return boolean is begin :incr_cnt:=:incr_cnt+1; if :incr_cnt = :cutoff_cnt then return TRUE; else returnFALSE; end if; end;

7. Click Compile.

8. Click Close.

This filter increments the counter by 1 each time a record in G_CNAME is fetched, then compares the counters value to the specified cutoff. When the counter exceeds the cutoff, no more records are fetched. Note: You can enter this code by copying and pasting it from the provided text file called rank_code.txt. This code is for the Group Filter. Building a Ranking Report 34-5 9. Click the Run Paper Layout button in the toolbar to display the Runtime Parameter Form, which enables you to change the default values for CUTOFF_ CNT and INCR_CNT. 10. Click the Run Report button to display the report output in the Paper Design view. 11. Save your report as rank_your_initials.rdf. Figure 34–3 Tabular report output restricted to top three customers

34.4 Add a Layout Object for a Parameter

As a way for users to quickly tell the number of customers displayed in the list, you need to display the value of CUTOFF_CNT in the report. To perform this task, you will create a boilerplate text object that references the parameter.

1. In the Object Navigator, double-click the view icon next to the Paper Layout node

to display the Paper Layout view. 2. Position the Paper Layout view and Object Navigator side-by-side so that they are visible simultaneously.

3. In the Object Navigator, in the Find field, type M_G_CNAME_GRPFR.

4. Click M_G_CNAME_GRPFR in the Object Navigator to select it in the Paper

Layout view. 5. Click the title bar of the Paper Layout view to make it the active window.

6. Select M_G_CNAME_GRPFR and all of its contents by press CTRL-A on your

keyboard.

7. Use the down arrow key to move the items down about 1 inch 2.5 centimeters.

8. From the font lists in the toolbar, choose Arial Western, point size 10.

9. Click the Text tool in the tool palette.

Tip: Notice that, if the Paper Design view is still open while you add this logic, the report now returns no records in the Paper Design view. To fix this issue, you should display one of the other views for example, the Data Model view and then come back to the Paper Design view. You will be prompted by the Runtime Parameter Form to enter values for the two parameters, INCR_CNT and CUTOFF_CNT. Note: You can also use the Find field in the Object Navigator to locate specific objects. When you select an item in the Object Navigator while the Paper Layout view is displayed, the corresponding object is selected in the Paper Layout view.