This topic introduces the concept of Batch Reports. A Batch Report is a report that requires more than one trip back to the database server in order to complete. For example, when generating a large report, data can be sent to the printer in batches. The batch size depends on the BASIC program. It could be a line, a paragraph, a page or any quantity of data defined by the way the BASIC program is written.
Start the report and return the first batch of data.
When the data is returned, keep the connection alive by using a persistent time out in the BASIC program.
Trigger an event back from the client window to the server to continue processing, then return the next batch of data.
Do one of the following:
Exit the BASIC program by dropping the connection using the non-persistent method if there is no more data.
Repeat this procedure if there is more data.
Triggering an event back to the server is not done automatically. It can be done using a Push button or a progress bar. With the progress bar, the status of the printing progress can be displayed.
The Batch Report program example generates a simple Customer list report using the Customers file located in the SQLDEMO account. The batch size is set to each record.
Before proceeding, complete the procedures described in Creating a Simple Report.
Right-click the rReport1 Class from the Report1 Library and select Duplicate.
A duplicate copy of the rReport1 Class displays.
Type rReport2 to rename the duplicate copy.
Select MyServer (Default) > Subroutines > mvDReport > bp > SimpleReport from Enterprise Browser.
Right-click SimpleReport, then select Duplicate Item.
A duplicate copy of the SimpleReport BASIC program is created.
Type BatchReport to rename the duplicate copy.
Double-click BatchReport node to open the BASIC Editor.
Edit the BatchReport BASIC program to enable batch printing.
w3mvDInput in the StartBatchReport routine is a persistent input with a 20 second time-out.
The BatchReport BASIC program successfully compiles.
Select the MyServer (Default) > mvDCatalog > BatchReport node from the Enterprise Browser.
Right-click BatchReport and select the Catalog Item...
The mvDCatalog Entry window displays.
Select the Allow Anonymous Access check box.
(Optional) Type Batch Report Printing Example in the Description field, then click Save.
Double-click wWindow1 Class to open the REPORT1.wWindow1 design form.
Select the Print Report button and align it below the Print from BASIC button, then drag the Push Button from the Component Store to the REPORT1.wWindow1 design form.
Type Start Batch Report in the Text field of the Property Manager window.
Drag the Progress Control from the Component Store to the REPORT1.wWindow1 design form.
Type ProgressBar in the Name field, then select KBorderInset from the effect drop-down list in the Appearance tab to define the field properties for the Progress Control in the Property Manager window.
Select a color from the progressColor field and the ::backcolor field located in the Custom tab, then select False from the Vertical and Blocks drop-down lists.
The ProgressBar component has a run time property (sendCarryOn), which when set to kTrue automatically triggers the evCarryOn event. The evCarryOn event triggers an event back to the server to request the next batch of data. While the data is being returned, the BASIC program also updates the current value of the ProgressBar to show the printing progress. While this is not necessary, it is a good idea to inform users that the system is performing other operations and cannot carry out any requests at this time.
Select MyServer (Default) > Reports > REPORT1.rReport2 node from the Enterprise Browser.
Drag the REPORT1.rReport2 node to the Start Batch Report button in the REPORT.wWindow1 design form.
The wWindow1_1033 window displays.
Select the evClick event and the Start New Print Job check boxes, then select the Print in Batches option and Screen from the Print Destination drop-down box.
Click Update to save the changes.
Select MyServer (Default) > Reports > REPORT1.rReport2 node from the Enterprise Browser, then drag the REPORT1.rReport2 node to the ProgressBar.
The ProgressBar event window displays.
Select the evCarryOn event check box, then click Update to save changes.
The Start New Print option must not be selected.
Double-click rReport2 Class from the REPORT1 Library.
The REPORT1.rReport2 design form displays.
Select MyServer (Default) > mvDCatalog > ReportTutorial > BatchReport node from the Enterprise Browser.
Drag the BatchReport node to the record in the REPORT1.rReport2 design form.
The rReport2 event window displays.
Select the $getreportdata check box, then click Update to save changes.
Right-click REPORT1.wWindow1 design form, then select Open Window.
The REPORT1.wWindow1 design form runs.
Click Start Batch Report to generate the Batch Report.
While the batch report generates, it displays progress information on the tandem port by the telnet session.
Generating Report in mvDesigner
Setting up the Development Environment
Creating a Simple Report
Modifying Fields at Run Time
Using the Report Data Grid
Using the Report Graph Control Component
Selecting Print Destination from BASIC