You can use DataWindow objects to create standard business reports such as financial statements, sales order reports, employee lists, or inventory reports.
To create a production report, you:
-
Determine the type of report you want to produce
-
Build a DataWindow object to display data for the report
-
Place the DataWindow object in a DataWindow control on a window or form
-
Write code to perform the processing required to populate the DataWindow control and print the contents as a report
Calling InfoMaker from an application
If your users have installed InfoMaker (the Appeon reporting product), you can invoke InfoMaker from an application. This way you can let your users create and save their own reports. To do this in PowerBuilder, use the Run function. For information about invoking InfoMaker, see the InfoMaker Users Guide.
To design the report, you create a DataWindow object. You select the data source and presentation style and then:
-
Sort the data
-
Create groups in the DataWindow object to organize the data in the report and force page breaks when the group values change
-
Enhance the DataWindow object to look like a report (for example, you might want to add a title, column headers, and a computed field to number the pages)
Using fonts
Printer fonts are usually shorter and fatter than screen fonts, so text might not print in the report exactly as it displays in the DataWindow painter. You can pad the text fields to compensate for this discrepancy. You should test the report format with a small amount of data before you print a large report.
After you build the DataWindow object and fill in print specifications, you can place it in a DataWindow control on a window or form, as described in Putting a DataWindow object into a control.
To allow users to print the report, your application needs code that performs the printing logic. For example, you can place a button on the window or form, then write code that is run when the user clicks the button.
To print the contents of a single DataWindow control or DataStore, call the Print method. For example, this PowerBuilder statement prints the report in the DataWindow control dw_Sales:
dw_Sales.Print(TRUE)
For information about the Print method, see the DataWindow Reference. For information about using nested reports to print multiple DataWindows, see Using nested reports.
Separate DataWindow controls in a single print job
For PowerBuilder applications only
If the window has multiple DataWindow controls, you can use multiple PrintDataWindow method calls in a script to print the contents of all the DataWindow controls in one print job.
These statements print the contents of three DataWindow controls in a single print job:
int job job = PrintOpen("Employee Reports") // Each DataWindow starts printing on a new page. PrintDataWindow(job, dw_EmpHeader) PrintDataWindow(job, dw_EmpDetail) PrintDataWindow(job, dw_EmpDptSum) PrintClose(job)
For information about PowerBuilder system functions for printing, see the section called “PowerScript Functions” in PowerScript Reference.