Oracle® Reports Building Reports
10g Release 2 (10.1.2)
In this chapter, you will learn about reports that include fields with wrapped text. By following the steps in this chapter, you can generate the report output shown in Figure 15-1.
Figure 15-1 Wrapped field report output
Reports Builder enables you to modify the look of your report in multiple ways. In this example, you will build a break report where the line wraps on word boundaries if it is too long to fit on one line.
This report contains a field which is of a fixed horizontal width, but can expand vertically if the contents of the break field are longer than the specified width. The field's contents are not truncated; rather, the contents will wrap within the specified width of the field, and the field will expand vertically.
For more information on break reports, refer to the Oracle Reports online Help.
This is a simple, one-query break report. In addition, you will add three summary columns.
This report is formatted as a master/detail report. You will modify the layout to add space between sets of information, then change the width of a field so that the break field will wrap.
Optional: You will change the format masks of three fields. You will also use Page Protect in this report. Page Protect causes all objects within a frame or repeating frame to remain together. By specifying Page Protect for the master repeating frame, the customer name and all of its related records will always appear on the same page.
As you build this example report, you will:
Create a query in the Data Model view manually, to include one query and two groups.
Create three summary columns to calculate various totals and percentages for your report.
To see a sample wrapped field report, open the examples folder called
wrappedbreak, then open the Oracle Reports example report named
wrappedbreak.rdf. For details on how to open it, see "Accessing the Example Reports" in the Preface.
To build the example in this chapter, you must have access to the Order Entry sample schema provided with the Oracle Database. If you do not know if you have access to this sample schema, contact your database administrator.
When you create a report, you can either use the Report Wizard to assist you or create the report yourself. In this example, you will use the Data Model view to create your two queries, then use the tool palette to create a data link between the two queries to relate the data tables.
To create the query:
Launch Reports Builder (or, if already open, choose File > New > Report).
In the Welcome or New Report dialog box, select Build a new report manually, then click OK.
In the Data Model view that displays, click the SQL Query tool in the tool palette then click in an open area of the Data Model view to display the SQL Query Statement dialog box.
In the SQL Query Statement field, enter the following
SELECT ALL CUSTOMERS_A1.CUST_FIRST_NAME, CUSTOMERS_A1.CUST_LAST_NAME, ORDERS.ORDER_ID, ORDERS.ORDER_TOTAL FROM CUSTOMERS CUSTOMERS_A1, ORDERS WHERE (ORDERS.CUSTOMER_ID = CUSTOMERS_A1.CUSTOMER_ID) ORDER BY CUSTOMERS_A1.CUST_LAST_NAME
Note:You can enter this query in any of the following ways:
Click OK to display the data model for your new query in the Data Model view. It should look like this:
Figure 15-2 Data Model for the query
In the G_CUST_FIRST_NAME group, click CUST_FIRST_NAME and drag it above the group to create another group.
Click CUST_LAST_NAME, then drag it into the new group, so that the data model now looks like this:
Figure 15-3 Data model with groups
Double-click the new group (G_1) to display the Property Inspector, and set the following properties:
Under General Information, set the Name property to G_Name.
Your data model should now look like this:
Figure 15-4 Data model with new G_Name group
Save your report as
The steps in this section show you how to use the Summary Column tool in the Data Model view to create three summary columns. These columns will calculate the percentage of each order total that the customer has purchased, the total purchases the customer has made, and the percentage of the total sales of all customers.
To create the summary columns:
In the Data Model view, click the Summary Column tool in the tool palette, then click in the G_CUST_FIRST_NAME group to create a summary column.
Double-click the new summary column object (CS_1) to display the Property Inspector, and set the following properties:
Under General Information, set the Name property to PCT.
Under Summary, set the Function property to % of Total, set the Source property to ORDER_TOTAL, set the Reset At property to G_CUST_FIRST_NAME, and set the Compute At property to Report.
Create a second summary column in group G_NAME with the following properties:
Under General Information, set the Name property to CUST_TOTAL.
Under Summary, set the Function property to Sum, set the Source property to ORDER_TOTAL, and set the Reset At property to G_NAME.
Create a third summary column in group G_NAME with the following properties:
Under General Information, set the Name property to PCT_TOTAL_SALES.
Under Summary, set the Function property to Sum, set the Source property to PCT, and set the Reset At property to G_NAME.
Your data model should now look something like this:
Figure 15-5 Data Model with Three Summary Columns
Save your report as
The steps in this section show you how to use the Report Wizard to create the layout and choose how your data will display in your report. Here, you will choose the style of report you want to create, and choose to display the data across the report (hence creating the across group report).
You can create a default layout using the Report Wizard, which deletes any existing layouts in your report and replaces it with the new one.
To create the default layout:
In the Data Model view, right-click on the canvas, then choose Report Wizard.
In the Report Wizard, on the Report Type page, select Create Paper Layout only.
On the Style page, select Group Above.
On the Fields page, click the double right arrows (>>) to move all of the fields to the Displayed Fields list.
On the Labels page, change the field widths as follows:
Click Finish to display your report output in the Paper Design view. It should look something like this:
Figure 15-6 Paper Design view for the wrapped field report
Notice how the complete names do not display. The steps in the next section will show you how to quickly correct this issue.
In this section, you will change the field to expand vertically if the contents of the break field are longer than the specified width. As you can see in Figure 15-6, the width of the fields are fixed, but the names are incomplete. You will also add space to display between each record in the report.
To modify the layout:
In the Object Navigator, double-click the repeating frame icon next to the R_G_NAME node under Paper Layout > Main Section > Body > M_G_Name_GRPFR, to display the Property Inspector.
Under Repeating Frame, change the Vert. Space Between Frames to
0.25, then press Enter.
Close the Property Inspector.
In the Object Navigator, under the Paper Layout node, navigate to Main Section > Body > M_G_NAME_GRPFR > R_G_NAME.
Double-click the icon next to the F_CUST_LAST_NAME field to display the Property Inspector.
Under General Layout, make sure the Vertical Elasticity property is set to Expand, then close the Property Inspector to accept your changes.
Follow steps 5 and 6 for the F_CUST_FIRST_NAME field.
You have now modified the layout of your report to display all the text in the wrapped fields, and added space between the records.
In this section, you will run your report to the Paper Design view so you can see how your report displays.
Click the Paper Design button in the toolbar to display the Paper Design view. Your report runs, then displays in the Paper Design view. It should look like the following:
Figure 15-7 Paper Design view for the wrapped field report
Save your report as
Congratulations! You have successfully created a wrapped field paper report. You now know how to:
manually create a data model.
create a master/detail (or group above) report using the Report Wizard.
modify the layout of your report to wrap the text in a field.
add space between records.
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 Reports Builder or hosted on the Oracle Technology Network (OTN), as described in Section 3.1.1, "Using the Oracle Reports online Help".