Modify the Layout of the Report Run your Report to Paper Summary

Building a Wrapped Field Report 15-7

15.7 Summary

Congratulations You have successfully created a wrapped field paper report. You now know how to: ■ manually create a data model. ■ create a masterdetail 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 Oracle Reports Builder or hosted on the Oracle Technology Network OTN, as described in Section 4.1.1, Using the Oracle Reports online Help . 15-8 Oracle Reports Users Guide to Building Reports Building a Header and Footer Report 16-1 16 Building a Header and Footer Report In this chapter, you will learn about reports that include headers and footers. By following the steps in this chapter, you can generate the report output shown in Figure 16–1 . Figure 16–1 Group left report output with header and footer This report has a page header, Employee Summary Report, printed in the upper margin area of every page of the report, and a footer, Total Salary for Department number: sum_sal, printed at the end of the list of employee information for each department. Concepts ■ A header and footer report contains boilerplate or fields in its header or footer. To create headers and footers in your report, add the boilerplate or field in the Paper Layout view of the Report Editor. If you create a field, make sure there is only one value for it. Otherwise, Reports Builder will not know which of the different values you want to print. ■ How often the boilerplate and fields appear and whether they are headers or footers depends on where you position them in the layout. Any boilerplate that is positioned within a repeating frame will print once every time the repeating frame prints. Boilerplate that is outside of all repeating frames will print once for the entire report. 16-2 Oracle Reports Users Guide to Building Reports Data Relationships This report uses one query to select all necessary columns. Youll add a break by assigning a column to a second group. Layout This report uses a group left layout with modifications. Youll increase the size of a repeating frame and the frame enclosing it to ensure they are large enough to contain a footer, then add the footer. Then youll modify the vertical spacing of a repeating frame to add space between each instance of it. Example Scenario In this example, you will create a report that displays and summarizes employee data by department. To make the report more readable, you decide to add a header to each page and to add footer for each master record. As you build this example report, you will: ■ Create a Data Model and a Group Left Layout . ■ Move a Summary to move the departmental summary closer to its label. ■ Add a Page Heading that repeats on all pages. ■ Add White Space and Format Fields to format monetary values. To see a sample report with a header and footer, open the examples folder named headerfooter, then open the Oracle Reports example named headfoot.rdf. For details on how to access it, see Accessing the Example Reports in the Preface.

16.1 Prerequisites for This Example

To build the example in this chapter, you must have access to the Human Resources sample schema HR provided with the Oracle Database. If you do not know if you have access to this sample schema, contact your database administrator.

16.2 Create a Data Model and a Group Left Layout

When you are creating a single-query report, such as this one, you can use the Report Wizard to create the data model and layout simultaneously. To create a data model and layout:

1. Launch Reports Builder or, if already open, choose File New Report.

2. In the Welcome or New Report dialog box, select Use the Report Wizard, then

click OK. 3. If the Welcome page displays, click Next. 4. On the Report Type page, select Create Paper Layout Only, then click Next. 5. On the Style page, type a Title for your report, select Group Left, then click Next. 6. On the Data Source page, click SQL Query, then click Next. 7. On the Data page, enter the following SELECT statement in the Data Source definition field: SELECT FIRST_NAME, LAST_NAME, EMPLOYEE_ID, SALARY, DEPARTMENT_ID FROM EMPLOYEES ORDER BY DEPARTMENT_ID, EMPLOYEE_ID Building a Header and Footer Report 16-3

8. Click Next.

9. On the Groups page, click DEPARTMENT_ID and click the right arrow to

move this field to the Group Fields list, then click Next. 10. On the Fields page, click the double right arrows to move all of the fields to the Displayed Fields list, then click Next.

11. On the Totals page, click SALARY, then click Sum.

12. Click Next.

13. On the Labels page, change the labels as follows, then click Next:

This step will add a footer to each instance of the master repeating frame departments.

14. On the Template page, click Finish to display your report output in the Paper

Design view. It should look something like this: Note: You can enter this query in any of the following ways: ■ Copy and paste the code from the provided text file called headfoot_code.txt into the Data Source definition field. ■ Click Query Builder to build the query without entering any code manually. ■ Type the code in the Data Source definition field Note: If you are not already connected to a database, you will be prompted to connect to the database when you click Query Builder or Next. Ensure that you connect to a database that has the appropriate schema for this example. Section 16.1, Prerequisites for This Example describes the sample schema requirements for this example. Fields Labels DEPARTMENT_ID Department SumSALARYPerDEPARTMENT_ID Total Salary for Department DEPARTMENT_ID: Note: The DEPARTMENT_ID column is part of the data model so you need to reference DEPARTMENT_ID in the footer label using DEPARTMENT_ID.