4. Managing Report Definitions

Report definitions created using the report writer are saved in Extensible Markup Language (XML) format. This is a universal standard file format, which simplifies the process of file sharing. Report definitions may be loaded into the report writer from a database, saved locally as XML, transferred via email or other method, and then uploaded for use in a different database. In this section, we will describe how to manage report definitions—moving them from a database to a local drive and back to a database again.

4.1. Loading Reports from a Database

For the purposes of this exercise, we will assume we are connecting to an xTuple Database, using the xTuple report writer. However, you would follow similar steps using the standalone OpenRPT application connected to a different database.

To begin with, let’s load an existing report definition into the report writer from an xTuple Database. From the Master Information section of the System Module, select the “Reports” option. The master list of report definitions will appear, as shown below:

Master List of Report Definitions in xTuple Database

We will be working with an xTuple report definition called “UsersMasterList.” This is a report which details information about xTuple user accounts. We can load the report definition into the report writer simply by opening it. To open the report definition, double-click on it—or highlight it and then select the EDIT button. The following screen will appear:

Load Report Definition from Database

The “UsersMasterList” is now loaded into the report writer. Our next step will be to save the report definition to a local drive.

4.2. Saving to XML

Now that we have loaded the “UsersMasterList” report definition into the report writer, let’s save it to our local drive in XML format. To do so, select the “Save As” option from the “File” drop-down menu. The following screen will appear:

Save Report Definition to XML Format

As you can see, our operating system prompts us to name the file and also specify a storage location. We navigate to a directory where other report definitions are stored and then give the file the same name it had when it was stored in the database. We also add the “.xml” extension to the end of the file name.

Tip

The names of report definition files are case-sensitive. To ensure accuracy, keep this in mind when sharing report definition files from one database to another.

Using an XML-compatible browser, we can now open the report definition and view the XML code, as shown in the following screenshot:

Report Definition XML Rendered in a Browser

So, we have stored the report definition on our local drive in the portable XML format. We are now able to share the file with other users, load it into the report writer for editing, or save it to another database.

4.3. Loading from XML

Before we can save a locally-stored report definition to another database, we must first load the XML file into the report writer. To load a locally-stored report definition into the report writer, select either the “Open File” button or the “Open” option from the “File” drop-down menu. The following screen will appear:

Loading XML File into the Report Writer

Our operating system prompts us to locate the file we want to load into the report writer. Once we locate and select the file, the report writer loads it, as shown in the following screenshot:

Report Definition Loaded from XML File

Now that the report definition has been loaded into the report writer, we can transfer it to a database—which we will do in our next step.

4.4. Saving to a Database

Next we will save the XML report definition to an xTuple Database. With the report definition loaded into the report writer, select the “Save to DB” option from the “Database” drop-down menu, as shown below:

Saving Report Definition to Database

Because in this example we are connected to an xTuple Database, a large number of report definitions are already stored on the database. The complete list of stored report definitions appears in the next screen, which appears after we select the “Save to DB” option from the “Database” drop-down menu:

Save Report to Database with a Higher Grade

xTuple can only generate reports using report definitions which are saved to its database. To distinguish between different versions of a report definition, the report writer employs grades. By default, xTuple uses the report definition with the highest grade.

Tip

Standard xTuple report definitions are delivered with a grade of “0”. By default, the xTuple client runs the highest numbered grade. To ensure that you can always return to the baseline version of a report, save your report definitions with a grade higher than 0.

Because our xTuple Database already contains one version of the “UsersMasterList” report definition, let’s save our current version with a grade of 50. This will clearly mark our current version as the default version xTuple should use. To see the two versions with their different grades, open the “Load from DB” option from the “Database” drop-down menu. The following screen will appear:

Note Multiple Grades for a Single Report

Keep in mind once again that xTuple will use the “UsersMasterList” report definition with grade 50 when executing this report.