Changes

Jump to: navigation, search

Create iReport Templates with Subreports

10,792 bytes added, 20:02, 23 October 2012
Created page with "==Advanced Reports== ===Sub-Report=== <p>Sub-report is reports within a report; thus, providing a way to generate a report that includes data on the target IMSMA Item as well ..."
==Advanced Reports==
===Sub-Report===
<p>Sub-report is reports within a report; thus, providing a way to generate a report that includes data on the target IMSMA Item as well as data on other IMSMA Items that are associated to the target IMSMA Item. Generally a sub-report is used in a situation where you have one or more sets of data relating to a single IMSMA item. A common use case would be a Location report with multiple details bands of different IMSMA items (Hazard, Hazard Reduction, Accident, Victim, MRE, and QC).</p>
<p>Regardless of what IMSMA data you’re including in your report and sub-reports, there are 6 basic steps to create a report with sub-reports:</p>

:Step 1 – Create the Main report
:Step 2 – Add Sub-report to the Main report
:Step 3 – Add Parameter to the Sub-report
:Step 4 – Define Report Query for the Sub-report
:Step 5 – Add Sub-report Parameter to the Main report
:Step 6 – Repeat Step 2-5 for additional Sub-reports

[[Image:iRepStep01.png|center|500px|''Step 1 – Create the Main Report'']]

====''Step 1 – Create the Main Report''====

<p>Before creating the main report, you will need to determine what data to be included on your report. For example, if you are creating a report about Hazard with all the Progress Report data, then the target IMSMA item for your main report should be Hazard and the target data for your sub-report should be Hazard Reduction assuming that Progress Reports are entered into the system as Hazard Reduction. Below is a list of questions and things to be considered when designing a report.</p>
*What are all the data to be included on the report?
*What is the target IMSMA Item for the Main report? This is the primary data of your report.
*What is the target IMSMA Item for the sub-reports? This is the secondary data of your report.
*Determine the relationship between the primary data and the secondary data. How did they get reconciled to one another?

<p>The Main report should be created with the IMSMA item determined to be the primary data of your report. The Main report is just a basic report and can be created using the steps provided in the “Creating a Basic Report” section. Below are the instructions:</p>
<ol>
<ol type="a">
<li>Create your main report with the IMSMA item determined as the primary data of your report. This is just a basic report.</li>
<li>Save your main report</li>
<li>Compile your main report to make sure that it’s error-free.</li>
</ol>
</ol>

[[Image:iRepStep02.png|center|500px|''Step 2 – Add Sub-report to the Main report'']]

====''Step 2 – Add Sub-report to the Main report''====

<p>Sub-report is reports within a report. As mentioned earlier, a sub-report should be created with the IMSMA Item determined as the secondary data of the report. Below is the instructions to create a sub-report:</p>

<ol type="a">
<li>Increase the size of Detail section of the Main report to make room for your sub-report.</li>
:'''View''' -> '''Bands''' -> '''detail''' -> '''increase the Band Height''' -> '''Apply'''
<li>Click the [[Image:iRepBand.png]] button</li>
<li>Click the detail section of the report. Hold down the mouse button and drag the cursor to create a rectangle to define the area of sub-report. Release the botton and the window below displays.</li>
</ol>

[[Image:iRepBandScreen.png|center|500px]]

<ol type="a" start="4">
<li>Click '''Next''' to define a new sub-report unless you have an existing report that you would like to use for sub-report.</li>
<li>Select from the '''Connection/Data Source''' list. This should be the IMSMA item determined as the secondary data of your report. For example, if you are creating a report about Hazard with Progress Reports, then “Hazard Reduction” should be the data source for the sub-report. Click Next.</li>
<li>Select the attributes to be included in your sub-report. Click '''Next'''.</li>
<li>Select the layout option. Click '''Next'''.</li>
<li>Enter a name for the sub-report. Click Finish. The sub-report displays.</li>
</ol>

[[Image:iRepStep03.png|center|500px|''Step 3 – Add Parameter to Sub-report'']]

====Step 3 – Add Parameter to Sub-report====

<p>To connect a sub-report to the Main report, we need to create a parameter for passing the identification (guid) of the primary IMSMA Item between the sub-report and the main report. Below is the instructions to create the parameter you need for the sub-report:</p>

<ol start="a">
<li>At the Sub-report window, select View -> Parameters.
:The window displays the parameters.
</ol>

[[Image:iRep09.png|center|500px|''Figure 9. Window of fields, variables, and parameters'']]
<div align="center">
''Figure 9. Window of fields, variables, and parameters''
</div>

<ol type="a" start="2">
<li>Click the '''New''' button.</li>
:The Add/modify parameter window displays.
<li>From the Add/modify parameter window:</li>
*Enter “'''''object_guid'''''” for the '''Parameter Name''' where ''object_guid'' is the suggested parameter name in the Column D of the Table - Required Parameters for Sub-report below.
*Click the '''OK''' button.
<li>Close the window that displays the list of all parameters.</li>
</ol>

[[Image:iRepStep04.png|center|500px|''Step 4 – Define Report Query for Sub-report'']]

====Step 4 – Define Report Query for Sub-report====

<p>The next step is to create a report query for the sub-report you just created in Step 2 to define how the IMSMA item on the Main report is related to the IMSMA item on the Sub-report. Below is the instructions on how to define the Report Query:</p>

<ol start="23">
<li>At the Sub-report window, select Data -> Report Query.</li>
:The Report query window displays.
<li>From the Report query window:</li>
<ol type="a" start="3">
<li>Select ImsmaQuery from the Query language list.</li>
<li>Enter object.guid = “$P{object_guid}” for the ImsmaQuery where object is the object type of the IMSMA item on the Main report - See Column E in the Table - Required Parameters for Sub-report below to determine the ImsmaQuery string for your Sub-report.</li>
</ol>
</ol>

[[Image:iRep10.png|center|500px|''Figure 10. Define Report Query for Sub-report'']]
<div align="center">
''Figure 10. Define Report Query for Sub-report''
</div>

<ol>
<ol type="a" start="5">
<li>Click '''OK'''.</li>
:The Report query window closes.
<li>Click the [[Image:iRepCompile.png]] button to compile the sub-report.</li>
</ol>
</ol>

[[Image:iRepStep05.png|center|500px|''Step 5 – Add Subreport Parameter to Main Report'']]

====Step 5 – Add Subreport Parameter to Main Report====

<p>We created a parameter on the sub-report to connect to the Main report in Step 3, now we need to create a parameter on the Main report as well. Below is the instructions to create the parameter you need for the Main report:</p>
<ol type="a">
<li>Make sure you are at the Main report by selecting the name of the Main report from the '''Window''' menu or double-clicking the Main report from the Files pane.</li>
<li>Double-click the sub-report box within the Main report.</li>
:A window displays four tabs (Common, Sub-report, Sub-report (Other), and All).
<li>Select the Sub-report (Other) tab. Click '''Add'''.</li>
<li>From the Add/modify parameter window:</li>
<ol type="i">
<li>Enter ''“$P{object_guid}”'' for the '''Sub-report Parameter Name''' field where ''object_guid'' is the parameter name you created in Step 3 for the Sub-report. See Column B in the Table – Required Parameters for Sub-report below to determine the parameter name.</li>
<li>In the '''Default Value Expression''' field, enter ''$F{guid}''.</li>
<li>Click '''OK''' and close the windowthe four tabs.</li>
</ol>
</ol>

[[Image:iRepStep06.png|center|500px|''Step 6 – Repeat Step 2-5 for additional sub-reports.'']]

====Step 6 – Repeat Step 2-5 for additional sub-reports.====

<p>You can have multiple sub-reports in one Main report. To add more sub-reports to the Main report, just repeat Step 2 to Step 5.</p>
<p>Once you have all the sub-reports created for your Main report, you can compile and run your Main report.</p>
<p>Below is the table listing typical parameters required for both Main report and Sub-report.</p>

<table border="1">
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
<td>E</td>
<td>F</td>
</tr>
<tr>
<td>If your Main report is</td>
<td>Sub-report parameter on Main report</td>
<td>Your Sub-report can be…</td>
<td>Parameter on Sub-report</td>
<td>Report Query defined on Sub-report</td>
<td>Comments</td>
</tr>
<tr>
<td>Location</td>
<td>location_guid</td>
<td>Hazard,
Hazard Reduction,
Accident,
Victim,
MRE, or
QC
</td>
<td>location_guid</td>
<td>location.guid = "$P{location_guid}"</td>
<td>Relationship is defined as “New” to a Location during the reconciliation. </td>
</tr>
<tr>
<td>Hazard, Hazard Reduction,
Accident,
Victim,
MRE, or
QC
</td>
<td>object_guid</td>
<td>Hazard, Hazard Reduction,
Accident,
Victim,
MRE, or
QC
</td>
<td>object_guid</td>
<td>links.toGuid = "$P{ object_guid}"</td>
<td>Relationship is defined using “Link” during the reconciliation.</td>
</tr>
<tr>
<td>MRE</td>
<td>mre_guid</td>
<td>MRE Detail</td>
<td>mre_guid</td>
<td>mre.guid = "$P{mre_guid}"</td>
<td>Relationship is defined as “New” to a MRE during the reconciliation.</td>
</tr>
<tr>
<td>Hazard Reduction</td>
<td>hazreduc_guid</td>
<td>Impact survey,
Interviewee,
Sector, or
Vegetation removal
</td>
<td>hazreduc_guid</td>
<td>hazreduc.guid = "$P{hazreduc_guid}"</td>
<td>Relationship is defined as “New” to a Hazard Reduction during the reconciliation.</td>
</tr>
<tr>
<td>Interviewee</td>
<td>interviewee_guid</td>
<td>Question</td>
<td>interviewee_guid</td>
<td>interviewee.guid = “$P{ interviewee_guid}”</td>
<td>Relationship persisted automatically when Questions are entered for each Interviewee at Field Report.</td>
</tr>
<tr>
<td>Sector</td>
<td>sector_guid</td>
<td>Sample</td>
<td>sector_guid</td>
<td>sector.guid=”$P{sector_guid}”</td>
<td>Relationship persisted automatically when Samples are entered for each Sector at Field Report.</td>
</tr>
<tr>
<td>Victim</td>
<td>victim_guid</td>
<td>Received MREs</td>
<td>victim_guid</td>
<td>victim.guid = "$P{victim_guid}"</td>
<td>Relationship is defined as “New” to a Victim during the reconciliation.</td>
</tr>
<tr>
<td>Task</td>
<td>task_guid</td>
<td>Work Item</td>
<td>task_guid</td>
<td>task.guid = "$P{ task_guid}"</td>
<td>Relationship is defined when adding a new Work Item to a Task at the Task Editor Window.</td>
</tr>
</table>

<p>The following section of the Advance Reports chapter discusses relationships between Items in IMSMA and also provides instructions on how to create a specific report/sub-reports.</p>

[[Category: Administrating IMSMA]]
[[Category: i-Report]]
0
edits

Navigation menu