Add a Percentage Ranking

Building a Ranking Report 34-9

5. On the Groups page, click G_CNAME2 in the Available Groups list and click

Down to specify its Print Direction and move this group to the Displayed Groups list, then click Next. 6. On the Fields page, click the following fields and click the right arrow to move them to the Displayed Fields list, then click Next: ■ CNAME2 ■ SUM_AMT2 7. On the Labels page, change the labels and field widths as follows, then click Next:

8. On the Template page, select No template. If you were to select a template, it

would override the template of the previous layout, then click Finish to display your report layout in the Paper Layout view.

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

10. In the Paper Layout view, click the Text tool in the tool palette.

11. Click directly above the label Customer Name in the new layout and type the

following text in the new boilerplate text object: Top CUTOFF_PCT Percent of Sales: 12. Move to an open area of the Paper Layout view and click the mouse button to exit text mode. Notice that the text object you just created is still selected, you can now adjust its positioning with the arrow keys. 13. If the text is not already bold, click the Bold button in the toolbar to make it bold.

14. Shift-click the labels Customer Name and Total Purchases so that they are

selected simultaneously with the object you just created. 15. Click the Underline button in the toolbar. 16. Click in an open area of the Paper Layout view to deselect everything.

17. Double-click field F_SUM_AMT2 to display the Property Inspector, and set the

following properties: ■ Under Field, set the Format Mask property by typing: -NNN,NN0.00 To add the logic for the percentage cutoff:

1. In the Object Navigator, type R_G_CNAME2 in the Find field to locate that

repeating frame.

2. Double-click the properties icon next to R_G_CNAME2 to display the Property

Inspector, and set the following properties: ■ Under Advanced Layout, double-click the Format Trigger property field to display the PLSQL Editor. 3. In the PLSQL Editor, use the template to enter the following PLSQL code: function R_G_CNAME2FormatTrigger return boolean is Fields Labels Width CNAME2 Customer Name 35 SUM_AMT2 Total Purchases 15 34-10 Oracle Reports Users Guide to Building Reports begin if :r_pct = :cutoff_pct then returnTRUE; else returnFALSE; end if; end; To update the Parameter Form for the new percentage parameter:

1. Choose Tools Parameter Form Builder.

2. In the Parameter Form Builder dialog box, scroll down the list of parameters until you find CUTOFF_PCT, and change its label to: Top Percentage :

3. Click OK.

4. Click the Run Paper Layout button in the toolbar. 5. In the Runtime Parameter Form: ■ For of Top Customers, type 5. ■ For Top Percentage , type 80. 6. Click the Run Report button in the toolbar. Figure 34–6 Tabular report output restricted by number and percentage of customers

34.7 Summary

Congratulations You have successfully created a ranking report. You now know how to: ■ create a data model and a tabular layout. ■ create parameters and group filter to control the ranking criteria. ■ add a layout object to display the parameter value in the report output. ■ create a Parameter Form that only displays the parameter you want users to set. 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 Percentage Cutoff. Building a Ranking Report 34-11 ■ add a percentage ranking. For more information on any of the wizards, views, or properties used in this example, refer to the Oracle Reports online Help, which is available in Oracle Reports Builder or hosted on the Oracle Technology Network OTN, as described in Section 4.1.1, Using the Oracle Reports online Help . 34-12 Oracle Reports Users Guide to Building Reports