12 - Creating Reports

Top  Previous  Next

Overview

The last item to cover is adding reports. First, we’ll create a simple customer list to introduce you to the Report Designer. Then we’ll create an Invoice Report to demonstrate how you can easily create Relational reports with multi-level group breaks, group totals, and page formatting. Then we’ll copy the Invoice Report and limit the copy to print invoice for only one customer at a time.

 

Starting Point:

LCLESSON.APP should be open, and the Application Tree displayed.

 

Updating the Main Menu

First, we need to add menu selections so the user can call the reports, and so the Application Generator will call the appropriate "ToDo" procedures.

 

Add a menu item

1.

RIGHT-CLICK on the Main procedure in the Application Tree dialog and choose Window from the popup menu.

2.

RIGHT-CLICK on the Menubar on the window and select Edit Menu. The Menu Editor is now open.

3.

Highlight the P&rint Setup item in the Menu Editor list.

4.

Press the Add New Item (Insert)  button.

5.

Type Print &Customer List in the Text property entry, then press the TAB key.

 

 

Specify the new item’s action

1.

RIGHT-CLICK on the Print &Customer List item in the Menu Editor list, and select the Actions item from the popup menu.

2.

Choose Call a Procedure from the When Pressed drop list.

3.

Type CustReport in the Procedure Name entry.

4.

Check the Initiate Thread box.

5.

Press OK to close the Actions (?ITEM1 Prompts) dialog.

 

Add a second menu item

1.

Highlight the Print &Customer List item in the Menu Editor list, and then press the Add New Item (Insert)  button.

2.

Type Print &All Invoices in the Text property entry, then press the TAB key.

3.

RIGHT-CLICK on the Print &All Invoices item in the Menu Editor list, and select the Actions item from the popup menu.

4.

Choose Call a Procedure from the When Pressed drop down list.

5.

Type InvoiceReport in the Procedure Name entry.

6.

Check the Initiate Thread box.

 

Add a third menu item

1.

Highlight the Print &All Invoices item in the Menu Editor list, and then press the Add New Item (Insert)  button.

2.

Type Print &One Customer’s Invoices in the Text property entry, then press the TAB key.

3.

RIGHT-CLICK on the Print &One Customer’s Invoices item in the Menu Editor list, and select the Actions item from the popup menu.

4.

Choose Call a Procedure from the When Pressed drop down list.

5.

Type CustInvoiceReport in the Procedure Name entry.

6.

Check the Initiate Thread box.

7.

Press the Save and Close button to close the Menu Editor.

8.

Press the Save and Close button to close the Window Designer.

9.

Press the Save and Close button in the Window Designer Editor to return to the Application Tree.

10.

Save your work by pressing the Save button on the IDE toolbar.

 

Creating the Report

Now you can create the first report, using the Report Designer.

1.

Highlight the CustReport procedure in the Application Tree.

2.

Press the Properties  button.

3.

Choose the Defaults tab and then highlight Report (Paper size Letter – Portrait) in the Select Procedure Type dialog. Press the Select button.

4.

Press the Report button in the Procedure Properties dialog.

5.

Press the Designer button to open the Report Designer.

The Report Designer appears. Here you can visually edit the report and its controls. The Report Designer represents the four basic parts of the REPORT data structure by showing the Page Header, Detail, Page Footer, and Form as four "bands." Each band is a single entity that prints all together. See the User’s Guide chapter on Using the Report Designer for more information on the parts of the report and how the print engine generates them.

For this report, you’ll place page number controls in the header, then place the columns from the Customer table in the Detail band.

 

Place a string constant

1.

With the Report Designer active, choose View  Toolbox (or press CTRL + ALT + X).

2.

Select the STRING control in the Toolbox, and DRAG the control to the top left of the Page Header band, and DROP.

 

 

3.

RIGHT-CLICK on the control, then choose Properties from the popup menu.

The String Properties dialog appears.

4.

In the Properties Pad, type Page Number: in the Text property.

 

Place a control template to print the Page Number

1.

Open the Control Templates Pad, if not already opened.

2.

Highlight ReportPageNumber then DRAG to the right of the previously placed string.

 

Populating the Detail

The Detail band prints once for each row in the report. For this procedure, you’ll place the columns in a block arrangement, which creates a label report at print time.

1.

Select the Report Designer  Populate  Multiple Columns from the IDE toolbar.

 

 

2.

In the Select Column dialog, highlight the <ToDo> folder, then press the Add button.

3.

Select the Customer table from the Select a Table dialog, then press the Select button.

4.

Highlight the Customer table, and press the Change button.

5.

Highlight KeyCustNumber in the Select Key from CUSTOMER dialog, then press the Select button.

6.

Highlight Company in the Select Columns list in the right pane,and press the Select button.

7.

CLICK inside the Detail band, near its top left corner.

8.

Highlight FirstName in the Select Columns list and press the Select button.

9.

CLICK inside the Detail band, just below the first control.

10.

Highlight LastName in the Select Columns list and press the Select button.

11.

CLICK inside the Detail band, to the right of the control you just placed.

12.

Highlight CUS:Address in the Select Columns list and press the Select button.

13.

CLICK inside the Detail band, below the second control you placed.

 

Resize the Detail band

At this point, you probably have very little room left in the Detail band, and need to make it longer.

1.

Press the Cancel button to exit multi-populate mode.

2.

CLICK inside the Detail band, but not on one of the string controls.

The Detail area’s handles appear.

3.

Resize the Detail band by dragging the middle handle on the bottom down—allow for enough room for about two more lines.

 

 

Place the rest of the columns

1.

Choose Report Designer  Populate  Multiple Fields from the IDE Menu.

2.

Highlight City in the Columns list, then press the Select button.

3.

CLICK inside the Detail band, below the last control you placed.

4.

Highlight State in the Columns list, then press the Select button.

5.

CLICK inside the Detail band, to the right of the previously placed control.

6.

Highlight ZipCode in the Columns list, then press the Select button.

7.

CLICK inside the Detail band, to the right of the previously placed control.

8.

Press the Cancel button to exit multi-populate mode.

 

Notice that you have the same set of alignment tools in the Report Designer that you have already used in the Window Designer. Feel free to align and adjust the position of your controls at this time.

 

Select a base font for the Report

1.

Open the Properties Pad (F4 Key), and select the Report control from the drop list as shown:

 

 

2.

In the Property Pad, locate the TextFont property, and press the ellipsis button to the right.

3.

Select a font, style, and size to use as the base font for the report.

If you don’t select a font, it uses the printer’s default font.

4.

Press the OK button to close the Select Font dialog.

 

Preview the Report

1.

In the Report Designer toolbar, press the Print Preview button to "visualize" how the printed page will appear.

 

 

2.

Highlight Detail in the Details list then press the Add button several times.

This populates the preview with some print bands to view. Because you can have many bands of various types within a single report, you have to select which to see before going to print preview. This way, the Report Designer knows what to compose on the screen.

3.

Press the OK button.

4.

When done "previewing," press the Close button.

5.

Press the Save and Close button to return to the Procedure Properties dialog.

6.

Press the Save and Close button to close the Report Designer Editor dialog.

7.

Choose File  Save, or press the Save button on the tool bar to save your work.

 

 

An Invoice Report

Next, we will create one of the most common types of reports. An invoice will make use of most of the tables in the data dictionary, demonstrating how to create group breaks and totals. It will also show you how to control pagination based on group breaks.

 

Creating the Report

1.

Highlight the InvoiceReport procedure.

2.

Press the Properties  button.

3.

Select the Defaults tab, then highlight Report (Paper size Letter – Portrait) in the Select Procedure Type dialog, then press the Select button.

The Procedure Properties dialog appears.

 

Specify the tables for the Report

1.

If not already opened, open and select the Data / Tables Pad.

2.

Highlight the <ToDo> folder, then press the Add button on the Pad toolbar.

3.

Select the Customer table from the Select dialog, then press the Select button.

4.

Highlight the the Customer table, and press the Change  button.

5.

Highlight KeyCustNumber in the Select Key from CUSTOMER dialog, then press the Select button.

The report will process all the Customer table rows in CustNumber order.

6.

Highlight the Customer table, then press the Add button.

7.

Select the Orders table from the Related Tables tab, then press the Select button.

It will process all the Orders for each Customer.

8.

Highlight the Orders table, then press the Add button.

9.

Select the Detail table from the Related Tables tab, then press the Select button.

Each Order will print all the related Detail rows.

10.

Highlight the Detail table, then press the Add button.

11.

Select the Products table from the Related Tables tab, then press the Select button.

Each Detail row will lookup the related Products table row.

 

Populating the Report Form Band

The Report Form band prints once for each page in the report. Its content is only composed once, when the report is opened. This makes it useful for constant information that will always be on every page of the report.

 

Place a string constant

1.

From the Procedure Properties window, press the Report tab, and then press the Designer button to reenter the Report Designer.

2.

With the Report Designer active, choose View  Toolbox (or press CTRL + ALT + X).

3.

Select the STRING control in the Toolbox, and DRAG the control to the top middle of the Report Form band.

4.

RIGHT-CLICK on the control just populated, and select Properties… from the popup menu.

The Property Pad now has focus.

5.

Type Invoice in the Text property entry.

6.

Locate the TextFont property, and press the ellipsis button to the right.

7.