Skip Headers

Oracle Reports Building Reports 10g (9.0.4) Part Number B10602-01 |
Home | Contents | Index

# 7
Building a Form Letter Report

#### Figure 7-1 Form letter report output

Text description of the illustration orbrformletter_fin.gif

Reports Builder enables you to build many types of reports, such as form letter, mailing label, tabular, and group above reports. You can learn more about these different types of reports by referring to the Reports Builder online help. This chapter describes the basic elements of a form letter report and how to build a simple form letter report.

#### About form letter reports

Form letter reports contain database values embedded in boilerplate text (boilerplate text can be defined as any text that appears each time the report is run). It can be text generated by Oracle Reports, text you create, or text you import from a file.

#### Concepts

A form letter report is similar to a mailing label report, in that it is a simple report with a special layout style.

##### Data Relationships

- There are no special restrictions on data relationships for a form letter report.

##### Layout

- A default form letter layout style is provided by Oracle Reports. It consists of the field names for the columns you've selected, prefixed by ampersands (&s). The ampersands indicate that they are hidden fields, and are contained within boilerplate and repeating frame objects. You then add the text of the letter to the layout. Oracle Reports prints one record (i.e., one letter) per page.

- Hidden fields, which are the default for a form letter layout, appear in the layout but not the output until referenced. You can do this in the Paper Layout view by typing its name, prefixed by an ampersand. Oracle Reports treats the reference as a normal field.

- In general, if you are embedding a field within boilerplate text (as in a form letter), it is best to hide the field and reference it where desired. The field values will then flow with the text. A field can appear in a report both where placed by default and where referenced, and can be referenced even when not initially hidden. Fields can also be referenced more than once in the same piece of boilerplate text.

#### Example Scenario

In this example, you will use the Report Wizard to build one query to select all of the columns displayed in this report. Oracle Reports will create all other necessary objects, e.g., groups and columns, by default.

To see a sample form letter report, open the examples folder called `formletter`, then open the Oracle Reports example report called `formletter.rdf`. For details on how to open it, see "Accessing the example reports" in the Preface.

##### Table 7-1 Features demonstrated in this example

Feature | Location
--- | ---
Use the Report Wizard to create a form letter report with a paper layout. | Section 7.2, "Use the Report Wizard to create a form letter report"

## 7.1 Prerequisites for this example

To build the example in this chapter, you must have access to the sample schema provided with the Oracle9i database. If you don't know if you have access to this sample schema, contact your database administrator. You should have access to the "Human Resources" portion of the schema to complete this example.

## 7.2 Use the Report Wizard to create a form letter report

When you create a report, you can either use the Report Wizard to assist you or create the report yourself. To build the simple report in this example, you can use the Report Wizard. Using the wizard enables you to define the layout for the report, as well as set the data definition.

In the Report Wizard, on the Text page, you will be able to set up your form letter report exactly the way you want it to appear. On this page of the wizard, you can set up your boilerplate text (e.g., the body of the letter), and use the fields from your data tables to fill in the variable data (e.g., the addressee's name).

#### To create a simple report:

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 Form Letter, 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 ALL EMPLOYEES.LAST_NAME, EMPLOYEES.FIRST_NAME, JOBS.JOB_ID,
       EMPLOYEES.EMPLOYEE_ID, JOBS.JOB_TITLE
       FROM EMPLOYEES, JOBS
       WHERE (EMPLOYEES.JOB_ID = JOBS.JOB_ID)
       ORDER BY EMPLOYEES.EMPLOYEE_ID

   Note: You can enter this query in any of the following ways: Copy and paste the code from the provided text file called `formletter_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.

8. Click Next.

   Note: If you are not already connected to a database, you will be prompted to connect to the database when you click Next. Ensure that you connect to a database that has the appropriate schema for this example. Section 7.1, "Prerequisites for this example" describes the sample schema requirements for this example.

9. On the Text page, format the letter the way you want it to appear. The steps that follow will show you how to make your form letter report look like this:

   Employee: &<FIRST_NAME> &<LAST_NAME>

   Emp. #: &<EMPLOYEE_ID>

   Dear &<FIRST_NAME> &<LAST_NAME>:

   The Human Resources department is updating its records of the company's employees. Currently, our records show your employee number as &<EMPLOYEE_ID>, and that you hold the position of &<JOB_TITLE>. If any of this information is incorrect, please contact the Human Resources department.

   Thank you,

   Human Resources

10. In the Form Letter Text box, type `Employee:`.

11. Click Space four times to enter four spaces.

12. In the Available Fields list, click FIRST_NAME, then click the right arrow (>) to move this field to the Form Letter Text field.

13. Click Space.

14. In the Available Fields list, click LAST_NAME, then click the right arrow (>).

15. Click New Line.

16. In the Form Letter Text field, type `Emp. #:`.

17. In the Available Fields list, click EMPLOYEE_ID, then click the right arrow (>).

18. Click New Line twice.

19. In the Form Letter Text field, type `Dear`.

20. Click Space.

21. In the Available Fields list, click FIRST_NAME, then click the right arrow (>).

22. Click Space.

23. In the Available Fields list, click LAST_NAME, then click the right arrow (>).

24. In the Form Letter Text field, type a colon (:) next to LAST_NAME, then click New Line twice.

25. Type the body of the letter. For the field names, use the Available Fields list to select the appropriate name, then click the right arrow (>) to insert it into the Form Letter Text field. The result should look like this:

    The Human Resources department is updating its records of the company's employees. Currently, our records show your employee number as &<EMPLOYEE_ID>, and that you hold the position of &<JOB_TITLE>. If any of this information is incorrect, please contact the Human Resources department.

    Thank you,

    Human Resources

26. Click Next.

27. On the Template page, select Predefined Template and click Beige, then click Finish to display your report output in the Paper Design view. It should look something like this:

#### Figure 7-2 Paper Design view for the form letter report

Text description of the illustration orbrformletter_fin.gif

1. Save the report as formletterreport_<your initials>.rdf.

## 7.3 Summary

Congratulations! You have successfully created a form letter paper report. You now know how to:

- define a form letter report layout using the Report Wizard.

For more information on any of the wizards, views, or properties used in this example, refer to the Reports Builder online help, which you can access in two ways:

- From the Oracle Technology Network (`http://otn.oracle.com/products/reports/`), click Documentation and navigate to the Reports Builder Online Help for the most recent, hosted online help.

- From Reports Builder, choose Help > Help Contents.

  Note: You can replace your Reports Builder online help with the most recent update by downloading the latest online help set available on the Oracle Technology Network (http://otn.oracle.com/docs/products/reports/). Instructions for replacing your help file are included in the readme.txt in the download file.

| Copyright © 2002, 2003 Oracle Corporation. All Rights Reserved. |
Home | Contents | Index