Changes

Jump to: navigation, search

Create iReport Templates with Subreports

14,472 bytes added, 20:07, 23 October 2012
no edit summary
<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>
==Reports on Items with a Direct Relationship==<p>The reports discussed so far in this training module have been based on a single data source. In this part of the training module, you will learn to create more complex reports that reference multiple data sources. Some items are dependent on the existence of another item. This type of relationship is referred to as a direct relationship. For example, an accident, hazard, hazard reduction, MRE, QC, or victim has a direct relationship to the location to which it is associated. The accident, hazard, hazard reduction, MRE, QC, or victim cannot exist unless it is associated with a location. This direct relationship is enforced in IMSMA via the reconciliation process.</p> [[Image:iRep11.png|center|500px|''Figure 11. Location and item records directly associated with it'']]<div align="center">''Figure 11. Location and item records directly associated with it''</div> Direct relationships also exist when subsets of data are contained within an item. 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.  The following sections will describe the process for creating reports on items that have a direct relationship between them. ===Country Structure Areas and Associated Locations===Although a location must be associated with a country structure area, the process for creating a report of locations in a country structure area is very similar to a basic report. The location data source contains a field for each country structure area that is defined in your IMSMA database.  To create a report that lists locations within a country structure area: <ol><li>From the '''File''' menu, select '''Report Wizard'''.</li>:The iReport Wizard window displays. <li>From the '''Connection/Data Sources''' list, select ''Location Data Source''.</li><li>Click the '''Next''' button.</li>:The window to select the attributes to include in the report displays. <li>From the Step 2. select fields screen:</li><ol type="a"><li>Select the country structure level(s) on which you would like to list the associated locations.</li><li>Select the fields that you would like to include in the report.</li><li>Click the '''Next''' button.</li>:A window displays the selected fields. </ol><li>Click the '''Next''' button.</li>:The window group the report data displays. <li>From the Group lists, select the country structure level(s) that you selected in step 4a.</li></ol> {| class="wikitable"|-| [[File:Note.jpg | 40px]] || Be sure to select the highest country structure level for Group 1, followed by the next highest country structure level for Group 2, and so on. |} <ol start="7"><li>Click the '''Next''' button.</li>:The window to select a layout displays. <li>From the window to select a layout:</li><ol type="a"><li>Select the layout option for the report.</li><li>Click the '''Next''' button.</li>:The window displays a message stating that you have successfully created a new report.<li>Click the '''Finish''' button.</li>:The template for your report displays. <li>Click the [[Image:iRepCompile.png]] button to compile the report.</li>:The Save report window displays.<li>Enter a name for the report in the '''File name''' field.</li><li>If there are no compilation errors, you may click the [[Image:iRepRun.png]] button to run the report.</li>:The results of the report display in the iReport JasperViewer window. </ol></ol> ===Location and Associated Items===A report of locations and associated items requires you to create an iReport sub-report. A sub-report is a report that is contained within another report. A report on locations and its associated item records will require you to create a report and a sub-report. The main report will contain the data for the location. For each associated item that you would like to include, you will need to create a sub-report.  [[Image:iRep12.png|center|500px|''Figure 12. Location and associated item records'']]<div align="center">''Figure 12. Location and associated item records''</div> All records in IMSMA have a ''guid''. A ''guid'' is a unique value that identifies the record in the IMSMA database. Because the guid is lengthy and comprised of alphanumeric characters, it is typically not a useful value to display in a report. However, the guid is necessary in determining which item records have a direct relationship.  All accidents, hazards, hazard reductions, MREs, QCs, and victims are associated with a single location. The information about the location to which an item record is associated is stored in the location_guid field of the item table and corresponds to the location_guid of the location to which it is associated ([[:Image:iRep03.png|Figure 13]]).  [[Image:iRep13.png|center|500px|''Figure 13. location_guid'']]<div align="center">''Figure 13. location_guid''</div> The location_guid field in the item table contains the guid of the location to which the item record is associated. [[:Image:iRep14.png|Figure 14]] shows an example of a location and the accident and hazard that are associated to the location. Notice that the location_guid value (1234-1234) in the accident and hazard are identical to the location_guid of the location. [[CategoryImage:iRep14.png|center|500px|''Figure 14. location_guid example'']]<div align="center">''Figure 14. location_guid example''</div> Creating a report of a location and associated items will require you to complete the following parts::*Part 1: Create a report with location fields:*Part 2: Create a sub-report for the associated item:*Part 3: Add parameters to the sub-report:*Part 4: Create a query the in sub-report to associate the guid to the location report:*Part 5: Add parameters to the location report:*Part 6: Administrating Compile and execute the location report ====Part 1. Create a report with location fields====The first part of creating a report of locations and their associated items is to create a report of the location fields you would like to include. <ol><li>Ensure that the IMSMAserver is started.</li><li>From the '''File''' menu, select '''Report Wizard'''.</li><li>From the '''Connection/Data Sources''' list, select Location Data Source to create a report of locations.</li><li>Click the '''Next''' button.</li>:The iReport Wizard, Step 2 window displays a list of the location attributes.<li>Select the fields you would like to include for the location.</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 associated item==== <table border="1"><tr><td>The next part of the process for creating a report on locations and its associated items requires you to create a sub-report within the location report.</td></tr></table> <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></ol></ol> [[Image:iRep15.png|center|500px|''Figure 15. Detail band height'']]<div align="center">''Figure 15. Detail band height''</div> <ol><ol type="a" start="3"><li>Click the '''Apply''' button.</li><li>The height of the band increases based on the value that you entered.</li></ol></ol> [[Image:iRep16.png|center|500px|''Figure 16. Increased detail band'']]<div align="center">''Figure 16. Increased detail band''</div> <ol start="2"><li>Click the [[Image:iRepBand.png]] button to add a sub-report.</li>:The cursor changes to a crosshair. </ol> [[Image:iRep17.png|center|500px|''Figure 17. Sub-report button'']]<div align="center">''Figure 17. Sub-report button''</div> <ol start="3"><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 below displays. </ol> [[Image:iRep18.png|center|500px|''Figure 18. Sub-report creation'']]<div align="center">''Figure 18. Sub-report creation''</div> <ol start="6"><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 associated item from the Connection/Data Source list. For example, if you are creating a report of locations and its associated accidents, you would select the accident data source.</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==== <table border="1"><tr><td>The next part of the process for creating a report on locations and its associated items is to define parameters that will be used for passing the location id between the sub-report and location report.</td></tr></table> <ol><li>From the '''View''' menu, select '''Parameters'''.</li>:The window displays the parameters. </ol> [[Image:iRep19.png|center|500px|''Figure 19. Window of fields, variables, and parameters'']] <div align="center">''Figure 19. Window of fields, variables, and parameters''</div> <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 location.</li></ol></ol> {| class="wikitable"|-| [[CategoryFile: iNote.jpg | 40px]] || Although there are no requirements for the parameter name, you should enter a name that is easy to remember and meaningful (for example, ''location'' or ''location_guid''). 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><li>Close the window that displays the list of all parameters.</li></ol></ol> ====Part 4. Create a query in the sub-report to associate the guid to the location report==== {| class="wikitable"|-| [[File:Note.jpg | 40px]] || 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 location.guid = "$P{''ParameterName''}"</li>where ''ParameterName'' is the name of the parameter that you created for the location guid.</ol></ol> [[Image:iRep20.png|center|500px|''Figure 20. Query for report on locations and associated items'']]<div align="center">''Figure 20. Query for report on locations and associated items''</div> <ol start="3"><ol type="a" start="3"><li>Click the '''OK''' button.</li>:The Reportquery window closes. </ol><li>Click the [[Image:iRepCompile.png]] button to compile the sub-report.</li></ol> ====Part 5. Add parameters to the location sub-report==== {| class="wikitable"|-| [[File:Note.jpg | 40px]] || The next part of the process for creating a report on locations and its associated items is to update the location report to include the parameter that will be used to associate the location record to item records. |} <ol><li>Display the location report by doing one of the following:</li>*From the '''Window''' menu, select the name of the location report. *Close the sub-report. *Bring the location report to the foreground by double-clicking the location 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 location.</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></ol> ====Part 6. Compile and execute the location report==== <ol><li>Ensure that the ''Location'' data source 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