Create the Report Layout Using the Report Block Wizard

40-12 Oracle Reports Users Guide to Building Reports

40.5 Add Vertical Space Between Records

To make the report more readable, you can add space between a certain number of records. To do so, you first create the parameter that determines the number of records between which the space will display. Then, you create a summary column in the data model that counts the number of records. You will then modify the paper layout of your report so that the vertical elasticity is variable. Finally, you will create a format trigger that will display the space between the user-determined number of records.

40.5.1 Create a user parameter

The parameter you will create in this section will determine how many records are displayed before an extra space is printed. Since this parameter is a user parameter, the user can change this value at runtime. To create a user parameter:

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 SPACE. ■ Under Parameter, set the Datatype property to Number, and set the Initial Value property to 5. The user parameter now displays in the Object Navigator: Figure 40–13 User Parameter in the Object Navigator

4. Save your report.

40.5.2 Create a summary column that counts the number of records

In this section, you will create a summary column in the data model that counts the number of employee records. This information will then be used by the format trigger to determine where to add extra space. Note: By giving the user parameter an initial value, the user can simply run the report without changing the parameters, and a space will display between every five records. Building a Report that Includes PLSQL 40-13 To create a summary column:

1. In the Object Navigator, double-click the view icon next to the Data Model node

to display the Data Model view. 2. In the Data Model view, click the Summary Column tool in the tool palette, then click in the G_FIRST_NAME group beneath the TOTAL_COMP formula column to create a new summary column: Figure 40–14 Data Model with new summary column

3. 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 CNT_COLUMN. ■ Under Summary, set the Function property to Count, and set the Source property to FIRST_NAME.

4. Save your report.

40.5.3 Modify the layout

To allow Reports Builder to insert the vertical spacing, you must modify the layout of your report. To add vertical elasticity: 1. Click the Paper Layout button in the toolbar to display the Paper Layout view. 2. Click the Flex On button in the toolbar.

3. In the Paper Layout view, click the repeating frame associated with G_FIRST_

NAME . 4. Click the center handle of the frame and drag the frame downward to create additional space. This additional space should be slightly larger than what you want to see between the sets of records. Note: If you cannot find the repeating frame in the Paper Layout view, you can click R_G_FIRST_NAME in the Object Navigator. The associated repeating frame will be selected in the Paper Layout view. 40-14 Oracle Reports Users Guide to Building Reports

5. With the repeating frame selected, choose Tools Property Inspector to display

the Property Inspector, and set the following properties: ■ Under General Layout, set the Vertical Elasticity property to Variable. 6. In the Paper Layout view, click the Rectangle tool in the tool palette, and draw a rectangle below the fields in the newly created space. 7. Make sure the new rectangle has no fill and no line so that it is not visible. The following image shows the new layout with the invisible rectangle: Figure 40–15 Layout with added vertical space

8. Save your report.

40.5.4 Create a format trigger

Now that you have adjusted the layout, you can create a format trigger based on the new boilerplate rectangle you created in the previous section. This format trigger will display this space after every set number of records, determined by the user parameter. To create a format trigger on the boilerplate rectangle: 1. While the rectangle is selected in the Paper Layout view, press F11 on your keyboard or choose Tools PLSQL Editor to display the PLSQL Editor. 2. In the PLSQL Editor, use the template to enter the following PLSQL code: function B_1FormatTrigger return boolean is begin If :CNT_COLUMN mod :SPACE = 0 then returnTRUE; else returnFALSE; end if; end;

3. Click Compile.

4. When the code is compiled without errors, click Close.

5. Save your report.

40.6 Run Your Report to Paper

Now that you have added space and created your format trigger, your report should display with space after every five records or the number of records you specify in the Parameter Form. Note: You can enter this code by copying and pasting it from the provided text file called plsql_code.txt. This code is for the Format Trigger. Building a Report that Includes PLSQL 40-15 To run your report: ■ Click the Run Paper Layout button in the toolbar. When the Parameter Form displays, click the Run button in the toolbar. Your report displays in the Paper Design view, and should look something like this: Figure 40–16 Final PLSQL example report

40.7 Summary

Congratulations You have successfully built a report that uses an external PLSQL library to calculate employee bonuses, which you can now use in other reports by simply referring to it. You now know how to: ■ create and use an external PLSQL library. ■ create a default layout in the Report Wizard. ■ add vertical space between a user-determined number of 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 .