Creating a Simple Report

This topic introduces the basic procedures in creating a SimpleReport program.

NOTE

The program example used throughout this section is called SimpleReport.

The SimpleReport program generates a Customer report using the Customers file located in the SQLDEMO account.

To create a new Library:
  1. Select Library > New in the Libraries window.

  2. Type Report1.lbv in the File name text box, then click OK.

The new Library is now called Report1.lbv. The REPORT1 displays in the Libraries window.

To add Class components to a new Library:
  1. Click New Library from the Studio Browser.

  2. Drag the mvD window from the Component Store to the REPORT1 Library window.

The mvD window component becomes an mvD window Class.

  1. Type wWindow1 to name the mvD window Class.

  2. Repeat procedures 2 and 3, but now drag mvD report from the Component Store to the REPORT1 Library.

The mvD report component becomes an mvD report Class.

  1. Type rReport1 to name the mvD report Class.

The REPORT1 Library displays three Classes:

To design the report:
  1. Double-click rReport1 in the REPORT1 Library.

The REPORT1.rReport1 design form displays.

  1. Drag the Entry field from the Component Store to the rReport1 design form.

Repeat this process to add additional Entry fields to the design form.

  1. Drag the Label Background Object from the Component Store to the REPORT1.rReport1 design form.

Repeat this process to add additional Labels to the design form.

  1. Type the names of the Labels in the Property Manager text field.

NOTE

Entry fields from the Component Store do not need to be named.

To create the BASIC program:
  1. Select MyServer (Default) > Subroutines > mvDReport from the Enterprise Browser and right-click the bp node.

  2. Select Create New Item…, then type SimpleReport to name the new item.

  3. Double-click the SimpleReport node to display the SimpleReport’s BASIC program Editor with the standard template code.

To create DataNames:
  1. Type the Category name in the SimpleReport’s BASIC program Editor.

<CAT>Report Tutorial</CAT>

  1. Type a DataName for each Entry field to be printed on the report.

<DNAME>fCustomer.ID</DNAME>

<DNAME>fCustomer.Name</DNAME>

<DNAME>fCustomer.Phone</DNAME>

  1. Click Extract to create the DataName node in the Enterprise Browser (as well as save the program).

NOTE

Report DataNames have the same structure as list DataNames, where each field is a column of a list.

To drag and drop DataNames:
  1. Select MyServer (Default) > DataNames > SimpleReport > fCustomer node from the Enterprise Browser.

The fCustomer node (where the f prefix represents a field) displays three column DataName elements that were created above:

  1. Drag the DataNames (for example, ID, Name, Phone, and so on) to the corresponding Entry fields on the report design form.

Each time a DataName is dragged to an Entry field, an Event window displays to show the DataName being dropped and its data type.

  1. Click Update to accept the default settings.

NOTE

The Entry field name changes to display the DataName that was dropped on the prefix with iMvdDataRef. iMvdDataRef is the internal Omnis Studio instance variable that holds the print data. This variable is internal and cannot be changed.

To edit the BASIC program:
  1. Select MyServer (Default) > Subroutines node from the Enterprise Browser.

The Subroutine SimpleReport BASIC program Editor displays.

  1. Edit the SimpleReport BASIC program’s first CASE instruction.

The print data is returned to the form through the form’s $getreportdata event. The CASE statement branches to the CreateSimpleReport Label if the event is $getreportdata from the REPORT1.rReport1 design form.

The CreateSimpleReport routine opens and selects the CUSTOMERS file from the SQLDEMO account and loops through the selected list to build the report data. Once the loop is completed, w3mvDInsert sends the print data to the report.

  1. Click Compile.

The SimpleReport BASIC program successfully compiles.

NOTE

The program must be cataloged before running.

To catalog the BASIC program:
  1. Select MyServer (Default) > Subroutines > mvDReport node from the Enterprise Browser.

  2. Right-click SimpleReport and select Catalog Item…

The mvDCatalog Entry window displays.

  1. Select the Allow Anonymous Access check box.

  2. (Optional) Type a description in the Description field, then click Save.

To drag and drop the mvDCatalog:
  1. Select MyServer (Default) > mvDCatalog > ReportTutorial > SimpleReport from the Enterprise Browser.

  2. Drag the SimpleReport to the REPORT1.rReport1 design form.

The rReport1 event window displays.

  1. Select the $getreportdata event check box, then select the server name from the Server drop-down list (for example, MyServer).

  2. Click Update to save changes.

  3. Click Print to Screen to run and test the report from the report design form.

If data is not returned, the report does not run. If data is returned from the BASIC program, the run-time report form opens and displays the report.

Running the Report

The report can be run from any one of these options:

To run a report from a Push button:
  1. Double-click wWindow1 Class from the REPORT1 Library.

The REPORT1.wWindow1 design form displays.

  1. Drag the Push Button from the Component Store to the REPORT1.wWindow1 design form, then type Print Report in the Text field of the Property Manager window.

The Push Button now displays Print Report.

NOTE

The Push Button component does not require a name.

  1. Select MyServer (Default) > Reports > REPORT1.rReport1 node from the Enterprise Browser.

The Reports node displays all the mvDesigner reports for all currently opened Libraries.

LibraryName.ReportClassName

where LibraryName is the name of the Library and ReportClassName is the name of the Report Class. For example, REPORT1.rReport1.

  1. Drag the REPORT1.rReport1 node to the Print Report button on the design form.

The wWindow1_1019 event window displays.

  1. Select the evClick Event and the Start New Print Job check boxes, then select Prompt from the Print Destination drop-down list.

NOTE

If a Print Destination (other than Prompt or nothing at all) is selected, click the Push button. The report automatically prints to the selected destination.

  1. Click Update to save changes.

The Start New Print Job check box must be selected for all new print jobs. The only time when this option should not be selected is when it is a continuing print job. For example, when printing a large report it is a good idea to print the report in batches.

The Print in Batches option is used to specify that the print data that is returned by this BASIC program is not the complete print data and that after this batch more data is available. This tells the mvDesigner Client that once the current data is printed, it needs to go back to the BASIC program to retrieve more data.

NOTE

Batch printing requires that the BASIC program be a persistent connection application.

  1. Double-click wWindow1 Class to open the REPORT1.wWindow1 design form.

  2. Right-click and select Open Window.

The REPORT1.wWindow1 design form runs.

  1. Click Print Report to open the Print Destination window, then double-click Screen to print the report.

To run a report from a menu:
  1. Drag the mvD menu from the Component Store to the REPORT1 Library, then define the field properties for the mvD menu Class using the Property Manger:

  1. Double-click mPrint Class to open the REPORT1.mPrint design form, then press Enter.

A menu option displays on the design form.

  1. Type Print Customer List in the menu option.

  2. Select MyServer (Default) > Reports > REPORT1.rReport1 node from the Enterprise Browser, then drag the REPORT1.rReport1 node to the Print Report button on the design form.

The mPrint_1001 window displays.

  1. Select the evClick event and the Start New Print Job check boxes, then select Prompt from the Print Destination drop-down list.

  2. Click Update to save changes.

  3. Select kTrue from the hasmenus drop-down list, then Select mPrint from the menunames drop-down list to define the field properties for the REPORT1.wWindow1 Class.

  4. Double-click wWindow1 Class to open the design form, then right-click the design form and select Open Window.

The Window REPORT1.wWindow1 design form runs.

  1. Select Print > Print Customer List from the window’s menu.

The Report Destination window displays.

  1. Double-click Screen to print the report, then click OK.

To run a report from a Toolbar:
  1. Drag the mvD toolbar from the Component Store to the REPORT1 Library.

  2. Type tbPrint to name the mvD toolbar Class.

  3. Double-click tbPrint Class to open the REPORT1.tbPrint design form.

  4. Drag the Push Button from the Component Store to the tbPrint design form, then type Print Customer List in the Property Manager tooltip field.

  5. Select MyServer (Default) > Reports > REPORT1.rReport1 node from the Enterprise Browser, then drag the REPORT1.rReport1 node to the Print Report button on the design form.

The tbPrint_1001 event window displays.

  1. Select the evClick Event and the Start New Print Job check boxes, then select Prompt from the Print Destination drop-down list.

  2. Click Update to save changes.

  3. Double-Click wWindow1 Class to open the design form.

  4. Select any of these options from the Property Manager toolbarpos drop-down list to define the field properties for the REPORT1.wWindow Class:

  1. Type tbPrint in the Property Manager toolbarnames field.

  2. Right-click the REPORT1.wWindow1 design form and select Open Window.

The REPORT1.wWindow1 design form runs.

  1. Click OK to open the Report Destination window, double-click Screen, then click OK to print.

To run a report from BASIC:
  1. Drag the Push Button from the Component Store to the REPORT1.wWindow1 Class design form.

  2. Type btprint in the Property Manager Name field and Print from BASIC in the Text field.

  3. Select MyServer (Default) > mvDCatalog > ReportTutorial > SimpleReport node from the Enterprise Browser, then drag the SimpleReport node to the Print from BASIC button.

The btPrint event window displays.

  1. Select the evClick Event and the Start New Print Job check boxes, then click Update to save changes.

  2. Select MyServer (Default) > Subroutines > mvDReport > SimpleReport node from the Enterprise Browser.

  3. Double-click the SimpleReport node to open the BASIC Editor.

  4. Type the CASE statement to handle the evClick Event of the btPrint Object to update the SimpleReport BASIC program.

CASE TRIGGEROBJECT = "btPrint" AND TRIGGEREVENT = "evClick"

GOSUB StartPrint

  1. Type w3mvDPropertyChange to run the $cinst.$openreport in the StartPrint Label.

StartPrint:

CALL W3MVDPROPERTYCHANGE("$$cinst","$openreport(’REPORT1’, ’rReport1’,1,’kDevScreen’)","...")

RETURN

where:

LibraryName

is the name of the library where the report is stored.

ReportName

is the name of the report to print.

Print Options

1—Print entire report

0—Print in batch

PrintDestination

kDevClipboard

kDevFile

kDevHtml

kDevPostscript

kDevPreview

kDevPrinter

kDevRtf

kDevScreen

  1. Click compile.

The SimpleReport BASIC program successfully compiles.

  1. Double-click wWindow1 Class to open the REPORT1.wWindow1 design form, then right-click and select Open Window.

The REPORT1.wWindow1 design form runs.

  1. Click Print from BASIC to print the report.

To run a report from a remote form:
  1. Drag the mvD remote form from the Component Store to the Report1 Library, then type rfForm in the Name field of the Property Manager window.

  2. Double-click rfForm Class to open the design form, then drag the Push Button from the Component Store to the design form.

  3. Type btPrintReport in the Name field, then type Print Report in the Text field to define the field properties for the REPORT1.rfForm Class.

  4. Drag the Print Control from the Component Store to the remote form (resize the Print Control component, if needed.)

  5. Do the following to define the field properties for the Print Control using the Property Manager window:

  1. Select MyServer (Default) > Reports > REPORT1.rReport1 node from the Enterprise Browser, then drag the REPORT1.rReport1 node from the Enterprise Browser to the Print Report button.

The btPrintReport event window displays.

  1. Select the evClick event and the Start New Print Job check boxes, then select Prompt from the Print Destination drop-down list and MyPrintControl from the Print Field drop-down list.

  2. Click Update to save the changes.

  3. Double-click wWindow1 Class to open the design form, then right-click and select Test Form.

The default Browser starts the remote form.

  1. Click Print Report to display the report in the Print Control.

NOTE

The Print Control is required to exist on the remote form in order to generate reports. However, the Print Control does not need to be visible if the Print Destination is set to Printer. In this case, the report is automatically sent to the local printer.

See Also

Generating Report in mvDesigner

Setting up the Development Environment

Creating a Batch Report

Modifying Fields at Run Time

Using the Report Data Grid

Using the Report Graph Control Component

Selecting Print Destination from BASIC

Summary

Examples