Page
Page
Table of Contents
Lab 1: Creating synonyms..................................................................................................................................3 Lab 2: Defining joins in your synonyms............................................................................................................7 Lab 3: Report Assistant....................................................................................................................................14 Lab 3.1: Creating Simple Summary and Gross Profit Display....................................................................14 Lab 3.2: Creating a Sample Detail Display .................................................................................................23 Lab 4: Graph Assistant......................................................................................................................................40 Lab 4.1 Creating a Bar Chart ........................................................................................................................40 Lab 4.2 Creating a revenue trend over time chart.........................................................................................46 Lab 5: Converting existing QRY/400 objects...................................................................................................52 Lab 5.1: Creating Metadata from Query/400 objects ..................................................................................52 Lab 6: Active Reports .......................................................................................................................................56 Lab 6.1: Creating an Active Report ..............................................................................................................56 Lab 6.2: Using an Active Report ..................................................................................................................60 Lab 7: OLAP (Online Analytical Processing) ..................................................................................................73 Lab 7.1: Enabling an OLAP report ..............................................................................................................73 Lab 7.2: Defining OLAP metadata using the Developers Workbench .......................................................74 Lab 7.3: Working with an OLAP-enabled report .........................................................................................83 Lab 8: HTML Composer .........................................................................................................................................................................100 Lab 8.1: Adding parameters to existing reports .........................................................................................101 Lab 8.2: Designing the layout for the HTML report ..................................................................................106 Appendix: Optional Exercises.........................................................................................................................120 Lab A: Report Assistant .............................................................................................................................120 Lab B: Report Assistant .............................................................................................................................126 Lab C: Using Web Query to enhance a QRYDFN ....................................................................................129 Lab D: Developers Workbench .................................................................................................................133 Lab D.1: Configuring Developers Workbench .....................................................................................134
Page
a. b.
Page
2. Expand Managed ReportingDomainswebqryXXApplications 3. Under Applications, right-click on application folder webqryXX and select NewSynonym
4. Under Configured Adapters: a. Expand DB2 cli b. Select *LOCAL (the local IBM i system where the tables reside) and click OK. Note: There are three types of System i objects that you can query with the DB2 Web Query product: i. DB2 for i5/OS refers to the majority of your tables created with either an SQL CREATE TABLE statement or by using DDS and a CRTPF command. ii. DB heritage files refers to files that have multiple record formats or multiple members. Files described by this adapter will utilize the OPNQRYF command on the IBM i. This
Page
directs the query to the older, and typically slower, database optimizer (CQE) iii. Query/400 imports existing Query/400 definitions and converts them to both table and report definitions.
5. Under Further restrict search to: a. Make sure Tables is selected. b. Click the Views checkbox to de-select it. Note: This results in a nice, concise list of only your physical files or tables. If you have SQL views or logical files you wish to query, the Views checkbox must be selected. If the library is an SQL collection or schema, selecting Views also displays the SQL catalog views. c. For the Library specify QWQCENT d. Click Next
6. You see a window with a list of tables in library QWQCENT. Specify the following: a. For Prefix, specify CEN_ Note: This causes the table names to be displayed with a CEN_ prefix (for example, CEN_ALERTS, CEN_ORDERS, etc.) If you have a long list of table names, this is a way to keep all related tables grouped together. b. Select Overwrite existing synonyms (Note: you may have to use the vertical scroll bar to see this setting) c. From the list of files, select the ORDERS table
Page
7. Your synonym for the ORDERS table has been created. Click Close to continue.
8. Back in the Developer Workbench Explorer window, you see two files in the webqryXX folder: cen_orders.acx The access file for the synonym. Contains file level information such as the library that the file resides in. cen_orders.mas The master file for the synonym. Contains information about all of the fields in the file.
Page
Once in the tool, we want to add new join segments to the ORDERS file. For this we will create new segments using the metadata import function. b. Right-click cen_orders and select AddSegment Via Metadata Import
Page
You see the Create Synonym dialog window. c. Under Configured Adapters, expand DB2 cli, select *LOCAL and click on OK.
d. Under Further restrict search to: Select Tables, de-select Views, and specify library QWQCENT. Click Next
Page
e. For Prefix, specify CEN_ and select the files INVENTORY, PLANT, and STORES. These are the files you will join to the ORDERS file. Click the Create Synonym button.
You see a confirmation window indicating that the synonyms were successfully created.
Page
10
2. Define Join Properties Now that the synonyms for the join segments have been created, you must define the fields that join the files to the ORDERS tables. a. Select and right-click on CEN_stores. Select Join Properties
b. STORECODE is the field that is used to join ORDERS to STORE. Select this field under both tables and click the map button. (located between the tables lists) This will bring the join formula into the Expression pane. Make sure Inner Join is selected for the Join Type. Click OK to continue.
Page
11
c. While segment CEN_stores is still selected and under Attribute, change the join segment type (SEGTYPEType) settings from Multiple (the default) to Unique.
Page
12
Once you have done this, the icon next to the CEN_stores segment becomes a red color 3. Click the Save icon to save your synonym
4. Repeat steps 2a 2c for the CEN_Inventory segment. The join field for this join is PRODUCTNUMBER 5. Repeat steps 2a 2c for the CEN_Plant segment. The join field for this join is PLANTCODE When you are finished, you have created a cluster for the ORDERS table. The segments of this cluster should look like this:
Page
13
Page
14
Page
15
a. b.
2. Create a folder for the reports Expand Domains your domain (webqryXX) Reports1: Getting Started Labs. Right-click the Reports folder and select New Folder. Key Folder Name: Manufacturing Reports and click Save.
Page
16
(List), will show all the fields from all the tables in one long alphabetical list. 4. Drag PRODUCTTYPE from the list of available fields on the left and drop it in the Sort by box in the center of your screen. Tip: If you are using the Firefox browser, you may not be able to drag and drop. In this case you will need to first click on the box to receive the field (Sort by) and then double-click the desired field name in the field list. 5. Drag LINETOTAL from the list of available fields and drop it in the Sum, Print box on the right. LINETOTAL is the gross revenue for each line item on an invoice. 6. Click the Add grand totals to the end of the report checkbox to select it.
Page
17
7. Click the Run arrow to produce your first report. A new browser window is launched and your first report is displayed:
8. Close the browser window with the report. This will return you back to the Report Assistant dialog window. 9. Save your report, naming it Revenue by Product Type.
Page
18
Next you will format LINETOTAL, and add a count of the number of orders for each product type. 10. Highlight the LINETOTAL field in the Sum, Print box and open the Field options - LINETOTAL dialog near the bottom of the screen.
Page
19
The Field options display allows you to work with the properties for an individual field. You can describe standard and conditional formats based on values in your report. You can set up a field so that when a user clicks on it they will drill down to a lower level report. You can specify if you want the report to display the actual data in a field or if you want to see the average, minimum, or maximum value in the field instead. If you are working with a sort field, you have additional capabilities to control the sort, add ranking columns, and control the subheadings and subfooting. 13. Click the ellipsis (three dots) to the right of the Format in report as window. 14. Change the LINETOTAL field to be displayed with Comma inclusion and Floating currency (you may need to scroll down to see both options) and click OK.
Page
20
15. On the Field selection tab ensure that LINETOTAL is highlighted. Then make sure the Field options LINETOTAL dialog is open and select the Title tab.
Notice that the Title is Revenue. This panel is where you can enter your own, more meaningful column headings for users. In our case, the LINETOTAL column was defined to DB2 as having a heading of Revenue. DB2 Web Query imports DB2s heading attribute into the metadata attribute Title. The last thing we are going to do with this summary report for now is add a count of the number of orders for each product type. 16. Drag ORDERNUMBER from the field list on the left to the Sum, Print box. 17. Open the Field options ORDERNUMBER dialog if it is closed. Under the Display tab, select Count from the Calculated as drop-down list.
Page
21
Note: If you dont see a long list of field options, including Count, verify that your report is a summary report and not a detail report -- in other words, that Sum and not Print is highlighted.
18. Change the field format to integer, 7, and Comma inclusion - C using the ellipsis button and click on OK.
Workshop: DB2 Web Query for i 19. Select the Title tab. 20. Change the title to Order Count on two lines.
Page
22
Workshop: DB2 Web Query for i 21. Using the up and down arrows LINETOTAL.
23
to the right of Run at the top of the screen to run the report.
Page
24
After you have chosen your table you are presented with a list of all the column or field names belonging to that table or cluster of tables. 3. Drag and drop PRODUCTTYPE and PRODUCTCATEGORY into the Sort by box. NOTE: Make sure PRODUCTTYPE is listed before PRODUCTCATEGORY. 4. Drag and drop LINETOTAL and COSTOFGOODSSOLD into the Sum, Print box. 5. Click the Add grand totals to the end of the report checkbox.
6. In the Field options panel use the ellipsis button to add commas to the formatting of LINETOTAL, and COSTOFGOODSSOLD.
Page
25
Page
26
Note: There are two ways to create calculated fields in DB2 Web Query. When you use the define field you are adding the definition to the list of fields within the table. This field is calculated every time a record is read and selected. Beside the Sum, Print heading is a picture of a wizards wand . This allows you to create a computed field. In this case the field isnt calculated until after the data is sorted and all aggregation is complete. Computed fields are often required for percentages and variances. The right panel can be used to display the precoded functions that are available or to display the list of fields either alphabetically or in a hierarchical structure: file then field name. Try the different buttons. 8. Enter a field name of Gross_Profit. 9. Select the list icon in the upper right. This displays the list of available field names alphabetically. 10. Create the formula LINETOTAL minus COSTOFGOODSSOLD by double-clicking the field names and using the - button on the calculator pad or on your keyboard. Note: If you use your keyboard, be sure to include a space after the -. Tip: Field names in the defined field definition panel must all be in upper case. 11. Click the Format button for Gross-Profit and define your field as being an integer, 10, long, with commas and a floating currency. Then click on OK.
Page
27
Tip: When creating your own reports ensure that the field length is large enough to handle the commas, dollar sign and the maximum digits possible. 12. Click OK and then drag and drop Gross Profit into the Sum, Print box.
13. Verify that the Gross_Profit field is highlighted and open the Field options Gross_Profit dialog near the bottom of your screen. Select the Title tab. 14. Label the column Gross Profit on two lines.
Page
28
Generating subtotals
Next you add subtotals for each product type. 26. Under the Sort by pane, highlight PRODUCTTYPE and make sure that the Field options PRODUCTTYPE dialog is open. 27. Select the Sorting tab and check Subtotal numeric sum/print fields.
Page
29
28.
29.
30. To change the default subtotal heading (*TOTAL) make sure that PRODUCTTYPE is highlighted. Go to the Field options - PRODUCTTYPE display and select the Subtotal tab.
Page
30
31.
Tip: By default all columns are added to create a total line. You can override individual columns and request that instead of summing the column, the total line should display the result of calculations such as a count of values or the average of the values. Look at the options for Sum under Prefix. 32. Save the report as Gross Profit Report and run the report.
Page
31
MS Excel Output
There are many possible output formats for your report. Note: In the appendix there are optional labs for testing additional output options such as PDF and On-demand paging. 33. From the Report options tab view the options in the drop down box Generate report as. Changing the selection in the second drop-down list to the right changes the output choices in the first list. Select EXL2KFORMULA - Excel w/formula.
34. Rerun your report. Note: Should you receive the Opening WFServlet dialog box, select Open with Microsoft Office Excel (default) and click on OK.
Page
32
Notice the Subtotal for Camcorders. If you look at the Excel input line you see that this is represented as a formula as opposed to an actual value of $103,516,731. This is a very nice feature for users who want to download reports and then analyze the data and possibly delete or move rows of data. Having formulas instead of values in your report allows the total fields to adjust automatically. If you want to see the constant values downloaded then simply choose Excel 97 or Excel 2000 for your output. 35. Close the Excel spreadsheet without saving it and change the output back to HTML Web browser and save as Gross Profit by Product Type.
Parameterized reports
End-users have requested to be able to print the gross profit ranking report for a single product type requested at runtime. To do this you must add an input parameter. 36. Go to the Selection criteria tab. 37. Drag the PRODUCTTYPE field onto the empty Screening conditions panel on the right. 38. Click <Select values> to define the parameter. 39. Select Parameter and then click the Auto Prompt icon .
Page
33
40. Ensure that your selection is Dynamic. For Description, enter Select product type:. Accept the default name for this parameter -- PRODUCTTYPE. Be sure the Data Source: is CEN_ORDERS and Field: is PRODUCTTYPE. Click OK twice.
Page
34
Note: Choosing Dynamic selection presents the users with a distinct list of current values for the column when the query is run. Static allows you to define a predefined set of values. If you allow the users to Select multiple values at runtime, they will be able to use the Windows standard Ctrl and Shift keys to select multiple product types. For now accept the default of allowing a single input value. To make the drill down report more understandable we need to include a report heading containing the product type. NOTE: You must be using Internet Explorer as your browser to complete this next section. 41. Under the Report headings tab enter the Page heading Gross Profit by Product Category for Type . 42. Click the Show - Field list arrow on the left and drag PRODUCTTYPE to the end of the heading. 43. Add date and time of day information to the bottom of the page. Enter the Page footing Prepared on &DATE at &TOD NOTE: &DATE and &TOD are system variables that represent the current date and current time respectively.
Page
35
44. Save this report as Gross Profit by Product Category and run the report.
45. Close Report Assistant. You now have a report that accepts either a parameter passed by another report or a value entered by the user.
Page
36
48. Select the Execute procedure radio button. DB2 Web Query then populates the list with your reports. Navigate through the list and select your Gross Profit by Product Category report. 49. In the Alternate comment box enter Click to drill down to Gross Profit Report for users to see when they hover over the Product Type field. 50. Click Add.
Page
37
51. Key the name of the Parameter the drilldown report is expecting. In this case, PRODUCTTYPE. 52. Select the Field that you want passed into the parameter -- PRODUCTTYPE.
53. Click OK twice 54. Save your report as Revenue by Product Type with Drilldown. Remove the check mark in the Prompt for parameters and Show on users list options and click on OK.
Page
38
55.
In the parent or top level report, the product types are highlighted in blue indicating that they can be selected and you can then drill-down to a more detailed report. 56. Drill down (single-click) Audio.
Page
39
57.
CONGRATULATIONS you have finished the first and the longest set of labs. Wasnt it easy and wasnt it fun?
Page
40
Lab 4.1: Creating a simple bar chart with drill down capabilities
1. Right-click the Manufacturing Reports folder and select Graph Assistant. 2. Select the same CEN_ORDERS table you used in the previous labs.
Page
41
When you do this, you are presented with a list of the different types of graphs you can select from. 3. Click the Graph types pull-down and look at the various chart types available. For each chart type there are many variations shown under Graph Styles. 4. For this exercise choose a Bar type and select Clustered as the style. Look at the various different templates. Select Cylinder on grey for the template.
Next you define the fields representing the x and y axes for the chart. 5. 6. 7. 8. Click the Field selection tab. Drag LINETOTAL onto the Sum panel. This is your Y axis. Drag COUNTRY onto the X axis panel. Drag PRODUCTTYPE into the separate graph area box. By default this produces one chart for each
Page
42
11. Select the Headings tab; then select the Graph tab. Give your chart the title Revenue by Product Type and the subtitle Country Comparison.
Page
43
12. Save your graph as Revenue by Product Type Graph and then run it.
Page
44
14. Click Execute procedure; a list of your reports is shown in the top white panel. 15. Navigate to and select the Gross Profit by Product Category report that you created earlier. Once you have selected your procedure, the Add button becomes available. Click Add to add the parameter that you want to pass from this report to the Gross Profit by Product Category report.
16. Select Field PRODUCTTYPE (the field that you want to pass as the parameter value) and then enter the Parameter name. This name must match the name that the Gross Profit by Product Category report is expecting to be passed. You accepted the default PRODUCTTYPE for this parameter name (the input column name).
Page
45
17.
Drill down explained: When you drill down from one report to another, the child report is expecting a parameter to be passed. In your case this was PRODUCTTYPE that was linked in the Gross Profit by Product Category report to the PRODUCTTYPE field. In the parent report or graph, you indicate where the users can drill down. In this graph you said that the users could drill down on any LINECODE or bar. When they clicked a bar, you told the system that you wanted the Gross Profit by Product Category report to be run. You also indicated that you were going to pass the PRODUCTTYPE field referenced by the selected bar. You did this by passing the value as a parameter called PRODUCTTYPE. Since this is the name of the parameter the report was expecting, it accepts the value and runs the report. 18. Roll over the bars with your mouse. You should see the cursor change from an arrow to a hand. The hand indicates that you can drill down in this area. When you hover over a bar, you see information in a small pop-up window that shows you details about the bar. You see the product type, country, and revenue or line total.
Page
46
Page
47
Look at the various choices for line charts. 3. Absolute. Select Graph type as Line ->
To show product revenue trending over time, it is necessary to plot one point for every month for each product. To do this, the date field must be converted from year, month and day to a field with just the year and month. 4. 5. a new field. Go to the Field selection tab. Click the calculator button to define
Page
48
6. Name your new field MthYr. 7. In the panel where you define the formula for the new field, simply enter the name of the date it is based on, ORDERDATE. 8. Specify a Format of TMYY. T means that the month or day immediately following is represented as upper case text. YY means that you want the year formatted as a four-digit value. An example for MthYr is Jan, 2003. Note: A single Y would have meant to display a two-digit year. If we had wanted to put the year first we would have specified a format of YYTM. DB2 Web Query is very powerful when it comes to working with date and time fields. 9. Click OK.
The chart being created will have one line for each product type with a data point for LINETOTAL for each month in the data.
Page
49
10. Drag and drop MthYr to the X axis box, LINETOTAL to the Y axis box, and PRODUCTTYPE to the Create a separate graph for each value of this field box. 11. Open the Field optionsPRODUCTTYPE dialog and select the option to Merge graphs into a single graph.
Since an entry on an axis of Jan, 2007 is obviously a date, the heading or label for MthYr can be removed from the graph. 12. window. 13. dialog and delete the label MthYr. Highlight MthYr in the X axis Open the Field options - MthYr
Page
50
Lets make the X axis look a little better. 16. Select the Properties tab and then select the X axis tab that opens up. 17. Select Style labels. 18. Set Style for: Data. Note: If some of the options are not available, it is because a default style sheet is in effect. In that case check the box at the top that allows overriding the defaults. 19. Change the Text rotation to 45-degree bottom to top and click OK.
Page
51
Page
52
2. First you must select which adapter to use in the left panel. Right-click Query/400 and select Create Synonym.
Page
53
3. In the Create Synonym dialog box, enter the QWQCENT, the library where the QRYDFN objects reside. Then click Submit.
4. 5.
Key a Prefix of CEN_ and click on the Default Synonym Name REVGPFTQRY to select it. Click Create Synonym.
6.
Page
54
7.
8.
You are returned to the DB2 Web Query home page where you can see the metadata for your QRYDFN object is already created as a report. You can simply click this report to run it or right-click it to see editing options. 9. Click the report to run it.
Page
55
10.
As you can see, its easy to import and enhance existing AS/400 Queries. Note: The optional lab Lab C: Using Web Query to enhance a QRYDFN adds traffic lighting to the imported Query/400 report.
Page
56
4. From the Report options tab, change the report type to AHTML - Active Report.
Page
57
Now you will make a few formatting and highlighting changes. 6. On the Report Options screen click the Active Report Styling button which became active when you selected AHTML - Active Report.
Page
58
7. For this example, make sure that Report view is Tabular and change the Row selection colors to Yellow for Hover, change the Visualization colors to Red for Negative numbers and Orange for Positive results, and click OK.
All you are doing here is affecting the initial look of the report for the end-user. 8. Save your report as Gross Profit Active Report and run it.
Page
59
9. Click a drop-down arrow next to the heading for any column and choose Save Changes. Click Yes to the ActiveX caution, if presented. Note: The Save changes menu option is NOT available in the Firefox browser.
Page
60
You can optionally use your browsers Save As option to save the HTML page, as follows:
Note: If you use Export instead of Save Changes you are exporting the records without formatting and controls. The records can be exported to an HTML page, MS Excel, and CSV files. Tip: Once you have saved your report as an HTML file, it can be e-mailed to end-users. In this case the recipient would be able to view and analyze the report with no connectivity to the System i. In the next lab you continue to work with this Active Report, but you do so as if you were the disconnected user rather than the developer.
1. Close Web Query browser windows. 2. As an end-user, locate your Gross Profit.html page in C:\ and launch it with Internet Explorer.
Gross Profit.html page in C:\ and save it to a memory stick (or ask the instructor Active Reports use ActiveX controls. Based on your browser security settings, youto email this may see warning html file to you). You can then complete the messages, and you may be asked if you wantremainder of this content. of the lab at home.Allow to allow blocked section In this lab, always All you blocked content need is a web browser - DB2 Web Query is not required for this.
Page
61
Note: If you are connected to the System i you could also go to the DB2 Web Query home page, navigate to the report and run it. The first thing to do is to analyze the product categories, evaluating gross profit compared with revenue (LINETOTAL). 3. Click the drop-down arrow next to Gross Profit and select Sort Descending.
To make the report better fit the page, hide the Cost of Goods Sold column.
Page
62
4. Click the drop-down arrow next to Cost of Goods Sold and choose Hide Column.
Next, you Visualize a column. This is a very powerful tool that allows you to see, at a glance, relationships between various columns. 5. Select the drop-down list for the Gross Profit column and click Visualize. This displays colored bars in the chart below. Visualize provides a quick, visual representation of the data in a column.
Page
63
With the visualize bars, it is much easier to spot relationships. Notice that although speakers wouldnt have ranked very high in revenue they are extremely profitable and generate the third highest profit of any Product Category. 7. From the Gross Profit drop-down list, choose Calculate -> % of Total.
Page
64
8. Notice the new column which shows each Product Type row as a percent of the total Gross Profit in this report.
9. Finally go back to your Calculation selection for Gross Profit and this time select Sum. Your summary will print at the top of the page.
Page
65
Next you temporarily filter the report to concentrate on audio sales. 10. Select the drop-down menu for Product Type and choose Filter -> Equals.
Page
66
11. Clicking the drop-down arrow on the right gives you a list of the distinct values in the field. Choose Audio and then click Filter.
Note: Besides standard operators such as Greater Than and Equal, you can search for a string of data anywhere within a field using the Contains operand. By default Contains is not case sensitive. If case is important, there is an additional operand Contains (match case). There are also similar Omits and Omits (match case) options. 12. In the filtered chart you see both your filtered sum and the total sum for a column. In the upper left corner is a new icon SUB/TOT. Try clicking this icon. It cycles you through three views: the sum of all your data; the sum of your filtered data; and having both sums displayed concurrently.
Page
67
Note: If instead of clicking the Filter button in the Filter Selection window, you had clicked the Highlight button, your report would contain all the records but the ones meeting the filter criteria would be highlighted. At any point in time, you can choose the Restore Original option from a drop-down list to return to the original display. To see all the records, simply close the Filter Selection dialog box. A helpful way of analyzing the data often involves changing the grouping and looking at your numbers slightly differently. 11. Close the Filter Selection window. 12. Select the Gross Profit drop-down and choose Rollup -> Group By (X)(SUM) Product Category.
Page
68
13. Now click the Pie chart graph icon (third from left) to change the report you are looking at into a pie chart. You could have chosen line or bar charts also.
Page
69
Note: You could have produced the same graph directly from your full report by clicking the Gross Profit drop-down arrow and selecting Chart -> Pie -> Group By (X) Product Category. Tip: If you had created filters, then plotted your graph, and then closed the filter, by default your graph would change to reflect the displayed report or all the data. To keep the chart displaying the filtered data, select the Lock icon (second from the right). 14. Click the List icon (leftmost) and select Export to -> Excel.
Page
70
15. Close MS Excel and close the charting window. If you have time at the end of the lab experiment with the Pivot or Cross Tab functionality of Active Reports. Again this is accessed via the drop down menu selected at a field level. Before leaving Active Reports, lets take a quick look at the difference between a Tabular and Accordion Active Report. 16. If your report definition is closed, go to the DB2 Web Query home page, right-click and Open Gross Profit Active Report. Subtotals should be removed for tabular reports. 17. Select the Field selection tab, highlight PRODUCTTYPE in the Sort by panel, Select the Field options display and then the Sorting tab. Remove the check from Subtotal numeric sum/print fields.
Page
71
18. Select the Report options tab and click the Active Report Styling button. 19. Select Accordion instead of Tabular, click OK and Run.
Page
72
You now see all the Product Categories within Audio. If there were more Sort By columns in the report, you could keep going, expanding down each of the levels. Take a look at some of the other options available under the drop-down arrows. You see that you can export data to CSV files, to HTML files, and directly into MS Excel. If you have filtered the data, you have the choice of exporting the entire dataset or just the filtered records.
Summary: Active Reports is a tool that works extremely well when your end-users are remote and not connected to the IBM i. It gives you the ability to perform sophisticated data analysis, manipulation, and charting all while in a completely disconnected mode.
Page
73
Page
74
4. From the Automatic drill down drop-down list, select Dimensions and Measures. This gives you the maximum drill down capabilities. Note: The most common choice for Automatic drill down is probably just Dimensions, not the Dimensions and Measures that we are using in the lab. 5. Save your report as OLAP Revenue. Make sure Run with OLAP is selected in the Save Standard Report dialog window (it should already be selected).
Your report is now OLAP-enabled. To summarize, you took a basic report and selected an output option to enable OLAP. This simple selection automatically gives you an enormous amount of analysis capabilities as you will see in the next section.
Page
75
3.
Remember that the term synonym is synonymous with metadata. To define a hierarchy, you must edit the metadata for a table. This is done through the Synonym Editor. 4. Right-click the table cen_orders.mas and select Edit in Synonym Editor.
Page
76
Note: Notice that the window you just opened shows four tables: ORDERS, INVENTORY, PLANT, and STORES even though you opened only the master file or metadata for the ORDERS table. This is because you earlier defined segments to join each of the files to the ORDERS tables. This pulls the metadata for all four tables into one clustered table.
Date Decomposition
One of the dimensions that we want to create will be a date dimension. To do this we need to break the date down into its individual components of Year, Quarter, Month and Day. We can manually create each of these four fields or we can use the Date Decomposition feature of Developers Workbench to generate them for us. 1. Select the ORDERDATE field.
Page
77
In many of the reports you have created so far, you have had to break down the date field into years, quarters and even months. This is a very common requirement. To save having to do this manually for every report, DB2 Web Query provides you with a feature to automatically decompose the date in the synonym editor. 2. Right click the ORDERDATE field and select Decompose Date
Page
78
3. Accept the default (all four sub components selected for ORDERDATE) by clicking OK. Four new fields are created for users to access. Now we return to creating our dimensions. 4. Select the Modeling View. This is the easiest way to define hierarchies in DB2 Web Query.
Page
79
5. If the Dimension Builder is not visible, select Dimension Builder from the Synonym menu at the top of the Developer Studio window.
In this view you see all the tables and their relationship to the base table ORDERS. You can either view the tables as icons or you can view a column list for each table. 6. Double-lick the INVENTORY table icon to switch to the Columns view. (A second double-click reverts back to icon mode.)
Page
80
The columns in the INVENTORY table are structured such that within product categories, you have product types; within product types you have models; and within models you have product names. Now you need to describe this hierarchy to DB2 Web Query. 7. In the Dimension Builder section, expand webqryXX/CEN_ORDERS, right-click Dimensions and select Add Hierarchy -> Levels.
Page
81
Dimension Builder
There are two types of hierarchies: one based on levels and the other based on parent child relationships. You use level hierarchies the example you have been using so far. (For example, Country -> Region -> State -> City is a level hierarchy.) For more information on different types of hierarchies see the Developers Workbench help text. 8. Right-click your new Dimension1 icon and select Rename. Change the name to Product Hierarchy.
Page
82
9. Starting at the top of the hierarchy, drag PRODUCTTYPE and drop it on Product Hierarchy. Repeat for each of the other levels, PRODUCTCATEGORY and PRODUCTNAME.
Page
83
10. Repeat steps through to define the Date Dimension, the Plant Hierarchy, and the Stores Hierarchy as shown in the following figure:
11. Save your definition and close all Developers Workbench windows. You have now completed all the steps required to OLAP-enable your reports. Typically this is done once by the IT department. After this, any user with authority to create reports can choose to OLAP-enable their report.
Page
84
Notice the addition of a completely new panel at the top of the report. This is called the Selection pane. It includes tabs for every dimension described for any of the tables that are part of the ORDERS cluster. You also have the capability to work with the Measures and to create a Graph directly from the report. There are three ways to work with your OLAP data: from the report itself, from the Selection pane, and from the Control Panel. In the above report you cannot see the control panel because it is hidden or closed. It can be opened via the OLAP button or by clicking on the blue
Page
85
Tip: The first thing you learn when working with an OLAP-enabled report is that there are multiple ways to accomplish the same result. 5. Right-click the title Revenue to bring up a context menu.
Page
86
As you saw in Active Reports, selecting visualization causes graph bars to be displayed to help you quickly note trends or to easily compare two columns. Positive numbers are visualized with blue bars while negative numbers are visualized with red bars. 7. Next, select the Store Hierarchy tab. Selecting the Store Hierarchy tab displays tabs for each element in the hierarchy, proceeding from the top of the hierarchy (on the left) to the bottom. By default each tabs drop-down list contains all the unique values for that column. For example, initially, every region in the world would be available under the region tab. 8. To begin to filter and drill down on your data, select Germany from the Country drop-down list.
Page
87
Tip: You can select multiple values using the Ctrl or Shift key. 9. Look at the Region drop-down list. Notice that the only regions displayed are for Germany. Select the Nord (North) region.
10. Your filters do not take effect until you run your report. First, look at your current totals and then click Run.
Page
88
Your report shows the revenue and number of orders for the Nord region in Germany. Notice the equal sign icon immediately to the left on each field of the Store Hierarchy tab. Basically each time you fill in a value you are filtering your data by creating a WHERE clause. Instead of selecting Country equal to Germany, you could have selected all countries except Germany by clicking the equal sign icon until it shows the not equal symbol. 11. Click this icon multiple times to cycle through your choices. 12. Click the Reset button to reset the report back to its initial state. You could also have used the back arrow on your browser to go back one screen at a time.
13. Select the Product Hierarchy tab but dont select any drop-down lists. Instead of using the hierarchy tabs, you drill down within the report itself. 14. Click the Audio link.
Page
89
Notice that not only did you drill down from Product Type to the next level of Product Categories within Audio, DB2 Web Query also filled in the Selection pane tabs for you. You would have achieved the same result by selecting Product Type = Audio in the Product Hierarchy tab and then clicking the Run button. 14. Now drill down on Amplifiers/PreAmps/Tuners to see the actual products that compose that category.
Page
90
Again notice that the drop-down lists have been filled in for you. You can go back and forth this way between the body of the report and the tabs at the top. 15. Continuing your analysis, drill down to see only sales that occurred in January 2007. Select the Date Dimension tab. 16. Select 2007 for the YEAR. 17. Select 01 for the MONTH. 18. Click Run.
Page
91
19. Click Reset to return to an unfiltered report. 20. Now lets see what happens when you drill down on a measure or total field. Drill down on the Revenue for Office products.
Page
92
After drilling on the Revenue for Office products, the Office product type is expanded to its sub categories and products. Revenue and Order Count are now grouped at a much more detailed level. 21. Reset your report to remove all drill downs.
The next request from your users is to generate a report that shows revenue by product type by year. 22. Drag ORDERDATE_YEAR from the Selection pane into the area of the report where you want it, that is, across the top. The plus symbol indicates that you are in a valid area to drop the field.
Page
93
23.
Remove Order Count from the display by right-clicking Order Count and selecting Hide.
Page
94
24. You now have a very nice pivot table. To see the years down the left hand column, simply drag the column name ORDERDATE_YEAR to the left of Product Type. Again, the plus sign indicates where you can validly drop the field.
Page
95
25. Save your new pivot report. Click the Save button and select Save Report. Navigate to the Standard Reports folder, choose Manufacuring Reports and save your new report as OLAP Pivot Report.
Page
96
Page
97
Notice that you have the option to save this report without any OLAP capabilities. In essence, you have used the OLAP functionality to actually design a new report for an end-user. 26. See what happens when you save to Excel or PDF.
In addition to dragging and dropping from the Selection pane, there are other methods to display additional columns in the report. 27. Right-click ORDERDATE_YEAR and then hover over Unhide. You see a list of columns that were either part of the initial report or are in one of the hierarchies. These are the columns available to you for display.
Page
98
28. Try the same process on the Revenue field. Notice that here you see only the numeric fields that are available to you.
Workshop: DB2 Web Query for i Next you look at Graph tab.
Page
99
30. Click the Run button. If the report is running on the DB2 Web Query home page, click the Maximize Contents icon (on the far right). 31. Make the pie chart window larger by dragging down the horizontal break line between the graph and the report.
Page
100
Notice that there is one pie chart for each year which was your major sort by axis. Tip: To control the scope of the graph use the drop down boxes in the Selection pane. For example, if you only wanted a graph for 2006 revenue you could select the year 2006 from the ORDERDATE_YEAR drop down list. Tip: If your report had multiple measures that could be graphed, you can actually choose to graph them on the same chart. You can select each measure for graphing and choose a different graph type. For example if your report contained profit, you could superimpose a line graph on a bar graph with the line representing the profit and the bar representing revenue.
Page
101
In this lab youll design a compound report with a single input parameter. This style of report can be used as the basis for key performance indicator (KPI) dashboards where the user might request the KPIs for a specific country, product type, and so on. This type of report is often designed by IT and deployed to senior management and executives within a company.
Figure 11-1
Page
102
1. Open Developer Workbench. You see WebFOCUS Environments under Developer Studio Desktop. 2. Expand WebFOCUS Environments -> <your environment -> Managed Reporting -> Domains -> QRYUSRxx -> Reports -> 1: Getting Started Labs Manufacturing Reports. 3. In your Manufacturing Reports folder, navigate to the graph Product Revenue Trends.
4. Right-click Product Revenue Trends and select Copy. Keeping your cursor in the same pane (the list of your reports), right-click and select Paste. You now have a report titled Product Revenue Trends1 in the Manufacturing Reports folder.
5. Right-click your new report, Product Revenue Trends1 and select Rename. Give the report the name HTML1_KPI_LINE.
Page
103
Tip: Even though you rename the report in the window to HTML1_KPI_LINE, if you look in the integrated file system or look at the properties of the new report, you see that the object name is still product_revenue_trends1.fex. You have changed only the display title of the report, not the physical name on disk. 6. Right-click HTML1_KPI_LINE and select Edit in Developer Studio Tool.
7. DB2 Web Query knows which tool was used to create your report. Selecting the default option opens the report in either Report Assistant or Graph Assistant, whichever is appropriate. In this example, Graph Assistant opens. 8. In Graph Assistant, choose the Selection criteria tab. 9. Drag PRODUCTTYPE to the Screening conditions pane. 10. Click Select values [or undefined]. 11. In the EQ Values window, select Parameter and then click the Auto Prompt button.
1 12. In the Values pane, make sure the PRODUCTTYPE field is selected. Accept all other defaults for PRODUCTTYPE parameter properties and click OK.
Page
104
13.
Notice in the Screening conditions pane that the Select values [or undefined] link has changed.
Remove the months from the X axis labels to free more room in the small output frame for the graph itself. 14. 15. Click the Properties tab and the X axis subtab. On the X axis subtab, make sure the Show axis labels check box is not checked.
Page
105
16.
From experience, you know that the frame for your graph is about 350 pixels wide by 250 pixels high. This can be an iterative process. You might need to design your HTML page, see how much room you have for your graph, and then return to the output options for the graph to ensure that it will fit in the designated space. 17. Set the output size to 350 pixels wide (Horizontal) by 250 pixels high (Vertical).
18. Save your graph and Run it. Notice how the size of the graph has changed from the original 19. Repeat the previous steps for the existing bar chart, Revenue by Product Type Graph. If you need more detailed assistance, refer to the previous steps 4-19 and figures. a. Copy and paste the Revenue by Product Type Graph and rename it HTML1_KPI_Bar. b. Add a PRODUCTTYPE parameter, accepting the auto prompting defaults. Your report should have only one parameter. c. Set the output size to 350 pixels wide by 250 pixels high.
Page
106
d. Click the Field selection tab. e. Open the Field options COUNTRY dialog. To save space for your graph, delete Country in the X axis field label field.
f.Save your graph and Run it. Again, notice the smaller size.
Page
107
0 Tip: To create a text report or graph, select New -> Procedure. You then see a window that allows you to choose between using Report Assistant, Graph Assistant, and the SQL Wizard to create your new report. 1 4. Call your new report HTML1_KPI and click Create.
In the rest of this lab, you include a line chart, a bar graph, and the gross profit report. Figure 11-10 below shows the final layout design of your compound report. The sections that follow refer to this figure unless noted otherwise.
Page
108
Figure 11-10
6. Draw a box similar to the box in the upper left corner labeled 1 in Figure 11-10. Look at the properties box in the right pane. Your box should be 250 pixels high and 350 pixels wide. This is the size of your graph. 7. Right-click Box 1 and select Reference existing procedure. This not only shows how the graph will look in this frame, but it also references any parameters that are used by the graph.
Page
109
8. Open your HTML1_KPI_Line file in the Manufacturing Reports folder. Notice that the actual file name is displayed.
9. In the New Parameters window, the system presents a list of the parameters used in HTML1_KPI_Line. For Control Type, accept the default of Drop down list. 10. For Parameter grouping options, select Do not create a form. 0 1
Page
110
Note: If you accept the default, New form element, the system creates a panel that contains your parameter label, the drop-down box, a run button and a refresh button like the following example. You said no to this because you want to be able to move each of these elements separately on your page.
11.
Click OK.
You now modify the HTML Page by moving the positions of the parameters to match Figure 11-10. 12. Delete the label Producttype. You reference Product Type in your overall report heading. 13. Move the drop-down list and the Run button as shown below. Your Run button looks slightly different at this stage.
Page
111
14.
Select the line graph. In the Properties pane on the right, change Name to LineGraph.
Page
112
15. Click the drop-down control box in the report; click the Parameters tab in the lower right corner; select Add ALL option, and specify to display All Products.
21. To make the two graph frames the same size, you can use the Properties pane to manually size the frames to be 250 x 350.
Page
113
Note: Another way to do this is to select both frame 2 and frame 1 using the Ctrl key and then click the Make same size icon ( ). Notice that it is the last element selected that controls the final size of all the selected elements. 22. Select frame 2 and then frame 1 and click the Align top icon ( ).
23.
Page
114
25. 26.
Draw a box similar to the box at the bottom in Figure 11-10, labeled 3. Right-click the new report frame and select the Gross Profit by Product Type report.
27.
To make this page look a little cleaner, you remove the frames around each of the reports: 28. Highlight each of the three reports. 29. In the Properties pane on the right, set Frame border to no.
Page
115
30. To have all three reports in your compound HTML page automatically run when the page is opened, highlight each of the three reports and from the Properties pane on the right, set Auto Execute to True.
Page
116
32. Draw a box in the pane where you want the report title to be. 33. Enter the text Product Type Indicators. 34. Click outside your text box so that it is surrounded by a straight line frame and not slashes. 35. In the Properties pane on the right, click the ellipsis button (...) next to Styling: Font. 36. Define the styling for your title by selecting the following options: arial, 18pt, bold, underlined, and blue.
Page
117
The Run button is initially set to run the original report that was used to import the parameter. You must tell it to also run your other two reports when the user clicks Run. 40. To add the second graph, click the add icon ( ) again. 41. For Action, select External procedure. 42. For Source, click the ... button, and navigate to and select HTML1_KPI_Bar. 43. For Target Name, select BarGraph to indicate which frame the report should run in. 44. Repeat the process and select the external procedure Gross Profit by Product Type and point it to the frame GrossPftReport. Your Hyperlink Properties window should look like this:
45. Click OK. 46. Save your report and then run it by clicking the Run button (circled in Figure 11-20). You must also click the Run button on your report to fill in the two graphs.
Page
118
Tip: You can return to the DB2 Web Query home page and run this dashboard. The easiest method is for a developer to stay within Developer Workbench and test from there. Do not forget that the page should be designed small enough to be viewed within the context of the DB2 Web Query home page. Your dashboard or KPI should look like the example in Figure 11-21.
Page
119
Page
120
3. Give the new field the name Quarter and select a format of Q. Either select or key the date field name ORDERDATE. The name must be in upper case letters. This extracts the quarter from ORDERDATE. Click OK.
Page
121
Page
122
4. Repeat the process to create a field named Year from ORDERDATE with a format of YY (UPPER CASE required).
Selection criteria
The next steps filter this report by selecting only year 2007. 5. 6. 7. 8. 9. Select the Selection criteria tab. Drag and drop Year from the Available fields list onto the Screening conditions panel on the right. From the first drop-down box, select WHERE. Select EQUAL to. Click the <Select values> link.
Note: Although you are selecting the default WHERE, DB2 Web Query allows you to choose WHERE or WHERETOTAL: WHERE does the select at read time and only passes those records to the query that meet the specified condition.
Page
123
WHERETOTAL does the comparison after the records have been retrieved, sorted and aggregated. The selection is done on the aggregate value of the column. If you wanted to select only the product types whose total revenue was greater than $100 million, you would use WHERETOTAL. If you used WHERE, you would be applying the selection on every individual order read and none would meet this criteria. 34. Select the Values radio button. DB2 Web Query looks for all distinct values in this field and presents them in a list. 35. Select 2007 and click OK.
Note: You can compare a field to a: Constant - a specific number Parameter -a variable whose value(s) is either entered by a user or passed from another report Field - another field in your table(s) Values - select from a list of actual values in the selected field.
Page
124
37. Run your report. When you do a save as for the report, default values selected are Prompt for parameters and Show on users list. I left the default values. You might want to make a note of what is the best choice for these here.
Page
125
38. Save the report as Cross Tab 2007 and close it.
Page
126
On-demand paging
2. Click the Report options tab and select On-demand paging in the Output format specific section.
Page
127
This report, only one page long, isnt the best to demonstrate the on-demand paging feature. Assume that your report was 201 pages long instead. When on-demand paging is enabled, DB2 Web Query saves your report on the System i and delivers one page of report output at a time to your browser, decreasing the amount of time you wait for your report to be transmitted. The bulk of your report remains on the System i until you request it or close the report. On-demand paging allows you to jump directly to a specific page or to search for a string of information in the report.
PDF output
So far all our output has been sent to the display. DB2 Web Query provides many additional options for output. 4. Select the Report options tab and for Generate report as, select PDF - Portable Document Format from the drop-down list. Note: Users do not require any additional software to create a PDF report. Adobe Acrobat Professional edition is not required.
5.
Page
128
6.
Close the PDF report and Report Assistant for this report.
Page
129
As you can see it looks very much like the reports you created in Report Assistant.
Page
130
3. Open the Field options GROSSPROFT dialog at the bottom of the screen and click Conditional styling.
Page
131
Note: You cannot add new columns to the report, even if the column is from a table used in the report. DB2 Web Query, in effect, sees the Query/400 result set as any other table. If you edit the report from DB2 Web Query, those changes are not reflected in the QRYDFN object 2. Click the Add icon to use the Wizard to create a conditional field to display Gross Profit in a green font if the gross profit is greater than 22,000,000.
3. Click OK to create the condition. 4. Click the Add condition icon to attach the condition; then change the Font to traffic light Gross Profit in green.
Page
132
5. 6.
Page
133
Page
134
When you start Developers Workbench, the first thing you must do is to add the definition of your System i environment. 3. 4. 5. Fill in the name and description of your System i. Verify that port 11331 is selected and that the HTML Alias is /webquery_html Click OK.
The first time you open the System i environment or connection that you just added, you must sign on. 6. Sign on with your admin or developer authorized profile.
Page
135
Application folders contain your metadata -- your master (.mas) and access (.acx) files. Remember that the master file contains the field names and formats for your table. The access file contains information about the actual name and location of the physical table and the primary keys for the table. Nearly all your work is done with the master file. The source code or procedures that store your report definitions are located under the Managed Reporting / Domains portion of the tree. Thats where you go to create a new report or modify an existing one.
Workshop: DB2 Web Query for i 8. Click Window on the tool bar and select Options
Page
136
Developers Workbench allows you to show your Windows desktop explorer tree in the same window as your DB2 Web Query Explorer tree. 9. Select the Explorer tab and click the checkbox for Show Desktop on Explorer tree.
Page
137
Notice, there now is a Windows Desktop icon in the DB2 Web Query explorer tree.
10.
Page
138
Showing your Windows desktop tree within Developers Workbench has a few definite benefits. The first and obvious benefit is being able to stay within one working environment as a programmer. A very nice additional benefit is the ease with which you can copy items from your PC hard drive to the DB2 Web Query folder structure. You may want to move style sheets, company logos, pictures and other PC files between the different file structures. In the example below, a text file containing SQL statements is being copied and pasted into the Other Files folder in the Common Domain. From here the SQL can be accessed and run via the SQL Wizard in Developers Workbench or the SQL metadata creation option from the DB2 Web Query home page.