The Reporter Introduction
From CometWiki
Introduction to The Reporter
The Reporter command language provides a simple way to create custom reports. While there are more than two dozen commands available, many reports can be created by using just a few of the commands. The Report editor can help you create the command file. The editor is launched when you click either the "Edit Report" or "New Report" buttons in DX. You can also start it directly by running "DATAEXP".
To get you started using the new Report editor, here are a few hints.
- There are built-in help messages for several of the editor's features. The "?" tool at the top right corner of the dialog can be used to display information about many of the dialog's controls. To use the tool, click on it then move your mouse to one of the controls and click. If help text has been defined for the control it will be displayed in a new window.
- Right click a filename in the tree to see its attributes, print its dictionary, or define an expression.
- Right click a fieldname in the tree to see its attributes (type and size)
- Try the "Show me the best way to do this!" button on the SELECTING tab especially if your report uses fields from more than one file. It will properly position the select clauses so the report runs the most efficiently.
* NOTE: The 8.00 version of the DataExp Reporter front-end does not support Reporter command files that contain specs for more than one report. Furthermore, when the report is saved, viewed, or run the command file will be rewritten with only the commands for the first report in the file. Commands for any additional reports will be lost! Therefore it is advised that you use DataExp to edit or run only those reports which were created by DataExp.
The Reporter Command Language
The Reporter command file is stored in a Comet file, preferably a text file with a ".ibr" extension. Often a report can be defined with just a few commands. For example, the following group of commands prints a customer list using data from the CUSTOMER data file:
INPUT CUSTOMER REPORT PRINT CUST.NUMBER;CUST.NAME;ADDRESS;CITY;STATE;ZIP
In the above example, the INPUT command specifies that data will be retrived from the CUSTOMER file. The REPORT command separates the INPUT command from the PRINT command. The PRINT command specifies which data fields will be printed. In this case, the customer number, customer name, address, city, state, and ZIP code will be printed. Additional commands can be used to sort and select specific records. For example, to sort the customer list by ZIP code, you could add the SORT command to the report specification:
INPUT CUSTOMER SORT ON ZIP REPORT PRINT CUST.NUMBER;CUST.NAME;ADDRESS;CITY;STATE;ZIP
Or, if you wanted to include just the customers from a certain state (in this case, California), you could include the SELECTING command:
INPUT CUSTOMER SELECTING IF STATE = "CA" SORT ON ZIP REPORT PRINT CUST.NUMBER;CUST.NAME;ADDRESS;CITY;STATE;ZIP
Note: This example would select all of the customers from California and then sort those records by ZIP code. Another frequently-used command is the TOTAL command. This command computes and prints column totals for numeric fields, as shown in this example:
INPUT CUSTOMER REPORT PRINT CUST.NUMBER;CUST.NAME;AR.CURRENT;AR.OVER.30;AR.OVER.60;AR.OVER.90 TOTAL AR.CURRENT;AR.OVER.30;AR.OVER.60;AR.OVER.90
The numeric fields named AR.CURRENT, AR.OVER.30, AR.OVER.60, and AR.OVER.90 are totalled and printed (in the appropraite columns) at the bottom of the report. If you sort the records by a particular field, you can then create control breaks and display subtotals. This is done with the SORT command, the TOTAL command, and the BREAK command, as shown in this example:
INPUT CUSTOMER SORT ON STATE REPORT PRINT CUST.NUMBER;CUST.NAME;AR.CURRENT;AR.OVER.30;AR.OVER.60;AR.OVER.90 BREAK ON STATE TOTAL AR.CURRENT;AR.OVER.30;AR.OVER.60;AR.OVER.90
This report, which is sorted by STATE, will include control breaks and subtotals every time the value of the STATE field changes. Grand totals will be printed at the bottom of the report. The Reporter can print data from multiple data files, as long as the appropriate link has been defined in the Comet data dictionary (#CFILES). The USING command specifies the link name that connects the primary file with one or more secondary files. The following example shows how data from the CUSTOMER file and CUSTOMER.HIST file can be printed on the same report. The link name for this example is CUST.TO.HIST.
INPUT CUSTOMER REPORT USING CUST.TO.HIST PRINT CUST.NUMBER;CUST.NAMES;SALES.LAST.MONTH;YTD.SALES
Other Reporter commands control where the report is printed, how the report is displayed (including control over the number of lines per page, number of spaces between each column, number of indented spaces, number of blank spaces between print lines, etc.), the definition of virtual fields (expressions), the definition of report title lines, and more.