Reports

One of the document template types supported by AwareIM is the Report type. Document templates of this type are somewhat different from other document templates. The main difference is in the document generation algorithm. Whereas for other types AwareIM just replaces tag elements with the appropriate values (see Document Generation), for reports AwareIM also repeats a particular section of the document template for each instance of a business object found in the Context. The following section describes this process in detail.

The layout of a document template of the Report type (or simply report) is designed using the Report Designer. The layout of any report consists of special sections called bands. Each band may contain report elements and is processed in a special manner during document generation. The following bands can be defined:

This band represents the title of the report.

This band represents a header of each page in the report.

This band represents a footer of each page in the report.

If the report has multiple columns this band represents the header of each column.

If the report has multiple columns this band represents the footer of each column.

This band is the main section of the report that is repeated for each instance of a business object in the Context.

This band represents thesummary of the report.

Instances of a business object shown in the Details band may be divided into groups – for example, each group may only show data starting with a particular letter of the alphabet. A group may also contain other groups. Each group is represented by a Group header and a Group footer. Elements of the group header are included into the resulting document at the start of each group and elements of the group footer – at the end of each group. Each group has a group condition, i.e. the expression that is calculated during the report generation to check whether a new group should be started (see Report Generation).

The details of defining bands in the Report Designer are provided in the Setting Band Properties section.

The following elements may be included in any of the report bands:

This element usually contains static text. It is possible to include tags, which will be resolved during the report generation, inside the static text. For example,

The account balance is <<Account.Balance>>

See “Tag Elements” in the Document Generation section.

This element represents a straight line.

This element represents a rectangle.

This element represents an image.

This element refers to another existing report that is embedded into the current (master) report. Sub-report elements are often used to display instances of a business object referenced by a particular reference attribute – for example, if a master report shows accounts, the sub-report for each account may show transactions of the account. When defining a sub-report it is necessary to indicate a query that finds the data for the sub-report. The query usually finds the instances referenced by an attribute, for example:

 FIND Transaction WHERE Transaction IN Account.Transactions

Note that the query uses the dynamic attribute Account.Transactions, which refers to the instances of the Account business object in the master report – see configuring queries and Other Usages of Context.

All elements mentioned before are always included into the final document by the report generation algorithm. A conditional element, on the other hand, allows specifying conditions, which define when a particular element should be included into the final document (if at all). Moreover, it makes it possible to designate several sub-elements for the same area in the report and specify conditions, which define when a particular sub-element will be printed. For example, consider a conditional element that includes two tag elements – both tag elements refer to the Balance attribute of the Account object (<<Account.Balance>>), except that one is displayed in green and another one - in red. The conditional element defines the conditions that specify that the first text element should be included if the value of the account balance is greater than 100 and another one – if it is less than 100. The final document therefore will display the account balance in red if it is less than 100 dollars and in green if it is greater than 100 dollars.

The details of defining elements in the Report Designer are provided in the Adding Report Elements section.

Report Generation

We can now describe what happens when a report document is generated from a report layout. First of all the Title band is generated. When we say that a certain band is generated it means that the report elements included in the band are transferred into the final document. Static elements, such as static text, rectangles, lines and images are transferred into the final document as is, whereas dynamic elements such as text elements with tags, tag elements, conditional elements and sub-reports are generated and the result is included into the final document. This is how the dynamic elements are generated:

  1. Text elements with tags and tag elements are resolved from the Context as described in Document Generation.
  2. Conditions of conditional elements are calculated and the appropriate sub-element is included into the final document (or nothing is included at all). If the sub-element is a dynamic element it is generated as well.
  3. A query attached to a sub-report element is run, the Context for the sub-report is formed (see Other Usages of Context) and the report generation algorithm is executed for the sub-report. The resulting document is included into the master document.

After the Title band has been generated AwareIM starts generating pages of the report by generating the Details band for every instance of a business object in the Context independently. If, for example, a report is generated for a number of accounts the Details band is generated for each instance of the account. The instances could either be selected by the user or found by a query attached to the document template (see Adding/Editing Document Templates).

When generating pages of the report AwareIM checks whether a new page should be started (the size of the page is specified as part of the properties of the report – see Setting Report Properties). If a new page is to be started AwareIM generates the Page Footer band for the previous page and the Page Header band for the new page. Also if the report has been defined to have multiple columns, AwareIM generates the Column Header and Column Footer bands when starting a new column.

Whenever AwareIM starts processing a new instance of the business object in the Context it checks whether it should start a new group (provided that group bands have been defined in the report). The new group is started if the value of the expression specified as a group condition changes. For example, if the group condition is specified as Product.Category the new group will be started whenever the value of the product’s category of the new instance is different from the value of the previous instance. When a group is started AwareIM generates the Group Footer for the previous group and the Group Header for the new group.

Finally after pages of the report have been generated AwareIM generates the Summary band.

This video tutorial explains how end users can define their own document templates using an AwareIM feature called “user defined documents”