Changes

Jump to: navigation, search

Create iReport Templates with Subreports

17,713 bytes added, 20:12, 23 October 2012
no edit summary
<li>Click the [[Image:iRepRun.png]] button to execute the report.</li>
:The report results displays.
</ol>
 
==Items with Data Subsets==
Certain items have subsets of data that are contained within them. For example, an MRE may have MRE details such as the MRE type, total audience, and percentage of women and men. The MRE details data requires the MRE to exist. Table 3. Parent/child relationships lists the items and the data subsets that depend on them.
 
<center>
{| class="wikitable" width="600"
|-
| align="center" colspan="2" | '''Table 3. Parent/child relationships'''
|-
| width="150pt" | '''Parent item'''
| width="450pt" | '''Child item(s) which require the parent item'''
|-
| Hazard reduction || Impact survey
Interviewee
Organisation
Question
Sample
Sector
Vegetation removal
|-
| Location || Accident
Hazard
Hazard reduction
MRE
QC
Victim
|-
| MRE || MRE details
|-
| Victim || Received MRE
|}
</center>
 
The process for creating a report on a parent item and its children is similar to the process for creating a report on locations and their associated items. The key difference is that the main report will contain the attributes of the parent item. The sub-report will contain the attributes for the child item. For example, if you were trying to create a report of MREs and their associated MRE details, the main report would contain the attributes for MRE and the sub-report would contain the attributes for MRE details.
 
====Part 1. Create a report with attributes for a parent item====
The first part of creating a report on a parent and its child items is to create a report which includes the attributes from the parent item you would like to include.
<ol>
<li>Ensure that the IMSMA server is started.</li>
<li>From the '''File''' menu, select '''Report Wizard'''.</li>
<li>From the '''Connection/Data Sources''' list, select the data source for the parent item.</li>
</ol>
 
{| class="wikitable"
|-
| [[File:Note.jpg | 40px]] || Table 3. Parent/child relationships lists the items which may be selected as the parent item for a report.
|}
 
<ol>
<li>Click the '''Next''' button.</li>
:The iReport Wizard, Step 2 window displays a list of attributes for the selected item.
<li>Select the attributes you would like to include for the parent item.</li>
<li>Click the '''Next''' button.</li>
:The window displays a list of the attributes that you have selected.
<li>Click the '''Next''' button.</li>
:The iReport Wizard, Step 3 window displays to allow you to group the report results.
<li>Because the report results for this exercise will not need to be grouped, click the '''Next''' button.</li>
:The iReport Wizard, Step 4 window displays to allow you to select the report layout.
<li>Select a layout option.</li>
<li>Click the '''Next''' button.</li>
:The iReport Wizard, Step 5 window displays.
<li>Click the '''Finish''' button.</li>
<li>Save the report.</li>
</ol>
 
====Part 2. Create a sub-report for the child item====
The next part of the process for creating a report on a parent and its child items requires you to create a sub-report within the parent item report.
 
<ol>
<li>Expand the detail section of the report by doing the following:</li>
<ol type="a">
<li>From the '''View''' menu, select '''Bands'''.</li>
<li>From the left pane, select ''detail''.</li>
<li>In the '''Band Height''' field that is in the right pane, increase the height of the detail section. At a minimum you will want to double the height.</li>
<li>Click the '''Apply''' button.</li>
:The height of the band increases based on the value that you entered.
</ol>
</ol>
 
{| class="wikitable"
|-
| [[File:Note.jpg | 40px]] || You may also expand the height of the detail band by dragging the line that separates the detail section of the report and the page footer section down.
|}
 
<ol start="2">
<li>Click the [[Image:iRepCompile.png]] button to add a sub-report.</li>
:The cursor changes to a crosshair.
<li>Click the detail section of the report.</li>
<li>While holding down the mouse button, drag the cursor to form the rectangle which will contain the sub-report.</li>
<li>Release the mouse button.</li>
:The window to create a new report or use an existing one displays.
<li>From the window:</li>
<ol type="a">
<li>Select the ''Create a new report'' option.</li>
<li>Click the '''Next''' button.</li>
:The How fill the sub-report screen displays.
</ol>
<li>From the window:</li>
<ol type="a">
<li>Select the data source for the child item from the '''Connection/Data Source''' list.</li>
<li>Click the '''Next''' button.</li>
:The window to select the attributes to include in the report displays.
</ol>
<li>From the window:</li>
<ol type="a">
<li>Select the attributes that you would like to include in the report.</li>
<li>Click the '''Next''' button.</li>
:The window to select a layout displays.
</ol>
<li>From the window to select a layout:</li>
<ol type="a">
<li>Select the layout option.</li>
<li>Click the '''Next''' button.</li>
:The window to specify the sub-report expression displays.
</ol>
<li>From the window to specify the sub-report expression:</li>
<ol type="a">
<li>Enter a name for the sub-report.</li>
<li>Click the '''Finish''' button.</li>
:The sub-report displays.
</ol>
</ol>
 
====Part 3. Add parameters to the sub-report====
The next part of the process for creating a report on a parent and its child items is to define parameters that will be used for passing the parent item guid between the sub-report and main report.
 
<ol>
<li>From the '''View''' menu, select '''Parameters'''.</li>
:The window displays the parameters.
<li>Click the '''New''' button.</li>
:The Add/modify parameter window displays.
<li>From the Add/modify parameter window:</li>
<ol type="a">
<li>In the '''Parameter Name''' field, enter a name for the parameter that will be used to identify the guid for the parent item.</li>
</ol>
</ol>
 
{| class="wikitable"
|-
| [[File:Note.jpg | 40px]] || Although there are no requirements for the parameter name, you should enter a name that is easy to remember and meaningful. Make note of this parameter name since it will used in a later step.
|}
 
<ol start="4">
<ol type="a" start="2">
<li>Click the OK button.</li>
</ol>
<li>Close the window that displays the list of all parameters.</li>
</ol>
 
====Part 4. Create a query in the sub-report to associate the guid to the parent item report====
The next part of the process for creating a report on locations and its associated items is to create a query that defines how the location and associated item are related in the IMSMA database.
 
<ol>
<li>From the '''Data''' menu, select '''Report Query'''.</li>
:The Report query window displays.
<li>From the Report query window:</li>
<ol type="a">
<li>Select ''ImsmaQuery'' from the '''Query language''' list.</li>
<li>In the field below the Query language list, enter ''ParentItem''.guid = "$P{''ParameterName''}"</li>
where ''ParentItem'' is the default value expression for the parent item and ''ParameterName'' is the name of the parameter that you created for the parent item guid.
<li>Click the '''OK''' button.</li>
:The Report query window closes.
<li>Click the [[Image:iRepCompile.png]] button to compile the sub-report.</li>
</ol>
</ol>
 
====Part 5. Add parameters to the parent report====
The next part of the process for creating a report on a parent and its child items is to update the parent report to include the guid attribute and parameters that will be used to associate the parent item to the child item.
 
<ol>
<li>Display the parent item report by doing one of the following:</li>
*From the Window menu, select the name of the report.
*Close the sub-report.
*Bring the parent item report to the foreground by double-clicking the report name that is displayed in the Files pane.
<li>Double-click the sub-report box within the report.</li>
:A window displays four tabs (Common, Sub-report, Sub-report (Other), and All).
<li>From the window:</li>
<ol type="a">
<li>Select the Sub-report (Other) tab.</li>
<li>Click the Add button.</li>
:The Add/modify parameter window displays.
</ol>
<li>From the Add/modify parameter window:</li>
<ol type="a">
<li>In the Sub-report Parameter Name field, enter the parameter name that you used for the parent item guid.</li>
</ol>
</ol>
 
{| class="wikitable"
|-
| [[File:Note.jpg | 40px]] || This is the parameter that you created in step previously.
|}
 
<ol start="5">
<ol type="a" start="2">
<li>In the '''Default Value Expression''' field, enter ''$F{guid}''.</li>
<li>Click the '''OK''' button.</li>
</ol>
<li>Close the window with the four tabs.</li>
</ol>
 
====Part 6. Compile and execute the parent item report====
<ol>
<li>Ensure that the data source for the parent item is selected from the list.</li>
<li>Click the [[Image:iRepCompile.png]] button to compile the report.</li>
<li>Click the [[Image:iRepRun.png]] button to execute the report.</li>
:The report results displays.
</ol>
 
==Reports on Linked Items==
Part 4 of this training module discussed direct relationships—relationships where the parent item must exist in order for the child item to exist. In this part of the training, you will learn about linked relationships. Linked relationships are optional relationships which may exist between items. Unlike direct relationships that are enforced during the IMSMA reconciliation process, links are optional. Accidents, hazards, hazard reductions, MREs, and QCs may be related to one another via ''links''. For example, a victim may be associated to an accident in a particular hazard. If these relationships are known, IMSMA users may define these links while reconciling the field report.
[[Image:iRep21.png|center|500px|''Figure 21. Direct relationships vs. Links'']]
<div align="center">
''Figure 21. Direct relationships vs. Links''
</div>
 
The process for creating a report on an item and its linked items is similar to the process for creating a report on items with a direct relationship. The item in the main report is the primary item for which you would like to find linked items. The sub-report would return the records for the particular item that is linked to the primary item. The key difference is the query used in the sub-report.
 
If you would like to report on different items that linked to the item in the main report, you may create a new sub-report for each linked item. For example, to create a report of hazards and the accidents and hazard reductions that are linked to those hazards, you would create the main report on hazard. This report would then contain a sub-report to list linked accidents, and another sub-report to list linked hazard reductions.
 
====Part 1. Create a report with attributes for a primary item====
The first part of creating a report on linked items is to create a report which includes the attributes from the primary item for which you would like to list linked items.
 
<ol>
<li>Ensure that the IMSMA server is started.</li>
<li>From the '''File''' menu, select '''Report Wizard'''.</li>
<li>From the '''Connection/Data Sources''' list, select the data source for the primary item.</li>
</ol>
 
{| class="wikitable"
|-
| [[File:Note.jpg | 40px]] || Table 3. Parent/child relationships lists the items which may be selected as the primary item for a report.
|}
 
<ol start="4">
<li>Click the '''Next''' button.</li>
:The iReport Wizard, Step 2 window displays a list of attributes for the selected item.
<li>Select the attributes you would like to include for the primary item.</li>
<li>Click the '''Next''' button.</li>
:The window displays a list of the attributes that you have selected.
<li>Click the '''Next''' button.</li>
:The iReport Wizard, Step 3 window displays to allow you to group the report results.
<li>Because the report results for this exercise will not need to be grouped, click the '''Next''' button.</li>
:The iReport Wizard, Step 4 window displays to allow you to select the report layout.
<li>Select a layout option.</li>
<li>Click the '''Next''' button.</li>
:The iReport Wizard, Step 5 window displays.
<li>Click the '''Finish''' button.</li>
<li>Save the report by doing one of the following:</li>
*Click the [[Image:iRepSave.png]] icon.
*From the File menu, select '''Save'''.
::The Save report window displays.
<li>Enter a name for the report in the File name field.</li>
<li>Click the '''Save''' button.</li>
</ol>
 
====Part 2. Create a sub-report for the linked item====
The next part of the process for creating a report on linked items requires you to create a sub-report for the item to which the primary item is linked.
 
<ol>
<li>Expand the detail section of the report.</li>
<li>Click the [[Image:iRepBand.png]] button to add a sub-report.</li>
:The cursor changes to a crosshair.
<li>Click the detail section of the report.</li>
<li>While holding down the mouse button, drag the cursor to form the rectangle which will contain the sub-report. </li>
<li>Release the mouse button.</li>
:The window to create a new report or use an existing one displays.
<li>From the window:</li>
<ol type="a">
<li>Select the ''Create a new report'' option.</li>
<li>Click the '''Next''' button.</li>
:The How fill the sub-report screen displays.
</ol>
<li>From the window:</li>
<ol type="a">
<li>Select the data source for the child item from the '''Connection/Data Source''' list.</li>
<li>Click the '''Next''' button.</li>
:The window to select the attributes to include in the report displays.
</ol>
<li>From the window:</li>
<ol type="a">
<li>Select the attributes that you would like to include in the report.</li>
<li>Click the '''Next''' button.</li>
:The window to select a layout displays.
</ol>
<li>From the window to select a layout:</li>
<ol type="a">
<li>Select the layout option.</li>
<li>Click the '''Next''' button.</li>
:The window to specify the sub-report expression displays.
</ol>
<li>From the window to specify the sub-report expression:</li>
<ol type="a">
<li>Enter a name for the sub-report.</li>
<li>Click the '''Finish''' button.</li>
:The sub-report displays.
</ol>
</ol>
 
====Part 3. Add the parameters to the sub-report====
The next part of the process for creating a report on linked items is to define parameters that will be used for passing the guid of the primary item between the sub-report and main report.
 
<ol>
<li>Click the '''New''' button.</li>
:The Add/modify parameter window displays.
<li>From the Add/modify parameter window:</li>
<ol type="a">
<li>In the '''Parameter Name''' field, enter a name for the parameter that will be used to identify the guid for the primary item.</li>
</ol>
</ol>
 
{| class="wikitable"
|-
| [[File:Note.jpg | 40px]] || Although there are no requirements for the parameter name, you should enter a name that is easy to remember and meaningful. Make note of this parameter name since it will used in a later step.
|}
 
<ol start="3">
<ol type="a" start="2">
<li>Click the '''OK''' button.</li>
</ol>
<li>Close the window that displays the list of all parameters.</li>
</ol>
 
====Part 4. Create a query in the sub-report to associate the guid to the primary report item====
The next part of the process for creating a report on linked items is to create a query that defines how the primary item and the linked item are related in the IMSMA database.
 
<ol>
<li>From the '''Data''' menu, select '''Report Query'''.</li>
:The Report query window displays.
<li>From the Report query window:</li>
<ol type="a">
<li>Select ''ImsmaQuery'' from the '''Query language''' list.</li>
</ol>
</ol>
 
{| class="wikitable"
|-
| [[File:Note.jpg | 40px]] || The following query is different from the query used when creating a report on items with data subsets.
|}
 
<ol start="3">
<ol type="a" start="2">
<li>In the field below the Query language list, enter links.toGuid = "$P{''ParameterName''}"</li>
where ''ParameterName'' is the name of the parameter that you created for the parent item guid.
<li>Click the '''OK''' button.</li>
:The Report query window closes.
</ol>
<li>Ensure that the Query Executor data source is selected from the list.</li>
<li>Click the button to compile the sub-report.</li>
</ol>
 
====Part 5. Add attributes and parameters to the main report====
The next part of the process for creating a report on linked items is to update the main report to include the guid attribute and parameters that will be used to associate the primary item to the linked item.
 
<ol>
<li>Display the main report by doing one of the following:</li>
*From the '''Window''' menu, select the name of the report.
*Close the sub-report.
*Bring the primary item report to the foreground by double-clicking the report name that is displayed in the Files pane.
<li>Double-click the sub-report box within the report.</li>
:A window displays four tabs (Common, Sub-report, Sub-report (Other), and All).
<li>From the window:</li>
<ol type="a">
<li>Select the Sub-report (Other) tab.</li>
<li>Click the '''Add''' button.</li>
:The Add/modify parameter window displays.
</ol>
<li>From the Add/modify parameter window:</li>
<ol type="a">
<li>In the '''Sub-report Parameter Name''' field, enter the parameter name that you used for the primary report item guid.</li>
</ol>
</ol>
 
{| class="wikitable"
|-
| [[File:Note.jpg | 40px]] || This is the parameter that you created previously.
|}
 
<ol start="5">
<ol type="a" start="2">
<li>In the '''Default Value Expression''' field, enter ''$F{guid}''.</li>
<li>Click the '''OK''' button.</li>
</ol>
<li>Close the window with the four tabs.</li>
 
====Part 6. Compile and execute the main report====
<ol>
<li>Ensure that the data source for the item in the main report is selected from the list.</li>
<li>Click the [[Image:iRepCompile.png]] button to compile the report.</li>
<li>Click the [[Image:iRepRun.png]] button to execute the report.</li>
:The report results displays.
</ol>
0
edits

Navigation menu