db2 web query for system i

368
Draft Document for Review October 10, 2007 9:57 am SG24-7214-00 ibm.com/redbooks Front cover Getting started with DB2 Web Query for System i Jackie Jansen Hernando Bedoya Gene Cobb Renee Mason Learn DB2 Web Query by using the easy to follow tutorials Follow the installation and best practices guides Take your Query/400 reports to the next level

Upload: tess98

Post on 13-Jan-2015

2.204 views

Category:

Documents


5 download

DESCRIPTION

 

TRANSCRIPT

Page 1: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am SG24-7214-00

ibm.com/redbooks

Front cover

Getting started with DB2 Web Query forSystem i

Jackie JansenHernando Bedoya

Gene CobbRenee Mason

Learn DB2 Web Query by using the easy to follow tutorials

Follow the installation and best practices guides

Take your Query/400 reports to the next level

Page 2: DB2 Web Query for System i
Page 3: DB2 Web Query for System i

International Technical Support Organization

DB2 Web Query for System i

July 2007

Draft Document for Review October 10, 2007 9:57 am 7214edno.fm

SG24-7214-00

Page 4: DB2 Web Query for System i

© Copyright International Business Machines Corporation 2007. All rights reserved.Note to U.S. Government Users Restricted Rights -- Use, duplication or disclosure restricted by GSA ADP ScheduleContract with IBM Corp.

7214edno.fm Draft Document for Review October 10, 2007 9:57 am

First Edition (October 2007)

This edition applies to Version 5, Release 4 of i5/OS (product number 5722-SS1).

This document created or updated on October 10, 2007.

Note: Before using this information and the product it supports, read the information in “Notices” on page xi.

Page 5: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214TOC.fm

Contents

Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiTrademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiiiThe team that wrote this IBM Redbook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiiiBecome a published author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvComments welcome. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xv

Part 1. Background, Installation, and Setup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Chapter 1. Introduction - Product Architecture and Overview . . . . . . . . . . . . . . . . . . . . 31.1 Query/400: A history lesson . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.2 Introduction to DB2 Web Query for System i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.3 Synonyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.4 DB2 Web Query features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

1.4.1 Base features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.4.2 Optional features available from IBM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.4.3 Optional features available from Information Builders . . . . . . . . . . . . . . . . . . . . . . 8

1.5 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101.5.1 Web browser clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.5.2 Web server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.5.3 Application Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.5.4 Reporting server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.5.5 Data Adapters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

1.6 DB2 Web Query Developer Workbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.7 DB2 Web Query Product Positioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Chapter 2. Installation and Server Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.1 Installation and Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2.1.1 Installation steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182.1.2 Post Installation steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.1.3 License keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

2.2 PC and System i Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.2.1 PC Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.2.2 System i Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.2.3 Developer Workbench requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

2.3 Reporting Server Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222.4 DB2 Web Query server jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Chapter 3. DB2 Web Query Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.1 Registering named users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263.2 Logging in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263.3 Administrator tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

3.3.1 DB2 Web Query domains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293.3.2 Creating sub-folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313.3.3 Assigning authority to users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

3.4 Developer tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333.4.1 Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343.4.2 Data adapters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

© Copyright IBM Corp. 2007. All rights reserved. iii

Page 6: DB2 Web Query for System i

7214TOC.fm Draft Document for Review October 10, 2007 9:57 am

3.4.3 Miscellaneous considerations about creating metadata . . . . . . . . . . . . . . . . . . . . 393.4.4 Metadata creation supports referential integrity . . . . . . . . . . . . . . . . . . . . . . . . . . 403.4.5 Setting up a cross system join . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

3.5 The first steps for a report basic user . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

Part 2. Tutorials for DB2 Web Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

Chapter 4. Tutorials: Getting Started. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574.1 Initial Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

Chapter 5. Report Assistant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635.1 Report Assistant Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645.2 Creating a summary report (RA1_Revenue). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

5.2.1 Defining a report layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655.2.2 Sum and detail reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675.2.3 Date formatting (RA2_XTab). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705.2.4 Selection criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715.2.5 Cross Tab report (RA2_XTab) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735.2.6 Creating a Sample Detail Report (RA3_GP). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735.2.7 Conditional styling (Traffic lighting) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 775.2.8 Using variables in report headings/footings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 785.2.9 Generating subtotals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805.2.10 Sorting by an aggregate field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 815.2.11 Adding Ranking Columns (RA4_Advanced) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

5.3 Output options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 845.3.1 On-demand paging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 845.3.2 PDF output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 855.3.3 MS Excel output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 865.3.4 DB2 database file output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 875.3.5 Parameterized reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 895.3.6 Drill-down reports - parent report (RA5_Child) . . . . . . . . . . . . . . . . . . . . . . . . . . . 915.3.7 Report properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

5.4 Information Only: Joining tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 945.5 Report Assistant Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

Chapter 6. Graph Assistant Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 996.1 Bar chart Tutorial. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1006.2 Creating a simple bar chart with drill down capabilities (GA1_Bar). . . . . . . . . . . . . . . 101

6.2.1 Adding multiple bars to one chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1036.2.2 Adding a drill down to your chart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

6.3 Creating a dual axis bar and line chart (GA2_Parm) . . . . . . . . . . . . . . . . . . . . . . . . . 1066.3.1 Adding a second Y axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

6.4 Creating a revenue trend over time chart (GA3_Line) . . . . . . . . . . . . . . . . . . . . . . . . 1136.5 Creating a line graph. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

6.5.1 Adding a date range filter to your line graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1176.5.2 Adding a user specified date range parameter . . . . . . . . . . . . . . . . . . . . . . . . . . 120

iv DB2 Web Query for System i

Page 7: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214TOC.fm

6.6 Working with pie charts (GA4_Pie) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1226.7 Creating a product type pie chart for each year . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1226.8 Conditional styling or traffic lighting a graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

Chapter 7. Power Painter Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1317.1 Power Painter Tutorial (PP1_PDF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1327.2 Getting Started with Power Painter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1327.3 Building a graph with Power Painter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1347.4 Building a report with Power Painter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

Part 3. Tutorials for DB2 Web Query Optional Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

Chapter 8. Active Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1498.1 Active Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1498.2 Creating an Active Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1518.3 Using an Active Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

Chapter 9. Configuring Developer Workbench. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1639.1 Configuring Developer Workbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1649.2 Setting Developer Workbench default options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

Chapter 10. OLAP (Online Analytical Processing) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16910.1 Getting Started with OLAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170

10.1.1 OLAP Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17010.2 Defining OLAP metadata using the Developer Workbench . . . . . . . . . . . . . . . . . . . 17110.3 Enabling an OLAP report (OL1_Revenue) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17610.4 Working with an OLAP enabled report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178

10.4.1 Slicing / Dicing and Drilling Down for more details . . . . . . . . . . . . . . . . . . . . . . 17910.4.2 Using the OLAP Control Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18810.4.3 Grouping Data into Percentiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194

Chapter 11. HTML Layout Painter Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19711.1 Compound Parameterized report (HTML1_KPI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198

11.1.1 Adding parameters to existing reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19811.1.2 HTML Layout painter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202

11.2 Highly parameterized report (HTML2_Parm) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21011.2.1 Creating the report in HTML Layout Painter . . . . . . . . . . . . . . . . . . . . . . . . . . . 213

Chapter 12. Additional Developer Workbench features . . . . . . . . . . . . . . . . . . . . . . . 22512.1 Synonym editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226

12.1.1 Date Decomposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22812.1.2 Additional Date Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23012.1.3 Creating filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23112.1.4 Joining Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23212.1.5 Business Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23712.1.6 Impact Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23912.1.7 Data Profiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241

Contents v

Page 8: DB2 Web Query for System i

7214TOC.fm Draft Document for Review October 10, 2007 9:57 am

12.2 SQL Wizard. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24312.3 IBM Developer Workbench Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248

Part 4. Miscellaneous or Additional Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251

Chapter 13. Using DB2 Web Query to run existing Query/400 reports . . . . . . . . . . . 25313.1 Query/400 - A reliable reporting tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25413.2 DB2 Web Query vs. Query/400 - What functions are similar . . . . . . . . . . . . . . . . . . 25413.3 Web Query verses Query/400 - What functions are different . . . . . . . . . . . . . . . . . . 25513.4 How to create metadata from Query/400 objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 25613.5 Use Web Query to edit a QRYDFN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260

Chapter 14. Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26114.1 Performance basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26214.2 DB2 CLI adapter performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262

14.2.1 Report request process flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26214.2.2 Adapter processing and optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26414.2.3 Remote database access considerations (including cross system joining) . . . 275

14.3 Query/400 adapter performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27714.4 DB2 for i5/OS optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

14.4.1 Database design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27814.4.2 Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279

14.5 Performance case study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28014.5.1 Identify long running report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28014.5.2 Perform analysis, looking for optimization disablers . . . . . . . . . . . . . . . . . . . . . 28114.5.3 Determine report tuning options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28214.5.4 Create an SQL view and synonym . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28214.5.5 Create a new report based on the SQL view . . . . . . . . . . . . . . . . . . . . . . . . . . 28414.5.6 Perform additional database analysis and tuning . . . . . . . . . . . . . . . . . . . . . . . 286

14.6 Performance benchmark. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28714.6.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28714.6.2 Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28814.6.3 Database and system configuration:. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28814.6.4 Metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28814.6.5 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291

Chapter 15. Frequently Asked Questions (FAQs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29315.1 DB2 WebQuery FAQ. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294

15.1.1 What was announced? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29415.1.2 What are some of the capabilities of this new product? . . . . . . . . . . . . . . . . . . 29415.1.3 We are happy with our Query/400 reports. Is there really any reason to move to this

new product? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29415.1.4 How do I migrate Query/400 reports into DB2 Web Query?. . . . . . . . . . . . . . . 29515.1.5 Why a web based query and report writing function? Wouldn’t a Windows based

solution be more robust? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29515.1.6 What additional features are available with DB2 Web Query? . . . . . . . . . . . . . 29515.1.7 What languages are supported?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29615.1.8 Will I need to download data to a PC Server or install a Windows server to sit

between the client and the System i server? . . . . . . . . . . . . . . . . . . . . . . . . . . . 29615.1.9 I have non DB2 data stored in other databases. Will I be able to use DB2 Web Query

to query those databases? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29615.1.10 Does the Software Maintenance Agreement (SWMA) for the Query/400 product

5722QU1 cover the new DB2 Web Query product 5733QU2 when licensing is obtained from an existing 5722QU1 licensed installation? . . . . . . . . . . . . . . . . . 296

vi DB2 Web Query for System i

Page 9: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214TOC.fm

15.1.11 What is the recommended save and restore process for DB2 Web Query? . 29715.1.12 Can I move/deploy synonyms and reports individually? . . . . . . . . . . . . . . . . . 29715.1.13 How do I manage my synonyms?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29815.1.14 Within my reports, how can I simulate a library list-like behavior when accessing

the base tables and views? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29915.1.15 I noticed that DB2 Web Query is using port 11331 for HTTP requests. What if I am

already using this port for something else? Is there any way to change it? . . . . 30015.1.16 How can I limit the number of rows being retrieved during the report development

phase? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30115.1.17 When I access the DB2 Web Query web console, I only see a limited number of

options. What happened to the other options? . . . . . . . . . . . . . . . . . . . . . . . . . . 30215.1.18 What happens to my existing queries when I upgrade to 5733QU2?. . . . . . . 30315.1.19 Query/400 supported exception joins. How do I specify that type of join with DB2

Web Query? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30315.1.20 I have my own stylesheets that I would like to use for my reports. How do I make

them available from Report Assistant? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30315.1.21 Can DB2 Web Query handle stored procedures with input parameters? . . . . 30415.1.22 How do I open my Excel spreadsheet reports in Microsoft Excel instead of the web

browser? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30515.1.23 Is the pricing for each of the IBM add-ons also based on named user pricing

scheme? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30615.1.24 Given this is browser based access, how is the security established for the users?

30615.1.25 Is the Report Caster feature part of the base licensing?. . . . . . . . . . . . . . . . . 30715.1.26 What is the benefit to using the JDE adapter add-on, as compared to just using

standard DB2 for Web Query access? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30715.1.27 Does the named user access apply to both a developer of queries and a user that

runs a query? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30715.1.28 Since a named user must run the report, can a report be scheduled to be run by

that user? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30715.1.29 Can a named user connect with multiple sessions concurrently? For example, I

would like to work on two separate queries at the same time. . . . . . . . . . . . . . . 30715.1.30 Will the imported query definition start using SQL, such that the SQL Query Engine

versus the Classic Query Engine would be used? . . . . . . . . . . . . . . . . . . . . . . . 30715.1.31 The OLAP feature is enabled by defining dimensions for the database. How does

DB2 Web Query get those dimensions?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30815.1.32 Can my DB2 Web Query reports run with adopted authority? . . . . . . . . . . . . 30815.1.33 . My user profiles are already members of a group profile. Since this user profile

parameter (GRPPRF) is already specified, how can domain authority be established? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308

15.1.34 Is the server based processing performed by the Websphere Application Server, or something requiring less overhead?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308

15.1.35 Can a more granular level of security be established, for example, to limit a report for a specific user? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308

15.1.36 Are column headings automatically obtained for the accessed files?. . . . . . . 30815.1.37 I have created a report with output to an Excel spreadsheet. Does a drill-down

(clicking an active link) access another spreadsheet? . . . . . . . . . . . . . . . . . . . . 30915.1.38 Is there an automated way to import Query/400 objects?. . . . . . . . . . . . . . . . 30915.1.39 When cascading through data in an OLAP report, is the data limited based on prior

selections? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30915.1.40 Is the knowledge of file relationships (Referential Integrity) a feature of the

database or DB2 Web Query? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30915.1.41 Does the 5722QU1 product need to be ordered when 5733QU2 is ordered? 309

Contents vii

Page 10: DB2 Web Query for System i

7214TOC.fm Draft Document for Review October 10, 2007 9:57 am

15.1.42 Is there a Try & Buy for the IBM add-on components (Active Reports, OLAP Module, and Developer Workbench)? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309

15.1.43 How are the DB2 Web Query domains established? . . . . . . . . . . . . . . . . . . . 31015.1.44 Will a query that was previously imported still function as an imported report, after

the Query Definition has been changed? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31015.1.45 Since the 5733QU2 product is announced as a Query/400 replacement, will either

the interactive query definition-time and run-time support be removed from the system? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

15.1.46 When building a dashboard, can graphics be included, for example company logo?310

15.1.47 Will the dashboard allow a periodic report; an effective automatic update? . . 31015.1.48 One of the report output options is "Excel with formulas." What does that really

mean?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31015.1.49 Does a copy of the Developer Workbench come with the base product?. . . . 31115.1.50 Is there an option in output to Excel, to establish 'cell protection' for formulas, to

ensure that for reports sent to an analyst, that the formula can not be accidentally changed? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311

15.1.51 How large is an Active Report file? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31115.1.52 Can an Active Report be saved with the active visualizations and any other

changes made by the user? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31115.1.53 Some Query/400 definitions are scripted in a CL Program, such that one query

produces output which will be used by the next query for input. Will that be possible with Web Query? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311

15.1.54 How can the SQL that is produced for the report be viewed?. . . . . . . . . . . . . 31115.1.55 In parameterized reports, can more than one item be selected from the list? 31215.1.56 Is there a way to specify double-spaced printing? . . . . . . . . . . . . . . . . . . . . . 31215.1.57 Is signon to the product available via LDAP or Kerberos? . . . . . . . . . . . . . . . 31215.1.58 Can a drill-down report have further drill-downs defined?. . . . . . . . . . . . . . . . 31215.1.59 How does one create dashboards? Using the Power Pointer tool? . . . . . . . . 31215.1.60 Is there any integration with the Rational tools with this product? . . . . . . . . . 31215.1.61 Is there integration to portlets with Portal 6.0? . . . . . . . . . . . . . . . . . . . . . . . . 31215.1.62 Report Caster seems like a good fit for our company? How would I find more

information on this product? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31215.1.63 Can a model 8## system have the product QU2 installed? . . . . . . . . . . . . . . 31315.1.64 Is there a *NOMAX licensing available? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31315.1.65 How are named users managed, established, or removed?. . . . . . . . . . . . . . 31315.1.66 Is there auditing available for running a Web Query report?. . . . . . . . . . . . . . 31315.1.67 Can I run a DB2 Web Query report from within a CL program? . . . . . . . . . . . 31315.1.68 In an OLAP report, can ordering be done like in Active Reports?. . . . . . . . . . 31315.1.69 Is there a way to automate the generation/update of the metadata? An API

perhaps?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31415.1.70 Can selection be defined on an expression? . . . . . . . . . . . . . . . . . . . . . . . . . 31415.1.71 How is a parameterized report designed, specifically to establish the inputs? 31415.1.72 Where can I find more training on the products? . . . . . . . . . . . . . . . . . . . . . . 314

viii DB2 Web Query for System i

Page 11: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214TOC.fm

Part 5. Appendixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315

Appendix A. Metadata in the IFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317

Appendix B. Date and Time functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321Date and Time System Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322Date Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322Date Format Display Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322Controlling the Date Separator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324Using Date Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324Date Fields in Arithmetic Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325Converting Date Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325Date Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325

DATEADD Add or subtract a date unit to/from a date. . . . . . . . . . . . . . . . . . . . . . . . . . 325DATEDIFF Calculate the difference between two dates. . . . . . . . . . . . . . . . . . . . . . . . 326DATEMOV Move the date to a significant point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326

Appendix C. Define and Compute fields processing differences. . . . . . . . . . . . . . . . 329Web Query calculation sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330

Appendix D. Setting up DB2 Web Query to run in an IASP environment . . . . . . . . . 331On the first System. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332On the second system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335

Appendix E. Additional material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339Locating the Web material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339Using the Web material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339

System requirements for downloading the Web material . . . . . . . . . . . . . . . . . . . . . . . 339How to use the Web material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340

Related publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341IBM Redbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341Online resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341How to get IBM Redbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341Help from IBM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343

Contents ix

Page 12: DB2 Web Query for System i

7214TOC.fm Draft Document for Review October 10, 2007 9:57 am

x DB2 Web Query for System i

Page 13: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214spec.fm

Notices

This information was developed for products and services offered in the U.S.A.

IBM may not offer the products, services, or features discussed in this document in other countries. Consult your local IBM representative for information on the products and services currently available in your area. Any reference to an IBM product, program, or service is not intended to state or imply that only that IBM product, program, or service may be used. Any functionally equivalent product, program, or service that does not infringe any IBM intellectual property right may be used instead. However, it is the user's responsibility to evaluate and verify the operation of any non-IBM product, program, or service.

IBM may have patents or pending patent applications covering subject matter described in this document. The furnishing of this document does not give you any license to these patents. You can send license inquiries, in writing, to: IBM Director of Licensing, IBM Corporation, North Castle Drive, Armonk, NY 10504-1785 U.S.A.

The following paragraph does not apply to the United Kingdom or any other country where such provisions are inconsistent with local law: INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of express or implied warranties in certain transactions, therefore, this statement may not apply to you.

This information could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these changes will be incorporated in new editions of the publication. IBM may make improvements and/or changes in the product(s) and/or the program(s) described in this publication at any time without notice.

Any references in this information to non-IBM Web sites are provided for convenience only and do not in any manner serve as an endorsement of those Web sites. The materials at those Web sites are not part of the materials for this IBM product and use of those Web sites is at your own risk.

IBM may use or distribute any of the information you supply in any way it believes appropriate without incurring any obligation to you.

Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not tested those products and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products.

This information contains examples of data and reports used in daily business operations. To illustrate them as completely as possible, the examples include the names of individuals, companies, brands, and products. All of these names are fictitious and any similarity to the names and addresses used by an actual business enterprise is entirely coincidental.

COPYRIGHT LICENSE:

This information contains sample application programs in source language, which illustrate programming techniques on various operating platforms. You may copy, modify, and distribute these sample programs in any form without payment to IBM, for the purposes of developing, using, marketing or distributing application programs conforming to the application programming interface for the operating platform for which the sample programs are written. These examples have not been thoroughly tested under all conditions. IBM, therefore, cannot guarantee or imply reliability, serviceability, or function of these programs.

© Copyright IBM Corp. 2007. All rights reserved. xi

Page 14: DB2 Web Query for System i

7214spec.fm Draft Document for Review October 10, 2007 9:57 am

Trademarks

The following terms are trademarks of the International Business Machines Corporation in the United States, other countries, or both:

Redbooks (logo) ™iSeries™i5/OS®AS/400®

DB2®Informix®IBM®Lotus®

Redbooks™System i™WebSphere®

The following terms are trademarks of other companies:

Java, JavaScript, JavaServer, JavaServer Pages, JRE, JSP, JVM, J2EE, Sun, Sun Java, and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.

Excel, Expression, Internet Explorer, Microsoft, Windows, and the Windows logo are trademarks of Microsoft Corporation in the United States, other countries, or both.

Other company, product, or service names may be trademarks or service marks of others.

xii DB2 Web Query for System i

Page 15: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214pref.fm

Preface

DB2® Web Query for System i™ is a Web-based query and report writing product that offers enhanced capabilities over the IBM® Query for iSeries™ (also commonly known as Query/400) product. IBM DB2 Web Query for System i will include the Query for iSeries technology to assist customers in their transition to DB2 Web Query, while offering a more modernized, Java™ based solution for a more robust, extensible, and productive reporting solution. DB2 Web Query will provide reporting and graphing assistants and a WYSIWYG report "painter." Customers will be able to modernize existing Query for iSeries reports while providing a foundation for building more complex business intelligence applications such as OLAP, data mining, dash boarding, or data warehouse implementations.

DB2 Web Query will provide capabilities to query or build reports against data stored in DB2 for i5/OS® databases through the latest browser based user interface technologies. Build new reports with ease through Power Painter or Report and Graph Assistant components. Simplify the management of reports by leveraging parameterized reporting. Deliver data to end users in many different formats, including spreadsheets, PDF, HTML or through the Java based thin client interface browser support.

DB2 Web Query will offer features to import Query/400 definitions and enhance their look and functionality with Power Painter or Graph Assistant. Add OLAP-like slicing and dicing to the reports, or view reports in disconnected mode for the end user on the go. Interface to all data in i5/OS through either DB2 or Open Query File native adapters that automatically identify the files to be accessed and import the metadata into DB2 Web Query.

This IBM Redbook gives a broad understanding of this new product and it is explained with a group of self explanatory tutorials that will help you get up to speed quickly. Overall this redbook is designed for IT users. Part 2, “Tutorials for DB2 Web Query” on page 55 and Part 3, “Tutorials for DB2 Web Query Optional Features” on page 147 can be extracted and used as stand alone tutorials for any user developing their own queries. Much of Chapter 8, “Active Reports” on page 149 is appropriate for end users who will be working disconnected from the System i. In addition, much of Chapter 10, “OLAP (Online Analytical Processing)” on page 169 can be used by end users who will simply be running OLAP enabled reports.

The team that wrote this IBM Redbook

This redbook was produced by a team of specialists from around the world working at the International Technical Support Organization (ITSO), Rochester Center.

Hernando Bedoya is an IT Specialist at the IBM ITSO, in Rochester, Minnesota. He writes extensively and teaches IBM classes worldwide in all areas of DB2 for i5/OS. Before joining the ITSO more than seven years ago, he worked for IBM Colombia as an IBM AS/400® IT Specialist doing presales support for the Andean countries. He has 24 years of experience in the computing field and has taught database classes in Colombian universities. He holds a master degree in computer science from EAFIT, Colombia. His areas of expertise are database technology, application development, and data warehousing.

© Copyright IBM Corp. 2007. All rights reserved. xiii

Page 16: DB2 Web Query for System i

7214pref.fm Draft Document for Review October 10, 2007 9:57 am

Jackie Jansen is a Senior Certified Consulting IT Specialist with 30 years at IBM. Jackie currently works in the IBM Americas Advanced Technical Support Solutions Centre. Jackie is the author of a variety of published columns including the recent 'Business Intelligence with Jackie' and 'Jackie's Forum'. Jackie is a frequent speaker at iSeries Technical Conferences and User Group meetings. Contact her at [email protected].

Gene Cobb is a DB2 for i5/OS Technology Specialist in System i Solutions Enablement. He has worked on IBM Midrange systems since 1988, with 10 years in the IBM Client Technology Center(CTC), in IBM Rochester. While in the CTC, he assisted customers with application design and development using RPG, DB2 for i5/OS, CallPath/400, and Lotus® Domino. His current responsibilities include providing consulting services to System i developers, with special emphasis in application and database modernization.

Renee Mason has been a Support Engineer for Database on System i for 3 years. She started working with U.S. clients only, but last year has branched out to supporting clients world-wide. She holds a bachelor's degree in Management Information Systems and a minor in Computer Science from Winona State University, MN. Her area of expertise within DB2 is Journal Management. She also trains other System i Support Engineers from around the world as they visit Rochester to build their DB2 technical skills as part of the International Internship Program.

Thanks to the following people for their contributions to this project:

Jenifer ServaisJoanna Pohl-MiszczykThomas GrayJames HansenInternational Technical Support Organization, Rochester Center

Eric WillDoug MackBrian MurasRobert AndrewsMichael CainJarek MiszczykRick SaltnessRobert AndrewsScott MooreTyler EvenDan ToftSandy Ryan

xiv DB2 Web Query for System i

Page 17: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214pref.fm

Fernando EchevesteIBM Rochester

Wilfried BlankertzIBM Germany

Julie MawIBM UK

Simona PacchiariniFrancesca ZocchedduIBM Italy

Robert FricanoLarry EissTerry SchwarzPat PowersGary GoldbergInformation Builders Inc.

Become a published author

Join us for a two- to six-week residency program! Help write an IBM Redbook dealing with specific products or solutions, while getting hands-on experience with leading-edge technologies. You will have the opportunity to team with IBM technical professionals, Business Partners, and Clients.

Your efforts will help increase product acceptance and customer satisfaction. As a bonus, you will develop a network of contacts in IBM development labs, and increase your productivity and marketability.

Find out more about the residency program, browse the residency index, and apply online at:

ibm.com/redbooks/residencies.html

Comments welcome

Your comments are important to us!

We want our Redbooks™ to be as helpful as possible. Send us your comments about this book or other Redbooks in one of the following ways:

� Use the online Contact us review Redbooks form found at:

ibm.com/redbooks

� Send your comments in an e-mail to:

[email protected]

� Mail your comments to:

IBM Corporation, International Technical Support OrganizationDept. HYTD Mail Station P0992455 South RoadPoughkeepsie, NY 12601-5400

Preface xv

Page 18: DB2 Web Query for System i

7214pref.fm Draft Document for Review October 10, 2007 9:57 am

xvi DB2 Web Query for System i

Page 19: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214p01.fm

Part 1 Background, Installation, and Setup

The redbook is divided into multiple sections. This initial section will introduce DB2 Web Query to the readers and provide guidance on installing DB2 Web Query. Parts 2 and 3 are hands on tutorials where the user can follow along and start to become familiar with the product. Part 4 covers Query/400 migration, Performance considerations and frequently asked questions.

In this initial seciton we will introduce and provide some background on IBM DB2 Web Query for System i. We will also provide the installation and setup instructions for the product.

This part includes the following chapters:

� Chapter 1, “Introduction - Product Architecture and Overview” on page 3

� Chapter 2, “Installation and Server Operations” on page 17

� Chapter 3, “DB2 Web Query Fundamentals” on page 25

Part 1

© Copyright IBM Corp. 2007. All rights reserved. 1

Page 20: DB2 Web Query for System i

7214p01.fm Draft Document for Review October 10, 2007 9:57 am

2 DB2 Web Query for System i

Page 21: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch01.fm

Chapter 1. Introduction - Product Architecture and Overview

Today’s information overload requires companies to analyze data quickly and easily in formats that suit the needs of different types of users. Executives want quick access to track to key performance indicators; Financial analysts want to analyze corporate performance to evaluate profitability or meet compliance guidelines; Business managers need up to the minute sales and inventory information to ensure customer demand and sales quotas can be met. The information needs to be delivered quickly and easily, with robust security in place, and distributed to a multitude of different client technologies, including browsers and spreadsheets, or integrated into line of business applications.

This chapter introduces IBM DB2 Web Query for System i (DB2 Web Query), a comprehensive Java(TM) based business intelligence tool that provides graphical, web based query and report writing functions.

Included in this chapter are the following topics:

� A history of the Query/400 product including its current limitations

� An overview of DB2 Web Query including how it addresses Query/400’s limitations

� DB2 Web Query architecture

� DB2 Web Query product positioning

1

© Copyright IBM Corp. 2007. All rights reserved. 3

Page 22: DB2 Web Query for System i

7214ch01.fm Draft Document for Review October 10, 2007 9:57 am

1.1 Query/400: A history lesson

When the AS/400 was first released in June of 1988, one of the optional licensed programs was 5722-QU1, the Query/400 product. This product was used by midrange programmers, administrators, and end users to retrieve, format, and analyze information from AS/400 database files to produce reports. The tool was widely popular within the AS/400 community due to its compact design, intuitive interface, and robust functionality. Users created custom reports by specifying the files, record selection criteria, fields to sort and group by, and column totals from a limited number of simple panels. The reports could be written directly to the screen, to a spooled file for printing, or to another database file for further processing. The definition could be then saved to a permanent AS/400 system object (object type *QRYDFN) so that the report could be shared with other users and run again later. With a proper knowledge of the database, reports could be generated in minutes.

The licensed program has since been renamed to IBM Query for System i, and is still available, supported, and widely used on the System i today. But however useful it has been to users in the past, it does have several major shortcomings:

� Lack of a graphical interface

Recently, significant emphasis has been given to “modernize” System i applications. This generally means providing a more modern (graphical) interface for tools, applications, and any generated output. Many reporting tools available today have a web browser or rich client based interface. They also provide the ability to generate the reports in a variety of graphical formats such as PDF, HTML, XML, and Excel® spreadsheets. Query/400 does not support any of these interfaces

� Lack of support for non-DB2 for i5/OS databases

Query/400 can only access information stored in DB2 for i5/OS. If you need your Query/400 reports to include information from other databases (such as Oracle or SQL Server), you must import these tables into DB2 for i5/OS. This is simply not practical if you have large amounts of data that is dynamic in nature.

� Limited ability to ad hoc/look at the data in a different way/further dissect the data and drill down

Once run, the Query/400 output is static in nature and cannot be easily manipulated for further dissection and analysis. If you want to look at the data in a different way (such as to resort the list by a different column), you must create and run additional reports. Further, the ability to select a particular element in the report and drill down for more information and analysis simply does not exist. Again you would have to run another report to obtain this information. All this results in analysis that is disruptive, lacks flow and fluidity, and is time consuming in nature. Not to mention the strain it places on an IT department that is continually writing various versions of reports to satisfy end user requirements.

� Not a pure SQL interface

Query/400 is a proprietary interface and does not use the industry standard Structured Query Language (SQL) when accessing database objects. This places restrictions on the functionality of the reports that can be created. New SQL functions and features that are introduced with each release cannot be directly/easily incorporated into Query/400 reports.

� Not strategic

IBM has clearly stated that SQL is the strategic database interface for both creating and accessing database objects. Since Query/400 is not an SQL interface, this means that IBM will not be investing in this technology in the future, and thus the product will not address any of the previously listed deficiencies.

4 DB2 Web Query for System i

Page 23: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch01.fm

� Does not use the new SQL Query Engine (SQE)

SQE was introduced in V5R2 of i5/OS and offers algorithms and features that give it distinct advantages over its predecessor, the Classic Query Engine (CQE). SQE is the strategic database engine, thus will receive all future enhancements. Although CQE will still be supported and maintained, IBM will not incorporate any new features into this engine. Only pure SQL requests are processed by the new engine. Because Query/400 is not an SQL interface, its query requests must be handled by the older CQE technology.

For more information on SQE including its advantages over CQE, see the Redbook Preparing for and Tuning the SQL Query Engine on DB2 for i5/OS.

Over the years, thousands (perhaps millions) of custom reports have been created using IBM Query for System i (aka Query/400). As a result, businesses have a significant amount of investment contained throughout their systems in the query objects. Because so much has been invested in these objects, System i businesses need a way to leverage/repurpose them using a more modern reporting tool.

1.2 Introduction to DB2 Web Query for System i

In April of 2007, IBM and Information Builders Incorporated announced a product alliance. The new product, known as IBM DB2 Web Query for System i (DB2 Web Query), is IBM’s strategic replacement product for Query/400. Like Query/400, it provides reporting capabilities against DB2 for i5/OS data. However, it also offers features that address the Query/400 limitations: a graphical interface, modernized report formats, SQL access methods, and more. And, oh by the way, it can also run your existing Query/400 reports, thus protecting the company’s valuable investment in those system objects.

DB2 Web Query is a product available from IBM under licensed program 5733-QU2. Customers that have a license for Query/400 5722-QU1 and are current on their software maintenance are automatically entitled to the base license for 5733-QU2. Customers will be provided with a licence for a limited number of named users based on software tier, unlike Query/400 which was licensed for unlimited users.

1.3 Synonyms

DB2 Web Query employs a data description language to describe necessary data elements for many types of data sources, including relational structures. Using this language, DB2 Web Query can describe i5/OS tables (physical files) or views (logical files) that have been established within the relational database system on System i. This view of the data is a layer of abstraction that is used by DB2 Web Query for reporting and is known as the synonyms or metadata.

Metadata is discussed in more detail 3.4.1, “Metadata” on page 34

Note: In an attempt to reduce the naming ambiguity, throughout this book, the product Query for System i will be referred to as Query/400 and the new product IBM DB2 Web Query for System i will be referred to as DB2 Web Query.

Note: The terms metadata and synonyms are used interchangeably throughout this redbook. They both refer to the DB2 Web Query data abstraction layer.

Chapter 1. Introduction - Product Architecture and Overview 5

Page 24: DB2 Web Query for System i

7214ch01.fm Draft Document for Review October 10, 2007 9:57 am

1.4 DB2 Web Query features

Licensed program 5733-QU2 has a base product and additional product components. The features supported by each of these options are discussed in the following sections.

1.4.1 Base features

The following list highlights some of the main features of DB2 Web Query that are available with the base product of 5733-QU2:

� Browser based interface

A web browser is the interface for both DB2 Web Query developers and those users that will be running the reports. This provides a graphical environment without the requirement of installing additional desktop software or plug-ins on user’s PCs.

� Query/400 report modernization

DB2 Web Query provides built-in adapters to import existing *QRYDFN objects without requiring any changes to those objects. Once the appropriate metadata has been created from the import process, the queries can be invoked from a browser interface and results displayed to the browser. This provides a modernized interface for both running existing queries and the report output.

� Web based query and reporting of data stored in DB2 for i5/OS - Report Assistant

Included in DB2 Web Query is a component known as Report Assistant. This is an HTML-based graphical tool that allows you to create new queries or modify existing ones (including imported Query/400 queries). You can select a data source, specify any sorting or grouping information, and display the report in your browser or another desktop application. When you use Report Assistant, DB2 Web Query creates a styled report that you can deploy on the Web without the necessity of learning the complexities of any reporting language.

� Deliver output content in various modernized formats for web browsers and wireless devices

By default, DB2 Web Query will generate HTML and display the query results to the browser. However, you can optionally specify other output formats. The following list shows some of the more commonly used formats that are available:

– Excel (97 and 2000)

– Portable Document Format (PDF)

– eXtensible Markup Language (XML)

– PostScript (PS)

In addition, you can direct your DB2 Web Query report output to the traditional spooled file and database file formats.

� Easy Report graph generation - Graph Assistant

Graph Assistant is an HTML-based tool that guides you step-by-step through the creation of a graph. The Graph Assistant enables you to create and style your graphs.

� What You See Is What You Get (WYSIWYG) report building - Power Painter

PowerPainter is a Web layout and report creation tool, built using Asynchronous JavaScript™ and XML (AJAX) technology, that enables you to create output and page layout formats. It combines reporting, graphs, and page layout design in a single tool. The framework makes Power Painter a thin-client tool that looks, responds, and performs like a Windows®-based facility.

6 DB2 Web Query for System i

Page 25: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch01.fm

� Data adapters

Data adapters manage the communication between DB2 Web Query and the DB2 for i5/OS database through the use of SQL statements or other data access methods. Three adapters are provided with the base product:

– Query/400

– DB2 for i5/OS

– System i Heritage files

For more information on each of these adapters, refer to the section “Data adapters” on page 35

� Runs natively on System i

Each server side component of the DB2 Web Query solution runs natively on the System i. This integrated environment equates to a more simplified environment: there are fewer servers and operating systems to set up, administer, secure, backup, and maintain.

� Ability to utilize matrix reporting, ranking, color coding, drill-down and font customization to enhance the visualization of DB2 data.

� Federated DB2 for i5/OS data access

Customers with multiple System i servers or i5/OS partitions will value the federated query capabilities of DB2 Web Query. This feature provides the ability to develop a single report against multiple DB2 for i5/OS databases.

For more information on the base component of 5733-QU2, see section 2.1, “Installation and Setup” on page 18

1.4.2 Optional features available from IBM

In addition to the base product, there are optional features (also known as add-ons) that are available to enhance the product’s functionality. Add-ons are available from IBM for an additional charge. Features included in the list of add-ons are:

� Enabling existing reports to use Online Analytical Processing (OLAP) or multi-dimensional functionality.

The DB2 Web Query OLAP module allows slicing and dicing of data in an almost unlimited number of ways. This satisfies a broad range of analytical needs, enhances reports with extensive data-analysis functionality, and gives users the ability to dynamically interact with the data. OLAP-enabling a report allows users to drill down to lower levels of detail. Users can interact with their data, pivot rows and columns, visualize their numeric fields and much more.

� Rich client for building customized Business Intelligence applications - Developer Workbench

DB2 Web Query Developer Workbench is an add-on component that provides a rich client development environment.

While you do not need Developer Workbench to create DB2 Web Query reports, there are some compelling reasons to consider using it as your report development tool. The following list includes some reasons to consider such an upgrade:

– Dimension tool

• define hierarchies to be stored in the metadata

• Prerequisite for OLAP module

– Interface to easily manipulate metadata and customize synonyms

Chapter 1. Introduction - Product Architecture and Overview 7

Page 26: DB2 Web Query for System i

7214ch01.fm Draft Document for Review October 10, 2007 9:57 am

• Include meaningful field names

• Include multilingual titles

– SQL Wizard that allows developer to use type in or copy/paste SQL statements directly into the tool.

– Includes HTML Layout Painter tool

This powerful tool allows you to combine reports, graphs and other elements together in a single HTML document or layout. It provides a WYSIWYG design environment to help you create professional looking layouts that require more advanced components such as custom HTML, HTML template files, and cascading style sheets (CSS).

– Advanced programmer tools including:

• Data Profiling

• Impact analysis

• Ability to change field types (including integer or alpha to recognized date fields)

• Automatic date decomposition

� Offline reporting capability - Active Reports

Many mobile workers need access to important information in stored in their analytic reports while disconnected from the internet. With DB2 Web Query Active Reports, users like these can take the power of business intelligence with them wherever they go. By combining data and interactive controls into a single, self-contained HTML file, Active Reports delivers analytic capabilities in a completely portable and disconnected environment, with absolutely no software required. For more information on Active Reports refer to Chapter 8, “Active Reports” on page 149 and also refer to the following URL:

http://www.informationbuilders.com/products/DB2 Web Query/portable_analytics.html

� Additional named user licenses

If you need more named users than the base option provides or you need more than you are currently licensed for, additional licenses can be purchased. For more details, contact your IBM representative.

1.4.3 Optional features available from Information Builders

In addition to add-ons that can be acquired from IBM, Information Builders offers a suite of products that can greatly enrich your ability to create and deliver high quality reports with a broad range of capabilities. The following are some of the more common add-ons that can be acquired directly from Information Builders:

� Data adapters to connect to specific databases or ERP systems

DB2 Web Query provides comprehensive, native access to more than 300 distinct databases and information sources – including relational, legacy, ERP, CRM, data staged in warehouses or data marts, and real-time data from operational systems – on any platform. An up to date list of the native data, application, and technology adapters can be found at:

http://www.informationbuilders.com/products/systemi

� WebFocus ReportCaster

ReportCaster is a scheduling and distribution application that centralizes the execution and distribution of WebFOCUS reports, the contents of URLs, and files. In addition to batch scheduling and execution of reports, the output can then be emailed to users, ftp’ed to a specific PC directory or stored on the System i.

8 DB2 Web Query for System i

Page 27: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch01.fm

� Quick Data

Quick Data is an add-in for MS Excel that provides an Excel user with almost exactly the same interface as Report Assistant from within MS Excel.

Use the following table as a quick reference for determining which features are part of which offering.

Table 1-1 Feature-Offering matrix

Feature Base Offering IBM Add-On Offering Information Builder Add-on Offering

Base named user licenses

X

Web browser interface X

Synonym creation X

Report Assistant X

Graph Assistant X

Power Painter X

Modernized output (HTML, XLS, PDF, etc.)

X

Query/400 adapter X

System i Heritage File adapter (multi-member or multi-format files)

X

DB2 for i5/OS adapter (System i tables, PFs, views)

X

DB2 for i5/OS cross-system join

X

OLAP X

Developer Workbench X

Active Reports X

Additional named user licenses

X

Report Caster X

Over 300 additional data adapters

X

Quick DataMS Excel add-in

X

Chapter 1. Introduction - Product Architecture and Overview 9

Page 28: DB2 Web Query for System i

7214ch01.fm Draft Document for Review October 10, 2007 9:57 am

1.5 Architecture

Although DB2 Web Query runs natively on System i, it is comprised of multiple application tiers servicing different components. Each of the components of the overall architecture is listed below:

� Hypertext Transfer Protocol (HTTP) clients

� Web tier

– Application Server

– Web Server

� Reporting Server

� Data adapters

� Relational Database Management System (RDBMS) data

DB2 for i5/OS is the integrated database for the System i. Other source databases may be used with the installation of the appropriate add-on adapters discussed earlier in this chapter.

The overall DB2 Web Query system architecture is shown in Figure 1-1

Figure 1-1 DB2 Web Query base architecture

To better understand the architecture it is helpful to understand the end-to-end process, and how a report request flows through the architecture. The following steps describe the life cycle of a typical DB2 Web Query request:

1. A user requests a report for execution from a web browser.

2. The Web server receives the request, processes the parameters, and routes it to the Reporting Server via the DB2 Web Query Servlet.

3. The Reporting Server processes the request and hands it off to the appropriate Data Adapter

10 DB2 Web Query for System i

Page 29: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch01.fm

4. The Data Adapter generates the appropriate database request and submits the request to the DB2 for i5/OS database engine

5. Reporting Server receives the result set from the database, formats the report, and returns the formatted report to the Web server via the DB2 Web Query Servlet.

6. The Web server delivers the report to the user’s web browser for display.

1.5.1 Web browser clients

Both DB2 Web Query developers and end users use a web browser as the interface to the product. The browser clients communicate via the HTTP protocol to the application server. The supported web browsers are:

� Internet Explorer® (IE) version 6.0 or higher

� Mozilla Firefox version 1.5 or higher

1.5.2 Web server

Web servers generally serve as the static content repository and handle HTML, GIF, CGI, and other traditional Web content and processing. The IBM HTTP Server is used to fulfill this role for the DB2 Web Query product.

The web server content for DB2 Web Query is grouped into contexts (aliases). These are grouped together in subdirectories and stored in the i5/OS Integrated File System (IFS) under the directory qibm/proddata/webquery/ibi/webfocus76. Under this directory is webquery_html, the context subdirectory that contains the following:

– Common Templates and Forms

– Common Images, Scripts and Style sheets

– Published Forms/Launch Pages

1.5.3 Application Server

An application server is a component-based product that resides in the middle-tier of a server centric architecture. It handles requests from web clients that require Java and non-traditional processing and provides middleware services such as security and state maintenance. DB2 Web Query runs on the i5/OS Integrated Web Application Server and uses the servlet container component to process these client requests. Servlet containers (also referred to as servlet engines)

The following list describes some of the attributes of the DB2 Web Query application server:

� Is a J2EE™ compliant web application

� Runs on a “Servlet Container”, a Java based container serving servlets, Java Server Pages (JSPs) and Connectors

� Does not require a full J2EE Application Server

� Supports Servlets

� Standardizes deployment schemes using archives/packages

� In some cases, multiple applications can be grouped into Web Application Bundle (WAB) files.

Chapter 1. Introduction - Product Architecture and Overview 11

Page 30: DB2 Web Query for System i

7214ch01.fm Draft Document for Review October 10, 2007 9:57 am

� Applications are grouped into the Web Application Bundle (WAB) file named webfocus76.wab. This WAB file is served under the context root of “/ibi_apps” and contains the following components:

– DB2 Web Query Servlet

• DB2 Web Query API

• Managed Reporting API

Communicates with MR Repository (basedir)

– DB2 Web Query home page Controller and JSPs

– DB2 Web Query Administration Console

– DB2 Web Query and Managed Reporting Drivers

– Communication Drivers to DB2 Web Query Server*

– Custom DB2 Web Query Exit (Plug-in)

– Custom Servlet Filter (Plug-in)

The DB2 Web Query servlet within the base architecture is shown in Figure 1-2.

Figure 1-2 DB2 Web Query Servlet within Application Server

1.5.4 Reporting server

DB2 Web Query Reporting Server is a C based application that resides on the System i and is responsible for managing data access, processing the business logic, and the generation of the fully styled output. It is comprised of the following components:

12 DB2 Web Query for System i

Page 31: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch01.fm

� Reporting Engine of DB2 Web Query product

� Data adapters repository

� Metadata/Synonym repository

1.5.5 Data Adapters

The Data Adapter is responsible for generating the appropriate request to submit to the database engine. The format of the request is dependent on the adapter that is used:

– DB2 for i5/OS Adapter - Generates appropriate SQL statement(s) to submit to the DB2 for i5/OS database engine.

– System i Heritage File adapter - Generates appropriate OPNQRYF command to handle reports that are based on data in multi-member or multi-format files.

– Query/400 Adapter - Retrieves the associated Query/400 query.

More information on Data Adapters can be found 3.4.2, “Data adapters” on page 35

1.6 DB2 Web Query Developer Workbench

Developer Workbench serves as the “thick” client component of DB2 Web Query that is used primarily for advanced development purposes. It is the standard Integrated Development Environment (IDE) for DB2 Web Query technology. Similar to the browser client, the Developer Workbench client communicates in HTTP protocol to the DB2 Web Query application server. Developer Workbench is an optional feature of DB2 Web Query. Developer Workbench is the only component that requires any software to be loaded on the client. Its place in the overall architecture is shown in Figure 1-3 on page 14.

Chapter 1. Introduction - Product Architecture and Overview 13

Page 32: DB2 Web Query for System i

7214ch01.fm Draft Document for Review October 10, 2007 9:57 am

Figure 1-3 Developer Workbench within the DB2 Web Query architecture

1.7 DB2 Web Query Product Positioning

The base version of the DB2 Web Query product is intended to serve as the strategic replacement to Query/400. If you are using Query/400 today as your primary reporting tool, or your requirements are for a robust query and reporting tool on the System i, the base product may be all that you need. While the new web based product is ideal for the mid-market, it offers the foundation to support large enterprise requirements as well. Consequently, if you have requirements for more advanced Business Intelligence (BI) capabilities, the upgrade path (available through the various add-on components) allows DB2 Web Query to be well positioned to support such large enterprise needs as well. This product will fill end user reporting requirement needs from parameterized and ad hoc reporting, to analytical (multi dimensional) slicing and dicing. It does not require a data warehouse or cubing technology, but if that is the desired BI infrastructure it integrates with that design with ease.

The add-on components available from Information Builder’s provide the ability to integrate with over 280 sources of information, including legacy sources and packaged applications. This is accomplished through native data adapters that are tuned and optimized for each data source. Such integration can greatly enhance the potential of a data warehouse. One of the biggest reasons why a data warehouse implementation fails is because it lacks certain key information to make it complete. This is often because the source for the missing data was inaccessible by the warehousing tool, a problem addressed by DB2 Web Query. For example, you could, in a single report, be viewing data that came from an Oracle database, an ERP system, and a DB2 data mart or data warehouse repository.

14 DB2 Web Query for System i

Page 33: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch01.fm

Overall you will find the various data adapters can reduce the data integration costs for your BI implementations because of its simple access to these sources. Reports from these various data sources can be created within hours after product installation.

Because DB2 Web Query is comprehensive and can access all data in a company it will be the logical choice as the standard for BI and reporting for many companies.You can use it for management within your organization to provide the following types of reports to keep you updated on the general health of your business.

� Dashboards

� Scorecards

� Key performance indicators (KPI)

� Drill downs

� Operational reports

In addition, the Report Caster product available from Information Builders will give you the ability to automatically deliver reports to your users. This add-on component can intelligently burst the pages of a single report out to the appropriate people. Delivery can be based on a schedule or based on some technology event. (such as new transaction, a stock price rises or falls to a certain level, or even a change in the weather.) Delivery destinations include sending reports to a Web Server, a database archive (called a Report Library), to E-mail (one of the more common destinations), mobile devices, and of course to a printer or fax machine.

Chapter 1. Introduction - Product Architecture and Overview 15

Page 34: DB2 Web Query for System i

7214ch01.fm Draft Document for Review October 10, 2007 9:57 am

16 DB2 Web Query for System i

Page 35: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch02.fm

Chapter 2. Installation and Server Operations

This chapter covers the installation of DB2 Web Query, 5733QU2 using RSTLICPGM. It outlines the PC and System i prerequisites for installing DB2 Web Query. It also describes what i5/OS system jobs will run and what their functions are in DB2 Web Query. Other system objects created upon installation of DB2 Web Query will be discussed.

2

Note: For the latest and more complete information on installation instructions please refer to:

http://www-03.ibm.com/systems/i/software/db2/pdf/DB2_Web_Query_Install.pdf

© Copyright IBM Corp. 2007. All rights reserved. 17

Page 36: DB2 Web Query for System i

7214ch02.fm Draft Document for Review October 10, 2007 9:57 am

2.1 Installation and Setup

The licensed program product number for DB2 Web Query for System i is 5733QU2. This will replace 5722QU1 or Query/400. DB2 Web Query will include the existing Query/400 product as well as the new offering. You can continue to create and run Query/400 reports and slowly migrate to DB2 Web Query if you choose. The two products can successfully operate concurrently against the same tables and libraries. 5722QU1, as an independent product, will be withdrawn from marketing. The functionality will reside under 5733QU2 with DB2 Web Query.

2.1.1 Installation steps

Before you start the installation steps please read the information in the Important box below.

After you have installed the required license programs and PTFs found in the APAR described before, the following are the installation steps:

1. Sign on as QSECOFR or use a user profile with *SECADM and *ALLOBJ authority.

2. Depending on what options of the product you want to install you would type the following commands:

a. For the Base Product

RSTLICPGM LICPGM(5733QU2) DEV(OPT01)

b. If Active Reports was purchased

RSTLICPGM LICPGM(5733QU2) DEV(OPT01) OPTION(1)

c. If OLAP Enablement option was purchased

RSTLICPGM LICPGM(5733QU2) DEV(OPT01) OPTION(2)

d. If Developer Workbench was purchased

RSTLICPGM LICPGM(5733QU2) DEV(OPT01) OPTION(3)

3. Read and press F14 to accept the license.

4. Load and apply the latest 5733QU2 PTFs as described in the informational APAR II14318.

5. Type on the command line: CALL QWEBQRY76/REGWEBQRY // Register the DB2 Web Query HTTP instance.

The first time the product is installed, it creates a user profile QWEBQRYADM with no password supplied. In the next step we will be setting up a password for this profile.

6. Type in the command line: CHGUSRPRF USRPRF(QWEBQRYADM) PASSWORD(<yourpassword>)

Important: For the most up-to-date information on prerequisites and required PTFs, please refer to the Informational APAR II14318 which can be found at:

http://www-912.ibm.com/n_dir/nas4apar.nsf/c79815e083182fec862564c00079d117/19f34f5766e54eef8625732d003c677d?OpenDocument&Highlight=2,II14318

18 DB2 Web Query for System i

Page 37: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch02.fm

2.1.2 Post Installation steps

The users that will be using the product needs to be pre-authorized and this is done by following steps:

1. For each user that will be using the product, you must type the following command:

CALL QWEBQRY76/WQADDLIC ‘USRPRF’ // where USRPRF is the user profile that you want to authorize. Type the USRPRF name in upper case.

2. If you need to remove an user type the following command:

CALL QWEBQRY76/WQRLSLIC ‘USRPRF’ // where USRPRF is the user profile that you want to disable.

Note: If you exceed the limit of purchased named users, the login function will be disabled.

3. To display which users are currently registered, type the following command:

WRKLICINF PRDID(5733QU2), option 8 for feature 5050.

4. If you have installed Developer Workbench follow the following steps:

a. Load and apply the latest 5733QU2 PTFs for Developer Workbench as described in the informational APAR II14318.

b. Copy the install file from IFS to your PC. This can be done by FTPing the install file to the PC or mapping a drive from the PC to the IFS. The install file is located at:

/qibm/proddata/webquery/ibi/DeveloperWorkBench/WfDevStudio763i.exe

c. Execute the Developer Workbench Install Program: WfDevStudio763i.exe

i5/OS System objectsUpon install of 5733QU2, these IFS directories will be created:

� /QIBM/PRODDATA/WEBQUERY/IBI

� /QIBM/USERDATA/WEBQUERY/IBI

These system objects will be created:

:These are user profiles the Web Query needs:

These are Web Query related user profiles:

� QWEBQRYADM - This profile has functionality on the server side. It has authority to start and stop the reporting server. It will be automatically created.

Object name Object Type

QWEBQRY76 *LIB

QWEBBASE *LIB

QSYS/QWEBQRYADM *USRPRF

QSYS/MRADMIN *USRPRF

QSYS/MDUNTITLED *USRPRF

QSYS/QWEBQRY *AUTL

QWEBQRY76/QWEBQRYJOB *JOBD

QUSRSYS/QWEBQRYADM MSGQ

Chapter 2. Installation and Server Operations 19

Page 38: DB2 Web Query for System i

7214ch02.fm Draft Document for Review October 10, 2007 9:57 am

� MRADMIN - This group profile has the authority to create domains in DB2 Web Query. It also has the rights to create reports in all domains and folders on the system.

� MDUNTITLED - This group profile gives users the authority to create reports in the default common domain.

2.1.3 License keys

Ater you have installed DB2 Web Query, you will be allowed a grace period in which to try the product. During this grace period, you will have access to all the features provided in the base product as well as all of the IBM add-on components. However, once the grace period has expired, license keys will be required to continue using both the base product and the add-on components. To obtain your DB2 Web Query license keys, ou will need to work through your normal product ordering channels (for example, a System i business partner). The system serial number is required to generate your specific license keys. When you receive this information back from your business partner, it will look something like this:

Product ID . . . . . . . . : 5733QU2 License term . . . . . . . : V1R1M0 Feature . . . . . . . . . . : 5050 Serial number . . . . . . . : 1078950 Processor group . . . . . . : *ANY Expiration date . . . . . . : 07/11/30 Usage limit . . . . . . . . : 4 Vendor data . . . . . . . . : *NONE License key . . . . . . . . : 921BA3 71228D 4F7C01

Product ID . . . . . . . . : 5733QU2 License term . . . . . . . : V1R1M0 Feature . . . . . . . . . . : 5101 Serial number . . . . . . . : 1078950 Processor group . . . . . . : *ANY Expiration date . . . . . . : 07/11/30 Usage limit . . . . . . . . : 4Vendor data . . . . . . . . : *NONE License key . . . . . . . . : 844C88 0793CB 21B986

Product ID . . . . . . . . : 5733QU2 License term . . . . . . . : V1R1M0 Feature . . . . . . . . . . : 5102 Serial number . . . . . . . : 1078950 Processor group . . . . . . : *ANY Expiration date . . . . . . : 07/11/30 Usage limit . . . . . . . . : 4Vendor data . . . . . . . . : *NONE License key . . . . . . . . : 896174 D047B4 548C01

Each license key is used to activate either the base product feature (5050) or one of the add on features (5101 and 5102). To enter your license keys and activate the specific features, use the ADDLICKEY command. For the examples given above, the commands you would enter are as follows:

ADDLICKEY PRDID(5733QU2) LICTRM(V1R1M0) FEATURE(5050) SERIAL(6504690) LICKEY(921BA3 71228D 4F7C01 ) USGLMT(4) EXPDATE(*NONE)

20 DB2 Web Query for System i

Page 39: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch02.fm

ADDLICKEY PRDID(5733QU2) LICTRM(V1R1M0) FEATURE(5101) SERIAL(6504690) LICKEY(844C88 0793CB 21B986 ) USGLMT(4) EXPDATE(*NONE)

ADDLICKEY PRDID(5733QU2) LICTRM(V1R1M0) FEATURE(5102) SERIAL(6504690) LICKEY(896174 D047B4 548C01 ) USGLMT(4) EXPDATE(*NONE)

2.2 PC and System i Requirements

In this section we will cover the PC and System i minimum requirements to install and run DB2 Web Query.

2.2.1 PC Requirements

No client needs to be installed on your PC to enable DB2 Web Query because all you need is a browser. The browser requirements are:

� Internet Explorer 6.0 or higher

� Firefox 1.5 is certified, version 2.0 is supported

If you are unsure what version of Internet Explorer you are using, open the browser and go to the Help menu. Select About Internet Explorer and note the version number.

PC memory requirements - In general usage, queries usually run best on PCs with 1 gig of RAM or more.

2.2.2 System i Requirements

� Your System i needs to be V5R4 of i5/OS.

� Qshell must be installed. It is a no charge option and comes with i5/OS. If you are not sure if you have it installed, type QSH on your i5 command line and push enter. If a QSH command line appears, then it is installed. It is option 30 of the Operating System.

� The following licensed programs must be installed:

– 5722SS1 option 30 - Qshell

– 5722SS1 option 33 - Portable App Solutions Environment

– 5722JC1 - IBM Toolbox for Java

– 5722DG1 - IBM HTTP Server for i5/OS

– 5722JV1 option 7 - Java Developer Kit 5.0

– 5722JV1 option 8 - J2SE 5.0 32 bit

– 5722JV1 - Java Runtime Environment JRE™ 1.4 or higher

2.2.3 Developer Workbench requirements

Though Developer Workbench client is not required for DB2 Web Query report development and execution, you may still find that it provides additional development features that make it

Note: You do not have to wait for the grace period to expire before entering your license keys. It can be done at any time.

Chapter 2. Installation and Server Operations 21

Page 40: DB2 Web Query for System i

7214ch02.fm Draft Document for Review October 10, 2007 9:57 am

worthwhile. If you do choose to install it on your PC, use the following hardware and software requirements.

Hardware RequirementsVerify that your Windows machine meets the Developer’s Workbench hardware requirements:

� Pentium 3 or higher at 600 MHz or higher.

� VGA or higher resolution graphics card. Display of 1027x768 is recommended.

� 512 MB of RAM.

� 500 MB free hard disk space for CD installation. 1.5 GB for downloaded installation.

Software RequirementsVerify that your Windows machine meets the Developer’s Workbench software requirements:

� Windows 2000, XP, or 2003 Server and Professional Editions. Windows 2000 must have Service Pack 2 or higher.

� Internet Explorer 6 and higher. Internet Explorer components are required for Developer’s Workbench. If possible, upgrade to the most recent version of Internet Explorer.

� Adobe Acrobat Reader 6.0 and higher. Acrobat Reader 6 and 7 are certified to view PDF reports generated by Developer’s Workbench.

Provided Third Party ComponentThe following third party component is provided for use with Developer’s Workbench. If it is not present on your machine, you have the option to install it with Developer’s Workbench:

– Java 2 SDK 1.5.0_09. A Java SDK is required for WebFOCUS features such as servlet connectivity, graph generation, and OLAP. If a Java SDK 1.4.1 or higher is not installed on your machine, you must allow Developer’s Workbench to install the SDK.

2.3 Reporting Server Commands

The base component of the licensed program provides multiple i5/OS commands to help with DB2 Web Query administrative tasks. In order for these command to work successfully, you must be signed in as user profile QWEBQRYADM.

STRWEBQRY START(*ALL) - Use this command to start all the jobs needed to run Web Query.

ENDWEBQRY - Use this command to end the reporting server. Using the OPTION (*CLEAR) is recommended.

TRCWEBQRY - The WEBQRY Trace / Save Command (TRCWEBQRY) command turns on, off and saves server traces.

Note: You must be an administrator to the Windows machine to run the Developer Workbench installation

22 DB2 Web Query for System i

Page 41: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch02.fm

2.4 DB2 Web Query server jobs

DB2 Web Query connects to i5/OS using SQL Call Level Interface (CLI). CLI is a callable SQL programming interface that is available in DB2 on i5/OS. CLI consists of APIs that are used to connect to the server and start dynamic SQL statements. CLI is a subset of ODBC. The system job that processes CLI is QSQSRVR. For more information on CLI, visit the Info Center at this link:

http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/cli/rzadp.pdf

Below is the list to the jobs that will run on your server when the reporting server is running. For all jobs, the start time of the job is the start time of the reporting server.

� EDAPTH - There will be one job. It helps with the workspace process.

� EDAPLOG - There will be one job. It contains startup info.

� EDAPGWY - There will be three of these jobs. They are listener jobs. There is one each for HTTP, TCP, and Java. These jobs receive incoming requests and hand work off to the TSCOM3 jobs.

� TSCOM3 - By default there are 4 of these jobs running. These jobs accept the request from the EDAPGWY job and translate the DB2 Web Query request into SQL. One TSCOM3 job does not correspond to one user, one TSCOM3 job can service several users. For this reasons, the design of these jobs contribute to the scalability of the product. They are referred to as “agents.”

� JSCOM3 - There will be one job. It services java processes.

� HLISNK - There will be one job. It is an internal server process.

� QP0ZSPWP - The DB2 Web Query JVM thread.

� WQLWI7 - Integrated Application Server jobs. Three of these jobs should be running whenever DB2 Web Query is active.

QSQSRVR - This is an i5/OS native prestart job that handles SQL requests made over CLI. This job will do the actual database work of optimization and returning the result.

The jobs listed above will auto-start in the QSYSWRK subsystem. However you may configure these jobs to start in their own subsystem. The QSQSRVR jobs will always run in the QSYSWRK subsystem, even if you configure all the other jobs to run in their own subsystem.

You can find information about the runtime environment(including ports used) in /QIBM/UserData/webquery/ibi/srv76/wfs/edaprint.log.

Chapter 2. Installation and Server Operations 23

Page 42: DB2 Web Query for System i

7214ch02.fm Draft Document for Review October 10, 2007 9:57 am

24 DB2 Web Query for System i

Page 43: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch03.fm

Chapter 3. DB2 Web Query Fundamentals

This chapters introduces the basic steps that have to be done to start using DB2 Web Query. The first section illustrates how to signon to DB2 Web Query so everyone should start there. After you are logged on, then proceed to the section that contains the instructions for what type of user you are, an administrator, a developer, or a basic user.

3

© Copyright IBM Corp. 2007. All rights reserved. 25

Page 44: DB2 Web Query for System i

7214ch03.fm Draft Document for Review October 10, 2007 9:57 am

3.1 Registering named users

DB2 Web Query is licensed by named users. Each user profile needs to be registered.

Registering a new UserTo register a user with DB2 Web Query run the following command.

CALL QWEBQRY76/WQADDLIC ‘USERPROFILE’

USERPROFILE references your System i user profile name and must be specified in upper case letters.

Removing a DB2 Web Query registrationTo remove a registered DB2 Web Query user run the following command.

CALL QWEBQRY76/WQRLSLIC ‘USERPROFILE’

Again your user profile needs to be in upper case.

Displaying registered usersTo display your currently registered users use:

WRKLICINF PRDID(5733QU2)

and take option 8 for feature 5050.

3.2 Logging in

One of the many positive features of DB2 Web Query is that you do not need to install anything on your PC to use it. The only client you need to create and run reports is the ubiquitous browser. Note: DB2 Web Query supports Internet Explorer and Firefox.

Let’s say your system name is MYSYSTEM.ABC.ACME.COM. Then the internal URL you will use is:

http://mysystem.abc.acme.com:11331/webquery

The port number in the URL will always be 11331 since this is the default port for DB2 Web Query. Sign onto DB2 Web Query with the same user profile and password you use to access the System i server. A webpage like the one shown in Figure 3-1 should appear.

26 DB2 Web Query for System i

Page 45: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch03.fm

Figure 3-1 DB2 Web Query Sign on

Once you are logged on, you will only see the domains and menu options that you are authorized to as shown in Figure 3-2. For an explanation of what are domains refer to 3.3.1, “DB2 Web Query domains”. If you do not see a domain that you think you should be authorized to, contact your DB2 Web Query administrator.

Tip: Add your DB2 Web Query URL to your browser “Favorites”

Chapter 3. DB2 Web Query Fundamentals 27

Page 46: DB2 Web Query for System i

7214ch03.fm Draft Document for Review October 10, 2007 9:57 am

Figure 3-2 DB2 Web Query home page

3.3 Administrator tasks

The main tasks for Administrators will be creating domains, creating sub-folders within those domains, and assigning user authority.

The User Profile for the AdministratorThe group profile for the administrator is MRADMIN. This administrator is the only one authorized to create new domains. The administrator is authorized to create and run reports in all domains.

If user profile SAMMY is to be the administrator, use the following CL command to assign it to the group profile MRADMIN:

CHGUSRPRF USRPRF(SAMMY) GRPPRF(MRADMIN)

Beware - If the user profile SAMMY already has a group profile, then use the following command so as not to overwrite the current group profile:

CHGUSRPRF USRPRF(SAMMY) SUPGRPPRF(MRADMIN)

28 DB2 Web Query for System i

Page 47: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch03.fm

3.3.1 DB2 Web Query domains

In the context of DB2 Web Query, the word domain refers to a graphical way to classify and separate your reports. For example, an administrator could create domains for Sales, HR, Marketing, and so on.

The first time you open up your browser to DB2 Web Query, you will see only the default Common Domain. Inside the Common Domain folder, you will see two other folders as shown in Figure 3-3:

� Reports: This folder is where permanent report objects are displayed. Your users will go into this folder to find the report they want to run. Developers that are authorized to this domain will be able to create new reports in this folder.

� Other Files: This folder contains files like style sheets and jpegs you may want to import into your report.

Figure 3-3 Common Domain Folder

Before Creating a Domain - Naming ConsiderationsIt is a a good practice to initially name your domains exactly with eight characters. These eight characters are also known as the Href. You can view an Href for a domain by right clicking on the domain and selecting Properties as shown in Figure 3-4. If you create a domain that has less than 8 characters, the domain name will be padded to complete the 8 characters. These padding characters are auto-generated. You will need to know what the Href is in order to assign user authority. This will be explained in 3.3.3, “Assigning authority to users”.

Figure 3-4 Properties of a Domain

Why create domains with exactly eight characters?DB2 Web Query uses the href, which is based on the domain name, to control user access to the domain. DB2 Web Query will check which System i groups the user belongs to. If the user belongs to a group “MDhrefname” this means that the user can be a developer in the domain

Chapter 3. DB2 Web Query Fundamentals 29

Page 48: DB2 Web Query for System i

7214ch03.fm Draft Document for Review October 10, 2007 9:57 am

with the associated href. For a user to be a developer in the Common Domain in Figure 3-4 they would need to belong to the group “MDUNTITLED”. The other special prefix is that DB2 Web Query will check for is MU. Having a group profile of MUUNTITLED would mean the profile was a valid user in the Common Domain (href “untitled”) and was allowed to run reports there but not to create them. In actual fact the Common Domain is the system default and it is the one domain that you do not require an MUhref to run reports in it. If you are registered as a licensed user of DB2 Web Query then you are entitled to run reports in the Common Domain by default.

If you want a domain name to be greater than eight characters, first create it with a meaningful name of exactly eight characters. Then rename your domain to your desired name that is greater than eight characters. The original eight characters will be remain your Href name.

For example, if you want your domain to be Month End Reports, you could first create your domain as monthend. Then you can rename it to Month End Reports and your Href will remain the eight characters of “monthend”. Table 3-1 shows what the Developer and Basic User group profiles will be for the example just mentioned in this paragraph.

Table 3-1 Developer and Basic User Group Profiles

How to create a domainLog on to DB2 Web Query home page as an Administrator which is a user profile belonging to the MRADMIN group. Right click on Domains and select New Domain. A small window will appear as the one shown in Figure 3-5 where you can type your domain name, then click the Save button. If your domain name was shorter than eight characters, right click on your domain and select properties in order to view what was auto-generated.

Figure 3-5 Create a domain

Domain Name Href name Developer group profile

Basic User group profile

Month End Report monthend MDMONTHEND MUMONTHEND

Tip: Avoid using blanks or special characters domain names, folder names or field names within DB2 Web Query.

30 DB2 Web Query for System i

Page 49: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch03.fm

How to rename a domainRight click on the existing domain and select properties. You will see the name listed in a white box which you can simply type over. Once you have edited the name to what you really want, click OK as shown in Figure 3-6.

Figure 3-6 The rename domain window

3.3.2 Creating sub-folders

After you have created your domains, you will need to create folders inside of those domains. These sub-folders further classify the types of reports within their domains. When the domain is expanded, a Developer or User will be able to recognize which sub-folder contains his report. You cannot create reports directly in the “Reports” folder. A subfolder must be used to create and store reports.

A Developer is authorized to create new sub-folders, but a User is not.

To create a sub-folder, right click on Reports and select New Folder. A window as shown in Figure 3-7 appears.

Figure 3-7 Create Folder

Type the desired name for the new folder and press the Save button. Your Developers can now create reports in the folder.

Chapter 3. DB2 Web Query Fundamentals 31

Page 50: DB2 Web Query for System i

7214ch03.fm Draft Document for Review October 10, 2007 9:57 am

3.3.3 Assigning authority to users

There are two other user categories besides the Administrator. The two categories are Developers and Users. Developers may create new reports and modify existing reports. Users only have authority to run existing reports. They can not edit or change anything about the existing report. When basic users right click on a report, they do not see a menu.

Table 3-2 shows what user types have what authority. Monthend is the example domain name used. Note that MD denotes the Developer group profile for that domain, and MU denotes the Basic User group profile for that domain.

Table 3-2 Authority of the different users

Here is an example of creating a new domain and assigning user authority. Let’s say you create a domain named monthend. Bob will be a Developer, and Jim will be a basic user who runs read-only reports.

First you must create the new domain from the DB2 Web Query home page. Then you would go to the System i command line and create the user profiles using the following CL commands.

CRTUSRPRF USRPRF(MDMONTHEND) TEXT(‘Group Profile for Developers’)

CRTUSRPRF USRPRF(MUMONTHEND) TEXT(‘Group Profile for Basic Users’)

After you have created group profiles for Developers and Users for domain monthend, you must assign existing users their correct authority. To assign users to the desired authority, use the CHGUSRPRF CL command. For example:

CHGUSRPRF USRPRF(BOB) GRPPRF(MDMONTHEND)

CHGUSRPRF USRPRF(JIM) GRPPRF(MUMONTHEND)

If you use the CHGUSRPRF command to change the group profile name while a user is currently signed on to DB2 Web Query, he must log off and log on again to see the new authority reflected.

If a user does not belong to any group profiles for a domain, he will only be authorized to run reports in the common domain. No other domains will be visible to him.

Administrator Developer Basic User

Group Profile name MRADMIN MDMONTHEND MUMONTHEND

Authority

Create Domain Yes

Create sub-folder Yes Yes

Create Report Yes Yes

Change Report Yes Yes

Run Report Yes Yes Yes

32 DB2 Web Query for System i

Page 51: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch03.fm

3.4 Developer tasks

The section describes the first steps in preparing to create a DB2 Web Query report. This section will cover steps that prepare you to write a report, such as which adapter to use and creating metadata.

A developer does not need to know either Query/400 or SQL to use DB2 Web Query. The report writing process in DB2 Web Query is different than either of the former tools. Though DB2 Web Query is mentioned as a replacement for Query/400, it is not a GUI representation of it. The “knobs and buttons” are different, and it has its own look and feel. This is a completely new tool for System i.

All examples in the tutorials are based on the sample database QWQCENT. This is a sample database that can be downloaded from the IBM Redbooks website. For more information on how to download this sample database please refer to Appendix E, “Additional material” on page 339. It contains 4 tables. Figure 3-8 is a Database map of the QWQCENT schema. It was created with iSeries Navigator.The icons between the tables represent a foreign key constraint.

l

Figure 3-8 Database map of the QWQCENT(CENTURY) Schema

For non SQL programmers the table shown in Figure 3-9 maps the equivalent terms between SQL and i5/OS.

Note: The sample database used to be called CENTURY on the pre-GA version of the product. For this reason if we refer to the CENTURY database we are actually referring to QWQCENT.

Chapter 3. DB2 Web Query Fundamentals 33

Page 52: DB2 Web Query for System i

7214ch03.fm Draft Document for Review October 10, 2007 9:57 am

Figure 3-9 SQL and i5/OS terminology

3.4.1 Metadata

DB2 Web Query requires it's own metadata to be able to read from DB2 objects. This metadata is referred to as a Synonym. First, the Synonym must be created on the data you wish to query, then it can be referenced in any number of reports. After you have created the metadata once, you do not need to create it again for that same object unless the file layout changes. The metadata is permanent object in the IFS. The metadata contains similar information to what DSPFFD contains. (For more information on what gets created on the system, see Appendix A, “Metadata in the IFS” on page 317)

How to create metadataFrom the DB2 Web Query home page expand the domain you wish to work in. Expand Reports and right click on the specific report folder. Select Metadata as shown in Figure 3-10.

i5/OSSQL

Terminology

log

column

row

index

view

table

schema/collection

journal

field

record

keyed logical file

logical file

physical file

library

34 DB2 Web Query for System i

Page 53: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch03.fm

Figure 3-10 Metadata

After selecting Metadata, a new window will pop up as shown in Figure 3-11.

Figure 3-11 Data Adapters Window

3.4.2 Data adapters

DB2 Web Query comes with three different adapters. An adapter is a program that enables DB2 Web Query to access a data source. The adapter you choose to create your metadata or your synonym is transparent to the end users who will be creating reports.

Here is a list of the three adapters.

Chapter 3. DB2 Web Query Fundamentals 35

Page 54: DB2 Web Query for System i

7214ch03.fm Draft Document for Review October 10, 2007 9:57 am

� DB2 cli adapter. This is the recommended adaptor for use by DB2 Web Query. Select this adapter if you want to write a report on a single member physical file. This can include a SQL table or a DDS created physical file. This adapter is also used for object types of Alias, Stored procedures, and MQTs. The DB2 for i5/OS adapter will generate SQL that takes full advantage of the latest DB2 enhancements that are found in SQE or the SQL Query Engine.

� System i heritage file adapter. Use this adapter when you need to query a file that has multiple members or multiple record formats. This adapter submits an OPNQRYF command to the server. OPNQRYF does not take advantage of the new enhancements to the DB2 optimizer and uses CQE or the Classic Query Engine under the covers.

� Query/400 adapter. Choose this adapter when you want to create metadata on an already existing Query/400 query. The QRYDFN object must exist on the System i. This adapter sends the RUNQRY command to the server which also uses the older CQE or Classic Query Engine.

Table 3-3 reviews which Adapter corresponds to which data type.

Table 3-3 Data Adapters

The three above adapters are provided with the base DB2 Web Query product. To see a full list of additional adapters that can be purchased from Information Builders see the following link http://www.informationbuilders.com/products/webfocus/data_access.html.

You must select which of the three adapters matches the data you will create metadata on. In this example, we use DB2 for i5/OS, which is for a single member file. LEFT click on the adapter and select Create Synonym as shown in Figure 3-12. If you have a connection to a remote database, you will select which database you want to connect to from this screen. Notice we will click on the *LOCAL connection.

Adapter Data Type Command sent to i5

DB2 cli single member physical file. Alias, Stored Procedure, or MQT.

CLI API

System i heritage files multiple member filemulti record format files

OPNQRYF

Query/400 QRYDFN object RUNQRY

36 DB2 Web Query for System i

Page 55: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch03.fm

Figure 3-12 Creating a Synonym

In this window, enter your Collection name into the dialogue box. Check what type of data you want to query. In our example, we want to create metadata on a Table in QWQCENT. Check the box next to table. Enter QWQCENT in the dialog box. Click Next.

Figure 3-13 Selecting the Schema/Library

A window appears showing all the different tables that reside on the QWQCENT (Century) Schema as shown in Figure 3-14. On this window, check the table names you wish to create reports. You may want to include a Prefix or Suffix. In our example cen_ will be our prefix. See the section “Prefix and Suffix - optional yet recommended” on page 38 for a discussion on prefix and suffixes.

Chapter 3. DB2 Web Query Fundamentals 37

Page 56: DB2 Web Query for System i

7214ch03.fm Draft Document for Review October 10, 2007 9:57 am

Figure 3-14 Selecting tables from a Schema/Library

Prefix and Suffix - optional yet recommendedThese are optional letters you can add to your synonym name to provide extra meaning for you. Using a prefix or suffix is not required. It is up to the Developer to decide if he wants to use the prefix and what naming convention is preferred. It may be recommended to use the library name or an abbreviated version of the library name for the prefix. This way, when you go to create your reports, you can search on all metadata that starts with the library name. Keep in mind all metadata is displayed in one box called “Database Descriptions.” The box is rather small and does not list the metadata according to library. In our example shown in Figure 3-14 we used the prefix “cen_ “, since the table resides in library QWQCENT. We left the suffix blank, but again it is the developer’s choice to use it. Leave baseapp in the drop down box. Now click the Create Synonym button.

The metadata will take a few seconds to create, depending on how many items you have checked. Once it is done, you will see on the Status column a message “Created successfully” as shown in Figure 3-15. After this the process of creating metadata is complete. You are ready to begin the tutorials in Chapter 5, “Report Assistant” on page 63.

38 DB2 Web Query for System i

Page 57: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch03.fm

Figure 3-15 Creating metadata Successful message

3.4.3 Miscellaneous considerations about creating metadata

The DB2 for i5/OS adapter can create metadata on five different i5/OS object types: tables, views, aliases, stored procedures, and materialized query tables. Tables, Views, Aliases and MQTs are treated identically by DB2 Web Query. All of them can be used to filter, join, sort, define, compute, and access all the functionality of Report Assistant. After you create the metadata, you will not be able to tell which object type you are using in your report.

Creating metadata on a stored procedureWhen you create metadata on a stored procedure, DB2 Web Query views the metadata as a result set. You will be able to simply run the report and see the stored procedure result set returned. You will also be able to use the functionality of Report Assistant to filter and manipulate the result set.

Considerations with multi-member files. As noted in Table 3-3, the DB2 for i5/OS adapter sends SQL statements to i5/OS, whereas the System i heritage file adapter sends the OPNQRYF CL commands. As indicated earlier DB2 for i5/OS optimizes SQL and OPNQRYF differently. SQL can go down the codepath of the newer SQL Query Engine, whereas OPNQRYF must still go down the Class Query Engine. In general, SQE tends to be faster than CQE.

A limitation of SQL is that it can only read data from the first member in a file. Perhaps you have run in to this limitation when writing SQL queries on multi member files before. One option is to consider using an SQL Alias. This will enable your query to use the DB2 for i5/OS adapter and make the query eligible for SQE. The Alias is a permanent i5/OS object that “points” to a specific member in a file. It is very easy to create, and once it exists SQL treats the Alias just the same as it would a table. You simply substitute the Alias name in any query where you would put a table name.

Note: DB2 Web Query does support the return of multiple result sets from the stored procedure. In this case, it will assign a distinct segment name to the fields of each separate result set.

Chapter 3. DB2 Web Query Fundamentals 39

Page 58: DB2 Web Query for System i

7214ch03.fm Draft Document for Review October 10, 2007 9:57 am

Here is an example of a CREATE ALIAS command in SQL. You can run this in the iSeries Navigator’s Run SQL Scripts window, or in STRSQL from the command line. STRSQL has a prompt for CREATE ALIAS that is very intuitive.

CREATE ALIAS QGPL/MYALIAS FOR QGPL/MULTI_MBR_FILE (MBR_NUM_2)

You can create metadata on an Alias as easily as you can on a regular table. The next section describes how to create DB2 Web Query metadata.

The heritage file adapter also has the limitation of only being able to join on key fields. If you try to join on non-key fields using the multi-member file adapter, you will get an error as shown in Figure 3-15. This may provide extra incentive to create an Alias and use the DB2 for i5/OS adapter.

Figure 3-16 Error message joining on non-key fields

What will happen to my metadata if my i5/OS object changes? If you make changes to the format of the underlying i5/OS object, such as adding a field to a file, you will not be able to use these changes in a DB2 Web Query report until the metadata is recreated. If you do not wish to use the change in a DB2 Web Query report, the old metadata will still work for the current report.

What will happen to my metadata if I delete my i5/OS object?If you delete the underlying table or QRYDFN object, the DB2 Web Query report will not be able to run based on the metadata alone. If you attempt to run the report in DB2 Web Query, you will get an error. You have the option of recreating the table or QRYDFN exactly as it was before so you will not need to recreate the metadata. Or if you create a new, yet slightly different object, you must create new metadata on that.

3.4.4 Metadata creation supports referential integrity

In this section we will explain the benefits to DB2 Web Query when you have referential integrity defined in the database. First let’s start explaining briefly what is referential integrity.

What is referential integrity?A feature of a relational database is that it must support the definition and enforcement of referential integrity. If you do not fully grasp what referential integrity means, you are definitely not alone. A database can consist of one large fact table and several smaller dimension tables. The dimension tables each contain a primary key that is referenced by a foreign key in the fact table. For our example, the primary key on the Inventory table is PROD_NUM and the corresponding foreign key on the Order table is PROD_NUM. An entry in the fact table is not allowed unless there is a matching key in the dimension tables. Now here it is in everyday terms. You are not allowed to place an order for a product that is not confirmed to be in your inventory. The referential constraint will not permit an entry into the Orders table unless the entry has a value for PROD-NUM also exists in the Inventory table. This prohibits unmatched, or “orphan”, entries in the Orders table.

40 DB2 Web Query for System i

Page 59: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch03.fm

What is the benefit of using referential integrity in DB2 Web Query?When DB2 Web Query creates metadata, it can recognize files that are related through referential integrity and bring them all in together in one piece of metadata. So when you go to write your report, you select a single synonym or table name that actually includes several files all related to each other. You will not need to manually define all the table joins. In order to have this convenience, you must have constraints defined on your tables.

If you do not currently have referential integrity in your database, it is strongly recommended that you consider implementing it. Not only does it aid in more effective report writing in DB2 Web Query, but it moves your business logic closer to the database level so as to reduce programming effort. You do not need to understand SQL to add constraints to your database, you can do this easily in iSeries Navigator. Referential Integrity constraints can be added to files created with DDS and CRTPF or to tables created with the CREATE TABLE statement.

Following is a brief example of how to set up referential integrity on our sample QWQCENT database. The table Orders is the fact table. The tables Inventory, Plant, and Stores are the dimensional tables. For our example we will set up referential integrity between the Orders table and the Inventory table. An item must exist in Inventory before it can have a “child” in Orders.

First we must create a primary key in INVENTORY, then we can create the foreign key in ORDERS. The relationship between the two is called a referential constraint. The referential constraint starts at the child table and ensures no child entry is inserted into the table unless an entry exists in the parent table.

Create a primary key on INVENTORY field PROD_NUM1) Open iSeries Navigator.

2) Expand the database container.

3) If the Century(QWQCENT) database is not currently displayed, right click on “Schemas” and then “Select Database to display.” A window will appear as in Figure 3-15. Type Century into the dialogue box and click Add. Then click OK.

Tip: You can also think of the small dimension tables as “parent” tables, and the large fact table as “child” table. Do not let the part about the child table being larger confuse you. Think of it as a parent will have many children. The constraint does not let the child be born unless the parent already exists.

Tip: If you want to add constraints using the command line, you can use ADDPFCST. If you want to add constraints using SQL you can use CREATE TABLE or ALTER TABLE.

Chapter 3. DB2 Web Query Fundamentals 41

Page 60: DB2 Web Query for System i

7214ch03.fm Draft Document for Review October 10, 2007 9:57 am

Figure 3-17 Select Schemas to display

4) After you have added Century to the displayed Schemas, expand the QWQCENT database and click on Tables. In the right pane, right click on the Inventory table and select Definition. This is shown in figure 3-16.

Figure 3-18 Definition of a Table

42 DB2 Web Query for System i

Page 61: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch03.fm

2) Click on the Key Constraints tab and then click Add. Click the Primary Key radio button. Select the field ProductNumber and click on the Add arrow button. Your screen should look as in figure 3-17. Then click OK.

Figure 3-19 Key Constraints window

3) Click OK one more time as in figure 3-18.

Figure 3-20 Key Constraints window

You are now finished created the primary constraint on Inventory table. Next, we will go to the Orders table and create our referential constraint. Remember, the Orders table will be checking the Inventory table to ensure any new record also has a matching key value in Inventory.

Chapter 3. DB2 Web Query Fundamentals 43

Page 62: DB2 Web Query for System i

7214ch03.fm Draft Document for Review October 10, 2007 9:57 am

1) Expand the Century schema and click on Tables. Go to the Orders table, right click, and select Definition.

2) Click on the Foreign Key Constraints tab. Click Add.

3) Go to the Table Name drop down box and select Inventory. Then go to Available Columns and click ProductNumber. We know this is the primary key on Inventory table because the screen says so in the top right under Key Columns. After you have selected the foreign key, click Add. Then click OK. These steps are shown in figure 3-19.

Figure 3-21 Foreign Key constraint

You are now finished creating the referential constraint between the Inventory and Orders tables. You may now repeat this process with the two other dimension tables, Stores and Plant. The key fields on those tables are, respectively, Store_Code and Plant_Code. The Orders table has the corresponding foreign key for each table, just as it did for the Inventory table.

Once you are done creating the other 2 referential constraints, your database is now ready for the metadata creation.

Creating Metadata on tables with referential integrityThe process to import a “cluster” of related tables into one piece of metadata is quite similar to creating a single piece of metadata. Review figures 3-9 through 3-13 of this chapter. After you have selected create synonym and submitted your library name, notice the check box at the top of the page that says “With foreign keys”. This is the difference in the process. You must check this box so that the related tables will be included in the same piece of metadata. This is shown in figure 3-20.

Then, the only table you need to select is the fact table, which in our case is the Orders table. The dimension tables will be automatically included. Then click Create Synonym. You may check all the related tables if you want to, but the final metadata creation will be the same.

44 DB2 Web Query for System i

Page 63: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch03.fm

Figure 3-22 Creating metadata with Referential integrity

After you click Create Synonym, you will see a success screen as in figure 3-21. Note there is only one piece of metadata. You can close out this box.

Figure 3-23 Created successfully message

When you are first starting to write the report based on the file cluster, you will be presented with the metadata box. The related files will all be under one name, it will say “Cluster for table yourFactTable. You can see this in Figure 3-24. So you know when you see the word “Cluster” in your metadata, referential integrity has been used to create that metadata. All the related dimension tables with referential constraints defined will appear in Report Assist.

Chapter 3. DB2 Web Query Fundamentals 45

Page 64: DB2 Web Query for System i

7214ch03.fm Draft Document for Review October 10, 2007 9:57 am

Figure 3-24 Cluster - Metadata with Referential integrity

When you are creating a report the list of columns can be presented alphabetically or by segment. In our case segment means table. See Figure 3-25.

Figure 3-25 Field selection sorted by table

46 DB2 Web Query for System i

Page 65: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch03.fm

3.4.5 Setting up a cross system join

The base version of DB2 Web Query provides the ability to access tables and views on remote systems. This means that you can create reports against data that resides on the following:

� The local system

� A remote System i or logical partition (LPAR)

� A combination of both of the above

This feature provides the foundation for creating a report with a federated or cross system join: a join in which the underlying base tables reside on multiple System i machines. The restriction here is that all databases (both local and remote) must be DB2 for i5/OS - if you want to access data on another platform such as DB2 for LUW, you will need to acquire the specific add-on data adapter for that database.

The following steps describe how to create a connection to a remote DB2 System i. If you already have a remote database defined already via WRKRDBDIRE, you may skip steps 1-5 below.

1. Open iSeries Navigator

2. From iSeries Navigator window, expand the desired connection name

3. Under the expanded connection, right-mouse click Databases → New → Relational Database Directory Entry as shown in Figure 3-26.

Figure 3-26 Series Navigator Create new Relational Database Directory Entry

4. From the Add RDB Directory Entry (ADDRDBDIRE) window, specify the following.

– Relational database

The logical name to assign to the Relational database. This is usually the name of the remote system or partition.

– Remote location name or address

Chapter 3. DB2 Web Query Fundamentals 47

Page 66: DB2 Web Query for System i

7214ch03.fm Draft Document for Review October 10, 2007 9:57 am

Either the fully qualified system/partition name or the IP address.

– Remote location type

The protocol being used to communicate between the two systems/partitions. In most cases, you will specify *IP for this setting.

When you are finished it should look similar to the example shown in Figure 3-27.

Figure 3-27 iSeries Navigator Add RDB Directory Entry screen

5. Click OK.

6. Open your web browser to the DB2 Web Query console on port 4066. (for example, http://rchm199b.rchland.ibm.com:4066/webconsole

7. Select Data Adapter from the menu bar.

8. From the Configuring Data Adapters page, click on DB2 cli and select Add connection as shown Figure 3-28.

Note: Using the CL command ADDRDBDIRE is also an option.

48 DB2 Web Query for System i

Page 67: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch03.fm

Figure 3-28 DB2 Web Query Add connection to Data Adapters

9. From the Add Connection for DB2 for i5/OS page, specify the following:

– Connection Name

Logical name used to identify this particular set of connection attributes. This is usually the remote system or partition name, but is does not have to match any value specified during the Add RDB Directory Entry process described above.

– Datasource

The DB2 database name that will be used for this connection. This must match the Relational Database value specified during the Add RDB Directory Entry process described above.

– Security

There are three methods by which a user can be authenticated when connecting to an DB2 database server:

• Explicit

The user ID and password are explicitly specified for each connection and passed to DB2, at connection time, for authentication.

• Password Passthru

The user ID and password received from the client application are passed to DB2, at connection time, for authentication.

• Trusted

The adapter connects to DB2 as a Windows login using the credentials of the Windows user impersonated by the server data access agent.

– User

For Explicit only, the i5/OS user profile.

– Password

For Explicit only, password associated with the specified i5/OS user profile.

When you are finished it should look similar to the example shown in Figure 3-29.

Chapter 3. DB2 Web Query Fundamentals 49

Page 68: DB2 Web Query for System i

7214ch03.fm Draft Document for Review October 10, 2007 9:57 am

Figure 3-29 DB2 Web Query Add Connection for DB2 for i5/OS

10.Click the Configure button

Now that the remote connection has been defined, you are ready to create the synonyms for the remote tables or views that you want include in your reports.

11.From the DB2 Web Query Data Adapter page, left-mouse click on the remote connection and select Create Synonym as shown in Figure 3-30.

Figure 3-30 DB2 Web Query Create Synonym

12.From the Select Synonym Candidates for DB2 for i5/OS page, select Tables and Views under Restrict object type to and specify the name of the Library (schema) that contains the database objects that you want to include in the cross system join. An example is shown in Figure 3-31

50 DB2 Web Query for System i

Page 69: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch03.fm

Figure 3-31 DB2 Web Query Select Synonym Candidates

13.From the Create Synonym for DB2 for i5/OS page, specify the prefix (recommended format is “connectionName_libraryName_”) and select the tables and/or views that you want to include in the cross system join, as shown in Figure 3-32. Click Create synonym button.

Figure 3-32 DB2 Web Query Create Synonym for DB2 for i5/OS

Now that the synonym for the remote table has been created, you are ready to include the table in your reports using a cross system join.

14.From the DB2 Web Query home page, select Report Assistant under the desired folder.

15.From the Select from available database descriptions dialog, find and select the synonym for the local table (do not select remote synonym just yet)

16.From the Report Assistant page, select the Join options tab.

17.From the Join options tab, click New.

Chapter 3. DB2 Web Query Fundamentals 51

Page 70: DB2 Web Query for System i

7214ch03.fm Draft Document for Review October 10, 2007 9:57 am

18.From the Select from target database description dialog, find and select the synonym for the remote table as shown in Figure 3-33.

Figure 3-33 DB2 Web Query Select target database description

19.As shown in Figure 3-34, specify the following:

– Join Type

– Description

– Instances

– Join fields

Note: For more information on joining tables see the Report Assistant Tutorial section “Information Only: Joining tables” on page 94

52 DB2 Web Query for System i

Page 71: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch03.fm

Figure 3-34 DB2 Web Query specify join options

20.At this point you can finish the report by specifying the desired options such as Sort by and Sum as shown in Figure 3-35. All of the fields from the joined files will appear in the list of fields to select from. Notice that the fields are color coded to clearly identify which files they originated from. See Chapter 5, “Report Assistant” on page 63 for more details on report writing.

Figure 3-35 DB2 Web Query specify Field selection

Chapter 3. DB2 Web Query Fundamentals 53

Page 72: DB2 Web Query for System i

7214ch03.fm Draft Document for Review October 10, 2007 9:57 am

3.5 The first steps for a report basic user

Ensure you have read section 3.2, “Logging in” and are logged on to the DB2 Web Query home page. You will only see the domains that you are authorized to. If you do not see a domain that you need, contact your DB2 Web Query administrator.

How to run a reportExpand the domain and then expand the Reports folder. There will be subfolders inside this report to categorize the reports within the domain. After expanding the subfolder, simply double click on the report you want to run. You will see a “Processing Request” screen while your results are being retrieved from the server. Then the results will appear in the right panel of your screen.

Figure 3-36 Running a report

Restriction: Keep in mind that the results of your report are literally returned to your PC and stored in your browser. This will affect the time for your results to appear. If your report returns several thousands of records, you will notice more delay than if your report returns ten records. If you think the report returns more records than you can actually use, ask your developer to limit the number of records returned to you.

Attention: It is recommended that you limit the number of records returned to 15,000 if you are using the Firefox browser and only 5,000 records if you are using Internet Explorer. More than this can cause the browser to fail.

54 DB2 Web Query for System i

Page 73: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214p02.fm

Part 2 Tutorials for DB2 Web Query

Part 2, “Tutorials for DB2 Web Query” and Part 3, “Tutorials for DB2 Web Query Optional Features” of this book are structured as basic tutorials. These examples are not intended to replace reference manuals or customer education classes. The intent is to provide some hands on exercises that will get you started and demonstrate some of the more common reporting techniques.

Chapter 4, “Tutorials: Getting Started” on page 57 lays the groundwork for the following tutorials. In Chapter 4 we will tell DB2 Web Query about the tables we are going to use in future chapters and setup security. If this has already been done for you, you can go straight to Chapter 5, “Report Assistant” on page 63.

The tutorials will all use tables in the QWQCENT library. This library may also be referenced as the “Century” library. Century is the ficticious electronics company referenced throught these tutorials. Specifically we will be using the following tables:

� ORDERS

� INVENTORY

� PLANT

� STORES

Orders is the central table. It contains foreign keys or links to the other three tables. In our examples you will see that we only ever directly refer to the Orders table. Thanks to DB2 Web Query’s knowledge and understanding of DB2 for i5/OS the other three tables are automatically made available whenever ORDERS is referenced.

Part 2

© Copyright IBM Corp. 2007. All rights reserved. 55

Page 74: DB2 Web Query for System i

7214p02.fm Draft Document for Review October 10, 2007 9:57 am

Figure 3-37 Map of tables in QWQCENT - Century library

In DB2 for i5/OS the following foreign keys are defined in the ORDERS table.

� ProductNumber is the key to the INVENTORY table

� StoreCode is the key to the STORES table

� PlantCode is the key to the PLANT table

56 DB2 Web Query for System i

Page 75: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04SetupTutorials.fm

Chapter 4. Tutorials: Getting Started

This chapter sets up the System i and the user profiles in preparation for the tutorials that follow. Many of the steps in this chapter were explained in more detail in Chapter 3, “DB2 Web Query Fundamentals” on page 25. They are included here to give you complete step by step instructions and to enable the Tutorials to stand alone. For more understanding behind items such as the security, domains and href’s please refer to Chapter 3.

4

© Copyright IBM Corp. 2007. All rights reserved. 57

Page 76: DB2 Web Query for System i

7214ch04SetupTutorials.fm Draft Document for Review October 10, 2007 9:57 am

4.1 Initial Setup

1. Before starting the tutorials you have to register your user profile as a valid licensed DB2 Web Query user. To do this run the following command.

CALL QWEBQRY76/WQADDLIC ‘USERPROFILE’

USERPROFILE references your System i user profile name and must be specified in upper case letters.

For more details on registering and removing users see “Registering named users” on page 26.

2. When you install DB2 Web Query the system creates a group profile named MDUNTITLED. To create reports in the Common Domain you need to be a member of either the MDUNTITLED. As a member of the MDUNTITLED group you will be authorized to create new reports in the default Common domain. For more details on security and authorizations see 3.3.3, “Assigning authority to users” on page 32

3. Start up a browser. Both Internet Explorer and Firefox have been tested. These tutorials use Internet Explorer.

4. DB2 Web Query uses port 11331. Point your browser to: http://systemi_name:11331/webquery

Figure 4-1 URL to initiate DB2 Web Query

5. Enter your System i userid and password.

Figure 4-2 Initial logon screen

You will be presented with the main DB2 Web Query home page.

Note: Being a member of the MRADMIN group instead of MDUNTITLED would also have worked for these tutorials. The MRADMIN group profile allows a user to create new reports in all domains and also to create new domains. This additional authorization is not required for the tutorials.

58 DB2 Web Query for System i

Page 77: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04SetupTutorials.fm

Figure 4-3 Common Domain properties

6. The Common Domain is where we will be storing our reports. Right click on Common Domain to see the domain properties. One of the properties will be the href or the system identifier. For the Common Domain this is always “untitled”. By previously including yourself in the group MDUNTITLED you now have developer authority (MD) in the domain UNTITLED.

7. Expand Common Domain and right click on the Reports folder.

8. Create a new folder called Tutorials. This is where we will store all our work.

Figure 4-4 Creating a new folder

Before we can create a report on the System i we need to first tell DB2 Web Query which tables the users will be able to query. DB2 Web Query will then create the metadata or synonyms to describe the selected tables. For more details see 3.4.1, “Metadata” on page 34.

9. Right click on Tutorials and select Metadata.

Chapter 4. Tutorials: Getting Started 59

Page 78: DB2 Web Query for System i

7214ch04SetupTutorials.fm Draft Document for Review October 10, 2007 9:57 am

Figure 4-5 Creating metadata

10.Right click on *LOCAL. This is the System i where the table resides.

11.Select Create Synonym.

Figure 4-6 Creating a synonym

12.Next enter the library where the tables reside. The library we will be using throughout the tutorials is the QWQCENT library.

Note: Although you select a folder to enable the submenu containing metadata, the metadata is not restricted to that folder. Once created, the metadata is system wide and available to all reports.

Tip: If you have other System i’s or LPARs or independent ASPs in your network you can add a connection to these systems and the database names will appear under *LOCAL. Any of these remote DB2 tables are then available for use. These additional databases must be defined in the relational database directory table on the System i.

Note: There are three types of System i objects that you can query with the base DB2 Web Query product.

� DB2 cli refers to the majority of your tables created with either an SQL CREATE TABLE statement or by using DDS and a CRTPF command.

� System i Heritage files refers to older tables that have multiple record types or multiple members. Tables described with this adapter will utilize the OPNQRYF command on the System i. This will then direct the query to the older, and typically slower, database optimizer (CQE).

� Query/400 will import existing Query/400 definitions and convert them to both table and report definitions.

60 DB2 Web Query for System i

Page 79: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04SetupTutorials.fm

13.In this example we are going to remove the check mark from the Views box. This will leave us with a nice concise list containing only our physical files or tables.

Figure 4-7 Metadata creation

14.From the list of tables check the box next to Default synonym name. This will select all the tables currently displayed.

15.Enter a prefix of “Cen_”. The will display the table names to the users as Cen_ALERTS, CEN_ORDERS etc. If you have a long list of table name this is one way of keeping all related tables grouped together.

16.Check the “With foreign keys” box. This is the option that will bring in all tables directly related through Referential Integrity and foreign key support. For more details on foreign key support see 3.4.4, “Metadata creation supports referential integrity” on page 40.

Note: If you have created SQL views or logical files and you wish to query them, you would need to leave Views checked. If this library is an SQL collection or schema, selecting Views will also display all the SQL catalog views in the library.

Chapter 4. Tutorials: Getting Started 61

Page 80: DB2 Web Query for System i

7214ch04SetupTutorials.fm Draft Document for Review October 10, 2007 9:57 am

Figure 4-8 Creating QWQCENT metadata

17.Click the Create synonym button.

Figure 4-9 Synonym creation completion

You have now authorized your user profile to create tables in the Common Domain. You have created a folder to store all your work in called Tutorials and you have defined all the tables we will be querying to DB2 Web Query through the create synonym process.

It is time to get started.

62 DB2 Web Query for System i

Page 81: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

Chapter 5. Report Assistant

Report Assistant provides an intuitive, graphical interface with drag-and-drop functionality. It enables you to quickly create a report in which you can sort your data, include record selection criteria, add headings, footings, subtotals, page-breaks, apply a style template and more. When you use Report Assistant, DB2 Web Query creates a styled report that you can deploy on the Web without the necessity of learning the complexities of any reporting language. With DB2 Web Query you can specify input parameters to allow end users to easily subset or filter their reports. Report Assistant supports output to many different file types including PDF files, MS Excel and DB2 database files. Report Assistant's tight integration with MS Excel includes the real-time creation of Excel spreadsheets with full styling, drill-downs, and formula capabilities. This allows Excel power users to analyze their corporate data in a tool with which they are already familiar.

Many of the reports created in this chapter are prerequisites for the enhanced features discussed later in this book. Active Reports, which is for users who are not connected to the System i, and OLAP enabled reports, are both based on existing reports created in this Report Assistant chapter.

This chapter goes into detail about basic functionality that is common among the various DB2 Web Query components.

For more details on the various options not discussed in the tutorials please use the help text or see the reference manual “IBM DB2 Web Query for System i”.

5

Tip: If you have Developer Workbench installed you will find the help text accessed via that product to be more extensive than the help text accessed via Report and Graph Assistant.

© Copyright IBM Corp. 2007. All rights reserved. 63

Page 82: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

5.1 Report Assistant Tutorial

In this tutorial we will create the two reports shown below Figure 5-1. The first report is a simple summary showing revenue by product type. The second report will be a more detailed report calculating gross profit for each product category within a specific user requested product type. Finally we will enable a user viewing the initial summary report to click on product type and automatically drill down to see the more detailed gross profit report.

At the end of this chapter is a section demonstrating how to join two tables if you haven’t previously defined the relationship via DB2 foreign key support. This section is for your reference only and will not actually be part of the tutorial.

Figure 5-1 Final drill down reports

5.2 Creating a summary report (RA1_Revenue)

Our first task is to be able to show the product revenue for each product type. We will be using the Century database that is shipped with DB2 Web Query in library QWQCENT. Instructions on creating the metadata defining this database to DB2 Web Query can be found in Chapter 4, “Tutorials: Getting Started” on page 57. This must be completed prior to continuing.

1. Right-click on the Tutorials folder where you will be storing your report and select “Report Assistant” This will bring up a list of available tables for you to query.

Note: Depending on the number of tables that have previously been defined to DB2 Web Query your list may only contain one table or it may contain many tables.

64 DB2 Web Query for System i

Page 83: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

Figure 5-2 Report Assistant initial table selection

2. Select the CEN_ORDERS table. You can tell from the word Cluster in the description that this single definition covers multiple tables without requiring external joins.

5.2.1 Defining a report layout

After you have chosen the CEN_ORDERS table you will be presented with a list of all the column or field names. As discussed in section 3.4.4, “Metadata creation supports referential integrity” on page 40 note that the displayed fields in the Field selection list come from various tables. These tables were automatically brought in by DB2 Web Query when the Foreign key option was selected during the creation of the Orders synonym or metadata. This results in the composite list of available fields.

3. To see the actual table or segment names drag the sides of the window to widen it.

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.

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.

Tip: Typing the first character of the table name will jump to the tables starting with that character. In, “Prefix and Suffix - optional yet recommended” on page 38n it was recommended that when you define your tables (create synonyms) to DB2 Web Query, you add a prefix to the tables so that they are logically grouped, for example by subject area or collection or library.

Note: You can choose to view your field names alphabetically regardless of which table they originated from or you can view the fields for each table separately. Immediately above the field list are three icons, the first being a calculator icon. Beside the calculator is the dimension or hierarchy icon which will show the fields within each individual table. The next icon, the list icon, will show all the fields from all the tables in one long alphabetical list.

Tip: If you are using the Firefox browser you may not be able to drag and drop your fields. In this case you will need to highlight the column you want to insert in your report and then click on the “add field” icon in the appropriate box i.e. Sort by, Sum etc. where you want the field moved to.

Chapter 5. Report Assistant 65

Page 84: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

Figure 5-3 Report Assistant field selection

6. Check the “Add grand totals to the end of the report” box.

7. Now select the Run arrow for your first report.

Figure 5-4 Initial Summary Report

Well that was very fast. It was easy to actually answer the question posed about the total revenue by product type but we know that we can make this report look nicer and more meaningful for our end users.

8. Save your report and name it “RA1_Revenue”.

Figure 5-5 Report Assistant save as menu

Tip: If an alpha field had been used instead of LINETOTAL the default sum option would have displayed the value of the alpha field in the last record for each sort group or product type.

66 DB2 Web Query for System i

Page 85: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

5.2.2 Sum and detail reports

First let’s look at the difference between the Sum and Print options on the initial Field selection tab. By default we selected Sum which produced our initial summary report. As requested this report was aggregated on PRODUCTTYPE. Selecting Print would have turned off the aggregation and produced a detail report.

9. Before you actually run this as a detail report you should limit the number of records you want to read. There are more than 32,000 detail records in the orders file. We don’t need to retrieve all these simply to make a point. Under the Report options tab enter 100 for the number of records to read.

Figure 5-6 Report Assist limit records read

10.If you then return to the Field selection tab and select Print instead of Sum and then Run you will see the following report.

Figure 5-7 Report Assistant detailed print report

11.As you can see the Sum option sums or aggregates field values based on your sort column and consolidates the records. The Print option is for a detail report which will include one row for each selected record. Since we want a summary report select the Sum option again and remove the 100 record limit.

We now want to dress the report up a little.

12.Highlight the LINETOTAL field in the Sum, Print box and select the “Show - Field options - LINETOTAL” arrow near the bottom of the screen.

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

Chapter 5. Report Assistant 67

Page 86: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

you have additional capabilities to control the sort, add ranking columns, and control the subheadings and subfooting.

Click the ellipsis or three dots next to the format window.

Figure 5-8 Report Assistant field Options

13.Change the LINETOTAL field to be displayed with commas and a floating dollar sign.

Figure 5-9 Report Assistant change format dialog

14.On the Field selection tab ensure that LINETOTAL is highlighted, select the Show - Field options drop down arrow, choose the Title tab.

68 DB2 Web Query for System i

Page 87: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

Figure 5-10 Report Assistant new column headings

15.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 DB2’s 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 on the right.

17.Open the Show - Field options dialog if it is closed and select Count from the “Calculated as” drop down box.

Figure 5-11 Report Assistant field calculation options

18.Change the field format to integer seven with commas using the ellipsis button.

19.Select the Title tab.

20.Change the heading to “Order” “Count” on two lines.

Note: If you don’t 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.

Chapter 5. Report Assistant 69

Page 88: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

Figure 5-12 Report Assist column heading for count field

21.Using the up and down arrows in the Sum, Print box move CNT.ORDERNUMBER above LINETOTAL.

Figure 5-13 Report Assistant field count

22.Using the blue triangle at the top of the screen Run the report.

Figure 5-14 Report Assistant RA1_Revenue report

23.Save your report.

5.2.3 Date formatting (RA2_XTab)

In this next example we are going to select only products sold in the year 2007 and we will add the quarter that the products were sold in across the top of our report.

70 DB2 Web Query for System i

Page 89: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

To do this easily we first want to create two new fields based on ORDERDATE. One field will contain the quarter and the other field will contain the year.

24.If you have closed your report open the Tutorials folder on the DB2 Web Query home page, right-click on the RA1_Revenue report and select Open.

25.From the field selection list click on calculator icon to define a new field.

26.Give the new field the name Quarter and select a format of Q. Either select or type in the date field name ORDERDATE. The name must be in upper case letters. This will extract the quarter from ORDERDATE. Click OK.

Figure 5-15 Report Assistant defining a date quarter

27.Repeat the process creating a field called Year from ORDERDATE with a format of YY.

Figure 5-16 Report Assistant creating a date year field

5.2.4 Selection criteria

We are going to filter this report and select only year 2007.

28.Go to the Selection criteria tab.

29.From the Selection criteria tab drag and drop Year from the field list onto the white palette on the right.

30.From the first drop down box select WHERE.

31.Select EQUAL to.

32.Click on “Select values”.

Note: The new fields quarter and year will be available only in the current report. See section 12.1.1, “Date Decomposition” on page 228 for how to modify the metadata and make these fields available globally. This will require the optional “Developer Workbench” feature.

Note: DB2 Web Query handles dates in a very intelligent manner. The problem is that a lot of this information, including the various date formatting options is not well described in the help text. For this reason details on working with dates has been added in the appendix “Date and Time System Variables” on page 322.

Chapter 5. Report Assistant 71

Page 90: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

Figure 5-17 Report Assistant Selection criteria

33.Select the Values radio button.

Figure 5-18 Report Assistant selection values

34.After selecting the Values button DB2 Web Query will look for all distinct values in this field and present them in a list. Select 2007 and press OK.

Note: Although we 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.

WHERETOTAL does the comparison after the records have been retrieved, sorted and aggregated. The selection is done on the aggregate value of the column.

i.e. 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.

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.

Tip: With DB2 Web Query you can store a list of products/regions/customers etc. that you are specifically interested in on your local PC. This list can be stored in a text file or in MS Excel. If you select the wizard icon next to the Constant prompt you will be able to browse your local PC. The values in that file then become the filter for your query.

72 DB2 Web Query for System i

Page 91: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

5.2.5 Cross Tab report (RA2_XTab)

35.Drag and drop Quarter into the Sort across box.

Figure 5-19 Report Assistant Sort across

36.Run your report.

Figure 5-20 Report Assistant sort across output

37.Save the report as RA2_XTab and close it.

5.2.6 Creating a Sample Detail Report (RA3_GP)

In this section we will create a parameterized report where the user will select, at run time, the product type they wish to query. We will also be able to drill directly to this report from the RA1_Revenue report we initially created.

1. Right-click on the Tutorials folder and choose Report Assistant.

2. Select table CEN_ORDERS.

Tip: If your report only shows two quarters you probably forgot to remove the 100 record limit. See point 11 on page 67.

Chapter 5. Report Assistant 73

Page 92: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

Figure 5-21 Report Assistant file selection

3. Drag and drop PRODUCTTYPE, and PRODUCTCATEGORY into the Sort by box.

4. Drag and drop LINETOTAL, and COSTOFGOODSSOLD into the Sum, Print box.

5. Using the ellipsis button, add commas to the formatting of LINETOTAL, and COSTOFGOODSSOLD.

6. Check the “Add grand totals to the end of the report” box.

Figure 5-22 Report Assistant field selection for detail report

Define and compute fields7. Select the calculator icon above the field list to create a define field. We are going to

create a gross profit field by subtracting the COSTOFGOODSSOLD from the LINETOTAL.

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 wizard’s wand. This allows you to create a compute field. In this case the field isn’t calculated until after the data is sorted and all aggregation is complete. Compute fields are often required for percentages and variances.

74 DB2 Web Query for System i

Page 93: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

Figure 5-23 Report Assistant new define field

8. There are three icons to the right hand side . The first two icons display the list of fields in various formats including alphabetically and in a hierarchical structure. The function icon is used to display the precoded functions that are available. Try the different buttons.

9. Enter a new field name of Gross_Profit.

10.Select the list icon. This will display the list of available field names alphabetically.

11.Create the formula LINETOTAL - COSTOFGOODSSOLD by double-clicking the field names and using the “-” button on the calculator pad or on your keyboard.

12.Select the Format button and define your field as being an integer, 10 long, with commas and a floating dollar sign.

Figure 5-24 Report Assistant creating a defined field

13.Select OK and then drag and drop your new field Gross_Profit into the Sum, Print box.

Tip: Field names in the defined field definition panel must all be in upper case.

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.

Chapter 5. Report Assistant 75

Page 94: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

Figure 5-25 Report Assistant formatting gross profit

14.Verify that the Gross_Profit field is highlighted. Next we need to click the Show - Field options arrow near the bottom of your screen. Select the Title tab.

15.Label the column “Gross” “Profit” (two lines).

Figure 5-26 Report Assistant Show - Field options

Tip: There are times when you are creating one define field based upon a second define field. DB2 Web Query processes the defines in the order they are entered into the system. The define field must already exist before it can be used in a secondary calculation. For more details on viewing the define order of the fields see Appendix C, “Define and Compute fields processing differences” on page 329.

Note: If you define your DB2 tables and specify long names or aliases or column headings, DB2 Web Query will use them.

Tip: The IF THEN ELSE constructs allow you to use logic when creating virtual fields. For example if you wanted to create your own count of the number of items sold in 2007 you could create a virtual field and use the formula “IF Year EQ 2007 THEN 1 ELSE 0”. DB2 Web Query prefers using “EQ” instead of “=”.

76 DB2 Web Query for System i

Page 95: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

5.2.7 Conditional styling (Traffic lighting)

What we want to do next is highlight the gross profits that are $25,000,000 or more.

16.Highlight Gross_Profit in the Sum panel and open the Field options box.

17.Select the Display tab and then the Conditional styling button.

Figure 5-27 Report Assistant Conditional styling option

This will bring up the conditional styling dialog box.

18.Selecting the wizard icon in the conditional styling dialog will lead you to a screen where you can define various filters or conditions for which you want to test your data.

Figure 5-28 Report Assistant Conditional styling dialog

19.Enter the name High_Profit for this condition, select your test field Gross_Profit, and choose the greater than or equal to relationship. Enter a value of 25000000 (25 million).

Figure 5-29 Report Assistant edit condition dialog

Note: The Conditional styling dialog allows you to compare Gross_Profit to another field in your table. If you select the Values button you will be presented with a list of distinct values in the Gross_Profit column.

Chapter 5. Report Assistant 77

Page 96: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

After pressing OK you will be able to enter another condition. For example, you might want to create a condition called Low Profit. This would allow you to “traffic light” your report and have the high and low profits show up in different colors.

20.From the list of conditions highlight the one that your are interested in, High_Profit, and then click the add (+) icon on the right side of the screen to attach the condition to the Gross_Profit column. That was the column we started with when we pressed the conditional styling button.

Figure 5-30 Report Assistant attach conditional styling

Next we want to define the formatting of the Gross_Profit field when it meets the High_Profit condition.

21.Select the Font button.

22.To make this excellent profit standout we want to highlight it by choosing the Bold style and green for the background color. Press OK twice to return to the main reporting screen.

Figure 5-31 Report Assistant styles dialog

5.2.8 Using variables in report headings/footings

23.Select the Report headings tab. Enter “Gross Profit by Product Category” for the Page Heading and “Prepared on &DATE at &TOD” for the page footing.

Note: Now that you have created a condition you need to “attach” it to your column for it to take effect. You may create one condition and attach it to multiple columns. For example, in a high profit situation you might want every column in the report to be highlighted.

Tip: For more information on using date and time variables within DB2 Web Query see “Date and Time System Variables” on page 322.

78 DB2 Web Query for System i

Page 97: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

Figure 5-32 Report Assistant page headings and footings

24.Run your report

Figure 5-33 Report Assistant high profit report

Notice the high profit items jumping out at you.

Note: DB2 Web Query ships with a default style sheet that automatically formats headings and footings. To control the report formatting yourself you need to remove the default style sheet under the Report options tab.

Chapter 5. Report Assistant 79

Page 98: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

25.Save your report as RA3_GrossPft.

5.2.9 Generating subtotals

Next we want to generate subtotals for each product type.

26.Highlight PRODUCTTYPE, make sure that the Show - Field options panel is displayed and check Subtotal numeric sum/print fields.

Figure 5-34 Report Assistant subtotals

27.Run your report again.

Figure 5-35 Report Assistant subtotalled report

28.To change the default subtotal heading make sure that PRODUCTTYPE is highlighted. Go to the Field options display and select the new Subtotal tab.

29.Type your new subtotal heading “Subtotal for “. Make sure that you leave a blank at the end as DB2 Web Query will append the Product Type to your heading.

80 DB2 Web Query for System i

Page 99: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

Figure 5-36 Report Assistant new subtotal headings

30.Run the report.

Figure 5-37 Report Assistant report showing new subtotal headings

5.2.10 Sorting by an aggregate field

As per usual, once your users see what they asked for they want something different. Instead of product category within product type sequence we are being asked to sort by gross profit within product type.

31.If you look at the Show - Field options panel for Gross_Profit you will see that there is not a sort tab.

32.You need to drag Gross_Profit from the list of available fields into the Sort by box and move it up below PRODUCTTYPE.

33.In the Show - Field options panel go to the Sorting tab and check the Total box. If you don’t you will be working with individual gross profit records instead of the aggregate or total of gross profit by product type

Tip: By default all columns are Summed 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 under “Sum”.

Chapter 5. Report Assistant 81

Page 100: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

Figure 5-38 Report Assistant adding additional sort criteria

If we did nothing else your report would now contain the Gross_Profit column twice.

34.Select the Display tab and make Gross_Profit invisible.

Figure 5-39 Report Assistant make field invisible

35.Select the Sorting tab and choose descending sequence.

36.Save your report.

37.Run the report.

Tip: You might want to quickly try your report without checking the total box. You will see that the report contains detail records instead of summary records. You should remember that what you did was forget to check Total. It will happen to you.

82 DB2 Web Query for System i

Page 101: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

Figure 5-40 Report Assistant sorting by a sum field

Notice that the records within each product type are in descending sequence by gross profit instead of product category.

5.2.11 Adding Ranking Columns (RA4_Advanced)

We have now been asked to show the gross profit ranking within product type.

38.Highlight Gross_Profit in the Sort by panel, display the Show - Field options display at the bottom of the screen if it isn’t on view, choose the Ranking tab, check the Add Ranking column and enter a column heading of “Gross” “Profit” “Rank” (three lines).

Figure 5-41 Report Assistant ranking

39.Save your report as RA4_Advanced.

40.Run your report

Tip: If you wanted to produce a “Top 10” report use the ranking capability. From the Ranking tab you would limit your ranked values to 10.

Chapter 5. Report Assistant 83

Page 102: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

Figure 5-42 Report Assistant with ranking column

5.3 Output options

Let’s experiment with a few of the other Report options within DB2 Web Query. The first one will be on-demand paging.

5.3.1 On-demand paging

41.Choose the Report options tab and select On-demand paging and rerun your report.

Figure 5-43 Report Assistant On-demand paging

84 DB2 Web Query for System i

Page 103: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

Figure 5-44 Report Assistant On-demand paging output

Our sample report isn’t the best to display the on-demand paging feature. Assume that our report was 201 pages long instead of one page long. 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.

5.3.2 PDF output

So far all our output has been to the screen. DB2 Web Query provides many additional options for output.

42.Select the Report options tab and using the first drop down list select PDF and run the report again.

Figure 5-45 Report Assistant PDF report options

Jump Next Page Search

Note: Users do not require any additional software other than the no charge Adobe Acrobat Reader to create a PDF report. Adobe Acrobat Professional edition is not required.

Chapter 5. Report Assistant 85

Page 104: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

Figure 5-46 Report Assistant PDF Output

5.3.3 MS Excel output

There are multiple choices for output to MS Excel. An excellent option is downloading your report to Excel complete with formulas. With this choice your totals and subtotals and many compute fields are represented as Excel formulas and are not downloaded as static values. This allows these columns to continue to be accurate even after the user modifies the worksheet.

43.You should still be in report RA4_Advanced. Return to the Report options tab and this time in the first drop down list select Excel w/formula and run your report.

Restriction: The above report was generated using an imported style sheet. If your PDF report scrolls onto two pages you have run into a known problem with the default style sheet. This problem is being investigated as the redbook goes to print. Not all style sheets have this problem. See “I have my own stylesheets that I would like to use for my reports. How do I make them available from Report Assistant?” on page 303. This FAQ includes information on how to import style sheets. The above report was created using the “problue.sty” style sheet that is shipped with DB2 Web Query.

Note: DB2 Web Query has the ability to create reports as Excel files. These can be created in two formats, Excel binary (XLS) files, referred to as Excel 97, and the newer XML-based Excel format (XHT), referred to as Excel 2000. Excel 2000 is really the first release that supported XML. DB2 Web Query cannot output directly in MS Excel 2007’s new format. MS Excel 2007 can read the Excel 2000 format.

With the XML-based MS Excel 2000 style sheets can be applied, cells can be formatted, traffic lighting or conditional styling can be passed, calculations can be rendered as formulas, and drill-downs are supported from within the resulting spreadsheet.

86 DB2 Web Query for System i

Page 105: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

Figure 5-47 Report Assistant MS Excel output

44.Notice the total for Audio in cell F9. If you look at the Excel input line you will see that this is represented as a formula as opposed to an actual value of $162,704,821. 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.

5.3.4 DB2 database file output

One final output option we will investigate is creating a DB2 database file on the System i.

45.Under the Report options tab select “Show database formats” in the second drop down box. This will fill in DB2 in the first box. This will also open up a section in the bottom right where you can specify the library and file or table name you wish to create.

Tip: If Gross Profit had been calculated as a compute field instead of a define field it would also have been represented in the MS Excel spreadsheet as a formula.

Note: There are many more output choices. Changing the second drop down list changes the output choices in the first list. If you are not using a style sheet for your output the difference between HTML and HTML with grid is whether or not your reports shows with grid lines between the rows and columns. This option is overridden by your style sheet.

Chapter 5. Report Assistant 87

Page 106: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

Figure 5-48 Report Assistant output to a DB2 database file

This time when you run your report, instead of coming to the screen the records are inserted in the table you specify. After the file insert is complete you will see a new window that tells you how many records were inserted into the DB2 table.

Figure 5-49 Report Assistant DB2 output confirmation

46.Set your output option back to HTML or reload your saved report. We are going to continue on with the last steps of our example.

Tip: You must have imported the metadata / created a synonym for your output table before you can use it as input to another query.

Note: See “Using output files for the next query” on page 255 for recommendations for converting Query/400 definitions that currently create temporary output files in QTEMP.

88 DB2 Web Query for System i

Page 107: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

5.3.5 Parameterized reports

We have been asked to be able to print our RA4_Advanced ranking report for a single product type requested at runtime. To do this we need to add an input parameter.

47.Still in your RA4_Advanced report go to the Selection criteria tab.

48.Drag the PRODUCTTYPE field onto the empty white panel on the right.

49.Choose “Select values” to define your parameter.

Figure 5-50 Report Assistant Selection criteria

50.Select Parameter and then select the Auto Prompt icon .

Figure 5-51 Report Assistant parameter definition

51.Ensure that your selection is Dynamic. Under Description enter the prompt you wish the users to see. We will use the default name for this parameter of PRODUCTTYPE.

Figure 5-52 Report Assistant Parameter Properties

Chapter 5. Report Assistant 89

Page 108: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

To make the drill down report more understandable we are going to put the product type into the report heading.

52.Under the Report headings tab add the words “for Type ” to the heading.

53.Select the Show - Field list arrow and drag PRODUCTTYPE to the end of the heading.

Figure 5-53 Report Assistant variable report heading

54.Finally, since we know that, using the parameter, this will now be a very small report let’s remove the default page numbering. Select the Report Options tab and choose Off in the Page numbering options.

Figure 5-54 Default page numbering

55.Run the report.

Note: Choosing Dynamic selection presents the users with a distinct list of current values of 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 control and shift keys to select multiple product types. For now leave it defaulting to a single input value.

90 DB2 Web Query for System i

Page 109: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

Figure 5-55 Report Assistant output parameter report

56.Save and close this report.

We now have a report that will either accept a parameter passed by another report or will prompt the user for their input.

5.3.6 Drill-down reports - parent report (RA5_Child)

We are going to take our initial RA1_Revenue report and enable it to pass an individual product type to the report we just created.

57.On the DB2 Web Query home page locate the RA1_Revenue report, right-click on it and select Open.

58.In the Sort by box highlight PRODUCTTYPE then open the Show - Field options panel and select the drill-down button.

Figure 5-56 Report Assistant drill-down option

Chapter 5. Report Assistant 91

Page 110: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

59.Select the Execute procedure radio button. DB2 Web Query will populate the list with your reports. Navigate through the list until you find your RA4_Advanced report. Select it.

60.Add a comment for user’s to see when they hover over the Product Type field.

61.Click Add.

Figure 5-57 Report Assistant drill-down dialog

62.Type the same name as the parameter the drilldown report is expecting. In this case use PRODUCTTYPE.

63.Select the field that you want passed into the variable PRODUCTTYPE. Select the field PRODUCTTYPE and click OK.

Figure 5-58 Report Assistant drill-down parameter dialog

64.Run your report.

65.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 detail report. Try it. Drill down (single click) on Audio.

92 DB2 Web Query for System i

Page 111: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

Figure 5-59 Report Assistant parent (summary) and child (drill-down) reports

66.Save your report as RA5_Child.

67.Close the report and close Report Assistant.

5.3.7 Report properties

68.Navigate to the RA4_Advanced report on the DB2 Web Query home page, right-click and select Properties.

The general tab of the properties will show you the creation date, the domain and most importantly the href or file name on disk. The detail tab will show you all the tables and columns used in your query. You will also see your sorting details, filtering criteria, output format and any joins that you might have explicitly defined.

Chapter 5. Report Assistant 93

Page 112: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

Figure 5-60 Report Assistant report properties

CONGRATULATIONS you have finished the first and the longest tutorial. Wasn’t it easy and wasn’t it fun.

5.4 Information Only: Joining tables

You may have noticed that we never actually needed to join any tables together even though we were looking at data from multiple tables. As previously discussed, this is because the tables were defined to DB2 with foreign key constraints.

If the tables either hadn’t had foreign keys defined or you had chosen not to include the foreign keys when you created the metadata, you would have had to create your joins manually. Below is the process you would need to have followed.

After you select your main table to query you would go to the Join options tab to specify any additional tables you want to access.

You need to select a “new” join and highlight the table in the list that you wish to join to. Next you need to define the actual join criteria.

94 DB2 Web Query for System i

Page 113: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

Figure 5-61 Report Assistant join options

You will need to tell DB2 Web Query which field from each table you want to use for your join.

Figure 5-62 Report Assistant join definition

The trick here is to remember to press the Save and Create button. If you forget this and navigate away from this page your join will not be executed.

After you have saved and created the first join definition you can press New and proceed to define a second join if you wish.

Chapter 5. Report Assistant 95

Page 114: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

When you return to the Field selection tab you will see that the fields from both tables are available to be used.

Figure 5-63 Report Assistant secondary table field

Notice that the columns from the secondary table are in a different color than the columns from the primary table. This is a quick visual check to help identify the different source tables.

Note: Join options:

Unspecified

This option was created for compatibility with prior versions. It is recommended that, instead of this choice, you select the appropriate options (Inner Join, Left Outer Join, Multiple Instances, Single Instances).

Inner Join

An inner join combines rows from both tables where there is an exact match between the join fields.

Left Outer Join

Retrieves records from both primary and secondary tables, including all records from the left table (primary) and any records from the right table (secondary) where the condition values match. If there are no matching values in the secondary table, the join still retrieves the records from the host table.

Multiple Instance

A one-to-many join structure that matches one value in the host data source to multiple values in the cross-referenced field. Joining employee ID in a company's employee data source to employee ID in a data source that lists all the training classes offered by that company would result in a listing of all courses taken by each employee, or a joining of the one instance of each ID in the host file to the multiple instances of that ID in the cross-referenced file.

Single Instance

A one-to-one join structure that matches one value in the host data source to one value in the cross-referenced data source. Joining an employee ID in an employee data source to an employee ID in a revenue data source is an example of a unique join.

96 DB2 Web Query for System i

Page 115: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch04.fm

If you select the Tree icon (between the calculator and the spreadsheet) you will see the fields listed in physical sequence by table.

5.5 Report Assistant Summary

You have now completed the first major tutorial and created a few different reports. Many of the remaining chapters take the reports that you have created in this chapter and modify them. Information that is similar between the different components will in some cases, such as joining tables, not be repeated. In other examples the steps will still be listed but in far less detail. If you forget how to accomplish a function simply return to this chapter for your “refresh”. Happy reporting.

Tip: If you switch to tree mode and hover over a field name additional information pertaining to that field appears.

Chapter 5. Report Assistant 97

Page 116: DB2 Web Query for System i

7214ch04.fm Draft Document for Review October 10, 2007 9:57 am

98 DB2 Web Query for System i

Page 117: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch05.fm

Chapter 6. Graph Assistant Tutorial

Graph Assistant provides a wide variety of graph types and graphing functionality to allow users to choose how to present their data in the best possible format. The available graph types range from a variety of bar and line charts through histograms and area charts, stock charts, gauges for key performance indicators and much more.

Additional details on the graphing facility can be found in the help text and in the reference manual “IBM DB2 Web Query for System i”.

In this chapter we will continue on with the same Century database used in the previous tutorials. In this chapter we will:

� Create a simple bar chart showing revenue by product type within country. We will drill down from this graph to the detail report that we created previously with Report Assistant. We will then modify this graph to be a dual axis bar and line chart that will accept country as an input parameter.

� Create a line chart that shows revenue trending over time. The users will be able to specify the time range they wish to see.

� Create multiple pie charts with traffic lighting or conditional styling based on a calculated field.

6

© Copyright IBM Corp. 2007. All rights reserved. 99

Page 118: DB2 Web Query for System i

7214ch05.fm Draft Document for Review October 10, 2007 9:57 am

6.1 Bar chart Tutorial

In this exercise we will initially create a bar chart that allows the user to drill down to a previous report.

Figure 6-1 Completed bar chart with drill down

We will then modify this bar chart to create a dual axis bar and line chart which will accept country as an input parameter.

100 DB2 Web Query for System i

Page 119: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch05.fm

Figure 6-2 Modified chart adding a gross profit line

6.2 Creating a simple bar chart with drill down capabilities (GA1_Bar)

1. Right click on the Tutorials folder and select Graph Assistant

2. Select the same CEN_ORDERS table we used in the previous tutorials.

Figure 6-3 Starting Graph Assistant

Chapter 6. Graph Assistant Tutorial 101

Page 120: DB2 Web Query for System i

7214ch05.fm Draft Document for Review October 10, 2007 9:57 am

3. Click on the graph types drop down and have a 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 chart type and select Clustered as the style. Look at the various different templates. Bumps is quite interesting. This tutorial will use “Cylinder on grey”.

Figure 6-4 Graph Assistant Graph type Selection

Next we want to define the fields representing the x and y axis for the chart.

5. Choose the Field Selection tab.

6. Drag LINETOTAL onto the Sum panel. This will be our Y axis.

7. Drag COUNTRY onto the X axis panel.

8. Drag PRODUCTTYPE into the separate graph area box. By default this would produce one chart for each separate plant.

102 DB2 Web Query for System i

Page 121: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch05.fm

Figure 6-5 Graph Assistant Field selection

6.2.1 Adding multiple bars to one chart

9. Ensure that PRODUCTTYPE is still highlighted in the Graph fields panel.

10.Open the Show - Field options box for PRODUCTTYPE. Select “Merge graphs into a single graph”. Instead of having a graph for each product type this will merge the graphs so that each type is a separate bar within each country.

Graphs can have headings both at the page level and at the individual chart level.

11.Under the Headings tab select the Graph tab. Give your chart the title of “Revenue by Product Type” and the subtitle of “Country Comparison”.

Figure 6-6 Graph Assistant Chart Titles

12.Save your graph as GA1_Bar and then run it.

Chapter 6. Graph Assistant Tutorial 103

Page 122: DB2 Web Query for System i

7214ch05.fm Draft Document for Review October 10, 2007 9:57 am

Figure 6-7 Graph Assistant Revenue by Product Type Chart

6.2.2 Adding a drill down to your chart

Now that we have our chart we would like the users to be able to double click on any of the bars and drill down to the detailed product type report we created earlier.

13.Return to the Field selection tab, highlight LINETOTAL and click the Drill down button. This will present you with the following screen.

Figure 6-8 Graph Assistant Drill down

14.Click Execute procedure and a list of your reports should be populated in the top white panel.

15.Navigate to and select the RA4_Advanced report that you created earlier. Once you have selected your procedure the Add button should become available.Click Add to add the parameter that you will be passing from this report to the RA4_Advanced report.

104 DB2 Web Query for System i

Page 123: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch05.fm

Figure 6-9 Graph Assistant Drill down procedure selection

16.Select the field that you want to pass as the parameter value (PRODUCTTYPE) and then enter the parameter name. This name must match the name that the child report is expecting to be passed. We defaulted our parameter name to equal the input column name of PRODUCTTYPE.

Figure 6-10 Graph Assistant parameter passing

17.Click OK and save this graph and then run this graph.

Drill down explained: When you drill down from one report to another the child report must be expecting a parameter. In our case this was the PRODUCTTYPE parameter that was linked in the gross profit report to the PRODUCTTYPE field. In the parent report or graph you indicate where the users can drill down. In this graph we said that the users could drill down on any LINECODE or bar. When they clicked a bar we told the system that we wanted the RA4_Advanced report to be run. We also indicated that we were going to pass the PRODUCTTYPE field in referenced by the selected bar. We were going do this by passing the value as a parameter called PRODUCTTYPE. Since this is the name of the parameter the Advanced report was expecting it accepts the value and executes the report.

Chapter 6. Graph Assistant Tutorial 105

Page 124: DB2 Web Query for System i

7214ch05.fm Draft Document for Review October 10, 2007 9:57 am

Figure 6-11 Graph Assistant Drill down from chart to report

18.Roll over the bars with your mouse. You should see the cursor changes from an arrow to a hand. The hand indicates that you can drill down in this area. When you hover over a bar you will see information in a small pop up window that shows you all the details about the bar. First you will see the product type, then the country and lastly the revenue or line total.

6.3 Creating a dual axis bar and line chart (GA2_Parm)

In this exercise we will be changing COUNTRY from a set of bars to an input parameter. We will also add gross profit as a line chart on top of our existing bar chart. Gross profit will have its own Y axis. This way we will be able to see the relationship between our revenue and the profit each product generated.

19.If you have closed the bar chart you just created, navigate to the Tutorials folder, locate GA1_Bar, right click on the report name and open it.

First we are going to modify the existing graph slightly.

20.Remove PRODUCTTYPE from the secondary (lower) X axis sort across box by highlighting the entry and using the red X.

21.We want to change COUNTRY on our X axis to be PRODUCTTYPE. You can either delete (X) COUNTRY first or you can simply drag PRODUCTTYPE on top of COUNTRY which will do an automatic replace for you.

Note: In this drill down example we passed the product type to the child report. We could have designed the report to accept both country and product type. If we had done that, when the user clicked on the same bar they could have passed the country name as well as the product type as filters or parameters to the Gross Profit report (RA3_GrossPft).

106 DB2 Web Query for System i

Page 125: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch05.fm

Figure 6-12 Changing X axis columns

Now that we have removed COUNTRY from the chart itself we want to add it in as a parameter.

22.Choose the Selection criteria tab.

23.Drag COUNTRY from the field list to the white space on the right.

24.In this case the defaults of WHERE and EQUAL to are appropriate since we want the user to select or specify a single country.

Click on Select values.

Figure 6-13 Creating a parameter for COUNTRY

25.Select Parameter and choose the Auto Prompt icon.

Note: At any time during development you can click the run button to see exactly what your chart looks like so far. Using the update button on the graph preview is very useful during development. If you have closed your graph preview box go to the Graph Type tab and select Show Graph Preview.

Chapter 6. Graph Assistant Tutorial 107

Page 126: DB2 Web Query for System i

7214ch05.fm Draft Document for Review October 10, 2007 9:57 am

Figure 6-14 Parameter Auto Prompt

26.Change the prompt the user will see to “Select Country:”.

27.For the remainder of the screen select the defaults and press OK.

Figure 6-15 Details about COUNTRY parameter

28.Save your report as GA2_Parm. We just created a simple bar chart that will prompt the user for country. Go ahead and try it. Remember that you can run your report or update the graph preview at any time.

6.3.1 Adding a second Y axis

29.First we need to redefine our graph as one that supports a second Y axis. On the Graph types tab change Clustered to Dual-Axis Clustered.

108 DB2 Web Query for System i

Page 127: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch05.fm

Figure 6-16 Selecting a Dual-Axis graph type

We want to superimpose Gross Profit as a line on top of our existing bar chart. Since Gross Profit doesn’t exist in our field list we will need to create it.

30.Go to the Field selection tab, and click on the calculator icon to create a new define field.

Figure 6-17 Creating a new define field

31.Give the field the name Gross_Profit.

32.To define the field you can key in the formula manually or you can open the field list panel to the right and double click on the field names to move them over. Use the formula “LINETOTAL - COSTOFGOODSSOLD”.

Now Gross_Profit is available for us to use.

Figure 6-18 Calculating Gross Profit

33.Drag Gross_Profit to the Y axis panel below LINETOTAL.

34.Show the Field options for Gross_Profit.

35.Specify that you want Gross_Profit to be displayed as a Line and you want it to use a 2nd axis.

Chapter 6. Graph Assistant Tutorial 109

Page 128: DB2 Web Query for System i

7214ch05.fm Draft Document for Review October 10, 2007 9:57 am

Figure 6-19 Adding a second Y axis for a line chart

36.Let’s make sure we have a heading for our graph. Select the Headings tab and then select the Graph tab below that.

37.The graph title should be “Revenue by Product Type”. We do not need a subtitle for this graph.

Figure 6-20 Graph Headings

38.Save and run your graph.

39.At the prompt screen select Germany.

110 DB2 Web Query for System i

Page 129: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch05.fm

Figure 6-21 Dual axis bar / line chart with prompting.

Modifying graph properties and settingsOverall the graph is looking like what we wanted. The one potential concern is ensuring that the users can quickly and easily read the values on the Y axis. Let’s simplify this for our users.

40.From the Properties tab select the Y axis tab.

41.Both our revenue and our profit are large numbers in the millions. Format the product type y axis (Y1 axis) values to be shown in millions with a $.

42.Now using the drop down list change the Y2 (gross profit) axis to be displayed as millions of dollars.

Figure 6-22 Formatting Y axis values

Chapter 6. Graph Assistant Tutorial 111

Page 130: DB2 Web Query for System i

7214ch05.fm Draft Document for Review October 10, 2007 9:57 am

43.Save and run your report.

Figure 6-23 Dual axis bar / line chart with prompting

44.Close Graphing Assistant.

With these minor changes our users are now much less likely to misinterpret the actual dollar values.

112 DB2 Web Query for System i

Page 131: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch05.fm

6.4 Creating a revenue trend over time chart (GA3_Line)

In this exercise we will start by creating a simple line chart spanning two years (all our data). We will then modify this chart to allow the user to specify the time range they are interested in.

Figure 6-24 Trending report with variable date range

6.5 Creating a line graph

1. Right click on your Tutorials folder and select Graph Assistant.

Figure 6-25 Creating a new graph

2. Select the table Cen_Orders

3. Have a look at the various choices for line charts and then select Line - Absolute.

Chapter 6. Graph Assistant Tutorial 113

Page 132: DB2 Web Query for System i

7214ch05.fm Draft Document for Review October 10, 2007 9:57 am

Figure 6-26 Selecting a Graph type for a Line chart

If we want to show product revenue trending by month we need to be able to plot one point for every month for each product. To do this we need to convert our date field from year, month and day to a field with just the year and month.

4. Go to the Field selection tab.

5. Click on the calculator button to define a new field.

Figure 6-27 Define a new field

6. Label 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. It is in the format field where we apply DB2 Web Query’s wizardry. Enter a format of TMYY. T means that the month or day immediately following will be represented as upper case text. A single Y would have meant to display a two digit year. YY means that you want your year formatted as a four digit year. An example of a MthYr’s value would be Jan, 2007. 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. See Appendix , “Date and Time System Variables” on page 322 for many of the different ways you can work with date and time fields.

9. Select OK.

114 DB2 Web Query for System i

Page 133: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch05.fm

Figure 6-28 Creating a date field of month and year

10.Drag MthYr as our main X axis. Drag LINETOTAL to the Y axis and specify PRODUCTTYPE for the extra Sort across column.

11.Open the Show - Field options dialogue for PRODUCTTYPE and select the option to “Merge graphs into a single graph”.

Figure 6-29 Creating a line graph with multiple lines

Since an entry on an axis of “Jan, 2007” is obviously a date we can remove the heading or label for MthYr from the graph.

12.Highlight MthYr in the X axis window.

13.Open the Show Field options display and delete the label MthYr.

Tip: PRODUCTTYPE cannot be dragged into its box until after LINETOTAL has been put in the SUM box.

Chapter 6. Graph Assistant Tutorial 115

Page 134: DB2 Web Query for System i

7214ch05.fm Draft Document for Review October 10, 2007 9:57 am

Figure 6-30 Remove the X axis field label.

14.Save your report as GA3_Trend.

15.Run your report.

Figure 6-31 Two year product revenue trend lines

Let’s 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.Ensure that you are setting the style for the Data labels and not the Title.

19.Some of the options are not initially available because a default style sheet is in effect. Check the box that allows you to override the defaults.

20.Change the Text rotation to “45-degree bottom to top”.

116 DB2 Web Query for System i

Page 135: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch05.fm

Figure 6-32 45-degree x axis labels

21.Save and run your report.

Figure 6-33 Report with 45-degree X axis labels

6.5.1 Adding a date range filter to your line graph

So far we have plotted one point for every month, year combination in our data. This obviously isn’t practical as your history grows in size. Next we are going to select a specific range to display. We will display one year’s worth of data starting with orders generated on July 1, 2006 and ending with orders received on June 30, 2007. After we look at the options for hardcoding a range we will look at how the user can specify an ad hoc range.

22.To filter the dates we start by selecting the Selection criteria tab.

23.Drag MthYr to the white panel on the left.

Chapter 6. Graph Assistant Tutorial 117

Page 136: DB2 Web Query for System i

7214ch05.fm Draft Document for Review October 10, 2007 9:57 am

24.We want to select the records as we read them so we will use the default WHERE as opposed to WHERETOTAL.

25.As stated previously our range will be all orders inclusively from July 2006 to June 2007. For our first where clause we want to select MthYr “GREATER THAN or EQUAL to” and then click “Select values” to enter our date.

26.We will be entering a Constant (so select that radio button) and enter 072006

Figure 6-34 Date Selection criteria

27.Drag MthYr over to the Screening conditions white space panel.

28.Notice that, by default, the two conditions you are defining will be ANDed together.

29.This time select LESS THAN or EQUAL to and click Select values.

30.From the new dialogue box choose Constant and enter 062007.

Figure 6-35 Selecting date ranges

You have now defined a range where 072006 <= MthYr <= 062007.

31.Save and run your report.

118 DB2 Web Query for System i

Page 137: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch05.fm

Figure 6-36 Specific date range

Notice that our report now starts with July and ends with June.

Next we will look at a few options that would have given us the same results. First we need to remove the selection criteria we have already specified.

32.Check both conditions and click the red X to remove them.

Figure 6-37 Removing Screening conditions

33.Using the same steps as we did with MthYr, this time drag ORDERDATE and specify the full date.

Figure 6-38 Using ORDERDATE column

34.Run your report. It should look exactly the same as our previous report.

Here is an even easier option.

35.Remove your previous screening conditions.

36.Drag ORDERDATE to the white panel and this time choose “FROM - TO” and press Select values.

37.On the new panel enter your from and to criteria 20060701 and 20070630.

Chapter 6. Graph Assistant Tutorial 119

Page 138: DB2 Web Query for System i

7214ch05.fm Draft Document for Review October 10, 2007 9:57 am

Figure 6-39 Date From-To option.

38.Run your report. Again the same report is generated.

6.5.2 Adding a user specified date range parameter

In this next example we want to allow the user to specify their date range instead of forcing one on them.

39.Remove your existing Screening conditions.

40.Drag ORDERDATE to the Screening conditions panel.

41.Select “GREATER THAN or EQUAL to” and click “Select values”.

42.This time, instead of specifying a constant, select Parameter.

43.Enter a parameter name for your user such as FROM_DATE.

44.Click OK.

Figure 6-40 Creating a date parameter

45.Again drag ORDERDATE to the Screening conditions panel. This time select “LESS THAN or EQUAL to”, click “Select values”, specify Parameter and name the parameter TO_DATE.

120 DB2 Web Query for System i

Page 139: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch05.fm

Figure 6-41 Defining parameters for a date range

46.Save and run your report.

Figure 6-42 Trend graph with variable date range

47.Try various date combinations.

In this exercise we saw multiple ways to hard code a date range and we also saw how to have the user specify a variable date range.

Chapter 6. Graph Assistant Tutorial 121

Page 140: DB2 Web Query for System i

7214ch05.fm Draft Document for Review October 10, 2007 9:57 am

6.6 Working with pie charts (GA4_Pie)

In this exercise we will create a single chart that will contain multiple pie charts, one for each year. We will then add conditional styling or traffic lighting to our pie charts based on comparisons with calculated values.

Figure 6-43 Yearly pie charts with conditional styling or traffic lighting

6.7 Creating a product type pie chart for each year

1. Navigate to your Tutorials folder, right click and select Graph Assistant and choose the Cen_Orders table.

2. Have a look at the various pie chart options and then select basic pie charts.

Figure 6-44 Selecting a graph type

In this example we want to create a pie chart for each year in our data. We do not currently have a field that contains just the year.

3. From the Field selection tab choose the calculator so that you can define a new year field.

4. Call your field Year and format it as YY. Remember, this will create a four digit year i.e. 2007. Specify that the field is to be based on ORDERDATE.

122 DB2 Web Query for System i

Page 141: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch05.fm

Figure 6-45 Creating a year field

5. Go to the Field selection tab to define the fields used in the pie chart.

6. Drag PRODUCTTYPE to the X axis box. This means that we will have a pie slice for each product type.

7. Drag LINETOTAL to the Y axis box. This means that the product type pie slices will be proportionately sized based on the LINETOTAL summed values.

8. Drag Year to the Sort across box which is titled “Create a separate graph ......”. By default this will create a separate graph for each value in Year.

9. Specify that you want two graphs across the page. If you had six different years this would create six pie charts in a 2 x 3 layout. If you had specified six across you would have had six, very small, pie charts across the page in a single row.

Figure 6-46 Pie chart field definitions

You could run or preview your chart at this stage. The graph is essentially complete. We are now just going to make it look a little cleaner.

Tip: If you are getting tired of splitting ORDERDATE up into its various components for each report make sure that you continue to progress through to the tutorial in section 12.1.1, “Date Decomposition” on page 228where you will see how to automatically break down a date and make the components available to all reports.

Chapter 6. Graph Assistant Tutorial 123

Page 142: DB2 Web Query for System i

7214ch05.fm Draft Document for Review October 10, 2007 9:57 am

10.Often a graph is easier to read without a legend. Instead we like to put the labels directly on or next to the pie slices for easy readability. Turn on automatic update on your Graph preview screen. Whether or not you permanently work in Automatic update mode is strictly a performance question.

11.While viewing the Graph preview screen try selecting different options for Show pie labels from both columns.

12.Finish your testing by selecting “Labels only” from column one and “Slice label and % value” from column two.

13.Turn off Automatic updating of the Graph preview.

Figure 6-47 Automatic update for Graph preview

As you can see from your Graph previews we are still showing the legend which duplicates the information on the slice labels.

14.To remove the legend from your pie chart go to the Properties tab, select the Settings tab and remove the checkmark from “Show legend”.

Tip: If you have closed or lost your Graph preview screen return to the Graph types tab and select “Show graph preview”.

124 DB2 Web Query for System i

Page 143: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch05.fm

Figure 6-48 Legend removal

Now we want to tell DB2 Web Query what size to make each of our pie charts.

15.Select the Properties tab, then choose the Options tab.

16.Select Customer size and specify 400 pixels for your Horizontal width and 300 pixels for your Vertical width.

Figure 6-49 Specifying customer graph sizes

17.Save your chart as GA4_Pie and Run.

Figure 6-50 GA4_Pie chart

Chapter 6. Graph Assistant Tutorial 125

Page 144: DB2 Web Query for System i

7214ch05.fm Draft Document for Review October 10, 2007 9:57 am

Notice how similar, as we would expect, the graphs look compared to the Graph preview screen we were viewing.

6.8 Conditional styling or traffic lighting a graph

The last area that we want to address in our graphing tutorial involves having segments of the graph highlighted based on some condition in our data. It is quite straight forward to simply say highlight LINETOTAL when LINETOTAL is greater or less than a predefined number. In this case we want to highlight the pie segments based on the profit margin of that segment. Specifically if the markup that the product is sold for, on average, is lower than corporate standards we want this highlighted.

We need to calculate the average markup after we have aggregated our data. Summing an average calculated at record input time would give us inaccurate results. As previously discussed with DB2 Web Query you can specify whether you want a new field calculated as records are read or after the input records are processed and aggregated. This processing sequence is described in more detail in Appendix C, “Define and Compute fields processing differences” on page 329.

18.Your GA4_Pie report should be open. Go to the Field selection tab.

19.To create a compute field select the wizard symbol above the Y axis panel.

Figure 6-51 Initiating the compute field wizard

20.Name the field MARKUP and specify the formula:

((LINETOTAL - COSTOFGOODSSOLD) / COSTOFGOODSSOLD) * 100

Don’t forget that you can either type in the field names or select them by double clicking the names on the left. The DB2 field names need to be in upper case.

Note: DB2 Web Query calls a new field calculated at input time a “define” field. A field that is calculated after all aggregation is done is called a “compute” field. See Appendix , “Web Query calculation sequence” on page 330 for more details.

126 DB2 Web Query for System i

Page 145: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch05.fm

Figure 6-52 Creating a compute field

While MARKUP is a field that we need to reference in our conditional styling we don’t actually want to display a graph of MARKUP data.

21.Highlight MARKUP, open the Show - Field options panel and check “Make this field invisible”. This makes MARKUP available to the report but won’t actually display it on the graph.

Figure 6-53 Making a field invisible

Next we need to define which pie slices we want to highlight.

22.Highlight LINETOTAL in the Y axis panel and open the Show - Field options panel.

23.Select the Conditional styling button.

Figure 6-54 Conditional styling

24.Select the Add Wizard.

Chapter 6. Graph Assistant Tutorial 127

Page 146: DB2 Web Query for System i

7214ch05.fm Draft Document for Review October 10, 2007 9:57 am

Figure 6-55 Conditional Styling Add Wizard

We want to highlight the pie segments or slices that have a lower markup than our company standard of 35%.

25.Give this condition the name of Low_Markup.

26.Define Low_Markup as occurring when MARKUP is less than or equal to the value of 35.

Figure 6-56 Creating a conditional styling condition.

After creating the condition definition we need to attach it to LINETOTAL and define what happens when this condition is satisfied.

27.Highlight Low_Markup and click the Add Condition button.

Figure 6-57 Attaching a condition definition

28.Choose the grey color indicator box. A window will open to allow you to choose the color you want the pie slices when the slice meets the Low_Markup condition. In this example choose red.

Figure 6-58 Conditional styling highlighting

128 DB2 Web Query for System i

Page 147: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch05.fm

When modifying a report by applying filters or using traffic lighting it is always good to indicate this information on the report itself. This is typically done via a sub heading or a page footing or footnote.

29.Select the Headings tab.

30.Choose the Graph tab and enter in a Chart footnote of “Red pie slices indicate an average markup of less than 35%”.

Figure 6-59 Explanatory chart footnote.

31.Save your report and run it.

Figure 6-60 GA4_Pie low markup charts

You have now finished the Graph Assistant Tutorial. I hope you are still enjoying yourself.

Chapter 6. Graph Assistant Tutorial 129

Page 148: DB2 Web Query for System i

7214ch05.fm Draft Document for Review October 10, 2007 9:57 am

130 DB2 Web Query for System i

Page 149: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch06.fm

Chapter 7. Power Painter Tutorial

Power Painter is a web layout and report creation tool. It is built using the new AJAX technology. This will allow a thin browser to deliver advanced functionality without add-ons and plug-ins. With HTML you must update the entire screen. With AJAX technology the application can update portions of the screen for improved flexibility and performance. Power Painter allows you to create a compound report combining multiple graphs and charts on a single page. You can link the various charts together all tied to a common sort group. Power Painter supports a live feed to your data to allow for real WYSIWYG report creation. With Power Painter you can use multiple data sources to build your compound reports.

In this tutorial we are going to build reports similar to those we built using Report Assistant and Graph Assistant. The idea is for you to become familiar with the various ways of achieving similar end results. We will lay out the report and graph on one page, link them by COUNTRY and tailor the request for PDF output.

7

© Copyright IBM Corp. 2007. All rights reserved. 131

Page 150: DB2 Web Query for System i

7214ch06.fm Draft Document for Review October 10, 2007 9:57 am

7.1 Power Painter Tutorial (PP1_PDF)

In this tutorial we will build a PDF file that shows profit analysis by region with a separate graph and report for each country. The PDF file will have a table of contents that lets a user quickly jump to the country they are interested in.

Figure 7-1 Power Painter exercise PDF output

7.2 Getting Started with Power Painter.

1. Open DB2 Web Query if it is closed and navigate to your Tutorials folder.

2. Right click on the Tutorials folder and select Power Painter.

3. Select the Cen_Orders table.

Figure 7-2 Power Painter data source selection

132 DB2 Web Query for System i

Page 151: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch06.fm

Before we actually create our report we can tailor the main Power Painter screen to look and work in a way we are comfortable with.

The main Power Painter screen is composed of your standard menu drop downs at the top (File, Edit etc.), a row of icons immediately below, a basically empty canvas to design your report on, and your various palettes. The palettes can be moved around the screen or they can be docked on the right hand side. The palettes can be opened via the drop down menu View / Palette / various palettes. Most of the palettes can also be opened by the icons below the drop down menus. Hover over an icon to see a description.

Double click a palette or move it to the edge of the canvas to dock it. You should see the pin and close button (X) in the upper right corner when a palette is docked. To un-dock the palette simply drag it to a new location on the screen.

Click the pin button to minimize the palette and have it appear as a tab to the right of your screen. Hovering over the tab makes the palette reappear.

You will want to change which palettes are open based on what work you are actually doing. Here is one design that appears to work quite well and will be used in this tutorial.

4. Click on the pin of the open Properties palette. This will temporarily make it a tab on the side. We will bring it back to the main docking area later. Either choose View / Palettes / Query or click the query icon (multi-colored circle with a question mark). Drag the query palette to the right underneath the Toolbox and above your Data Sources palette.

Figure 7-3 Power Painter main screen

While you are initially laying out your report, the two main palettes you will use will be the Query palette and the Data Sources palette. Once you have selected your columns you can move the properties box back to the docking area and click on the pin for the Data Sources so that it minimizes to the side. This will keep the Query and Properties palettes on full view

Chapter 7. Power Painter Tutorial 133

Page 152: DB2 Web Query for System i

7214ch06.fm Draft Document for Review October 10, 2007 9:57 am

while you are designing the actual look and feel of your report. You can have more than two palettes open and docked but they start to get a little small to work with effectively.

In this report we want our page to start with our logo or picture and a heading, below that will be a graph and below that will be the main report.

7.3 Building a graph with Power Painter

The graphing component in Power Painter is a more full function and advanced graphing tool than Graphing Assistant. It allows you more control over styling, colors, text properties, legend formatting, and more. Using gauges becomes much more meaningful with Power Painter. You can selectively control the color of the quality bands and the gauge needle. With Power Painter you can add annotations to your graphs. Graph Assistant allows you to drill down to another report or graph. This is one function that is not available in Power Painter.

We will start with building the bar graph that shows the individual regions in a country and their revenue attainment.

5. Maximize your screen. Click on the picture of a graph (bar chart) in the Toolbox and then, using your mouse, draw a rectangle on the canvas. This rectangle outlines the margins for your graph. Leave room for a report title at the top of the page. The graph can be moved and sized using the mouse after you initially place it.

Figure 7-4 Insert a graph

134 DB2 Web Query for System i

Page 153: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch06.fm

You will find that Power Painter has more advanced graph controls in most areas than does Graphing Assistant.

6. For this example we are going to select the default Vertical Clustered Bar chart. If we had wanted to display a series of bar charts i.e. one bar for each year for each rep then we would have selected the CrossTab box. We do not need that for this example. Simply select Finish.

Figure 7-5 Power Painter selecting a graph type

Now what we want to do is define the columns required in the graph. Similar to Report and Graph Assistant you can view your column names in multiple sequences including in alphabetical sequence or in a tree type hierarchy based on table names. Remember that our Orders data source is actually composed of multiple tables all joined automatically by your foreign key definitions. The icons in the data source bar allow you to change the displayed sequence. Use the drop down arrows on both the hierarchy structure icon and the list icon to see your different choices.

7. To include a field on the report you can drag the field name either onto the graph you just created or onto the Query palette. When you drag a field onto the report area of the canvas you will see a Query palette pop up. Drag LINETOTAL onto the Y Axis label.

Chapter 7. Power Painter Tutorial 135

Page 154: DB2 Web Query for System i

7214ch06.fm Draft Document for Review October 10, 2007 9:57 am

Figure 7-6 Field Selection for graphing

8. Now drag REGION onto the X group axis label.

Figure 7-7 X group axis field selection

9. Finally drag COUNTRY onto the Coordinated label.

Tip: Make sure that you select your graph before dragging your field. The open query palette relates to the highlighted object.

Tip: Coordinated fields are common sort fields and filters that tie together the various reports and graphs on your page. Each change in the coordinated field causes a page break. The report layout you define is repeated for each new value.

136 DB2 Web Query for System i

Page 155: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch06.fm

Figure 7-8 Adding a Coordinated field

10.Save your report as PP1_PDF.

11.Now that we have chosen most of our fields you may find it easier to bring the properties palette to the front and minimize the data sources palette. To minimize the data sources palette click on the pushpin. To redock the properties palette simply double click its tab on the right side of the screen. Now any time you select a field in the query palette you should see that field’s properties in the property palette.

Selecting the graph opens up the basic chart properties window. To see all the chart properties you need to open up the Chart Editor.

12.Select the Chart Editor icon or select Chart Editor under View and Palettes.

Figure 7-9 Show Chart Editor icon

With the Chart Editor open, the options you select control the properties displayed in the properties panel. To be able to read all our region names we need to orient them differently on the graph.

13.In the Chart Editor panel select Ordinal axis and then select labels.

14.From the properties panel choose to present the region names on a 45 degree angle.

15.Have a look at the various properties available between the Chart Editor and the properties box. This is where you will completely control the appearance of your graph. You define your traffic lighting or conditional styling here, you can choose whether one series shows as bars while a second series is displayed as a line chart and much more.

Tip: The property box changes between document properties, report properties, and column properties. If you select a column in the Query palette you will see the properties relating to that column. If you select a graph or report you will see the basic graph properties or report properties and if you click the whitespace on the canvas outside of a report you will see the overall properties for the document.

Chapter 7. Power Painter Tutorial 137

Page 156: DB2 Web Query for System i

7214ch06.fm Draft Document for Review October 10, 2007 9:57 am

Figure 7-10 Chart editor properties

Our graph is complete. Now we need to add any headings to our report.

16.Select the text icon from the Toolbox. and draw a rectangle where you want to place the heading of your report.

Figure 7-11 Adding text to a report

17.Enter in a report title of “Sales Analysis by Country”. Choose a blue font, size 14, bold and underlined.

Figure 7-12 Adding text to a graph

138 DB2 Web Query for System i

Page 157: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch06.fm

18.Let’s also add a date and page numbers to our report. Select the text icon from the tool bar and draw a rectangle where you want to place the text on your report.

Figure 7-13 Adding a text box to your document

19.Select the Insert dropdown and choose Date/Time.

20.Choose the date format you would like to see.

Figure 7-14 Inserting current Date/Time

21.After the date you just inserted use the enter key to force a new line and type “Page “.

22.Select the Insert dropdown and this time select Page Numbering.

23.Choose Page n of n.

Figure 7-15 Inserting Page Numbering

Figure 7-16 Date and page numbering area.

24.Select the Font Properties and button and make your new text the same color as your report heading.

Chapter 7. Power Painter Tutorial 139

Page 158: DB2 Web Query for System i

7214ch06.fm Draft Document for Review October 10, 2007 9:57 am

25.Change the font size to 10 so this text will be somewhat smaller than our main heading.

Figure 7-17 Font changes

26.Save and run your report. It should look similar to Figure 7-18

Figure 7-18 Regional Sales Analysis graph

Notice that you have one page for each graph. When the coordinated column COUNTRY changes a page break occurs.

Now that our graph is complete we will create the coordinated report.

140 DB2 Web Query for System i

Page 159: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch06.fm

7.4 Building a report with Power Painter

We are now going to add a report that lists each salesperson that sold in the country and details on the sales. It is conceivable that a sales person could show up in different sections of the report if they made sales in different countries.

1. Make sure that your PP1_PDF report is open and maximized.

2. There are multiple ways to start a report in Power Painter. In this example select the report icon in the Toolbox.

3. Outline the area under your graph where you want your report to be located on the page.

4. Drag SALESREP onto your new report area and a query palette should open up. Drop SALESREP on the By folder.

Figure 7-19 Adding fields to a report

You can drag and drop fields directly onto the report or you can drag and drop then onto a query palette that you have opened and docked.

Note: We will be using the same data source that we used for the graph. If we wanted to add data from a second data source we could do that by selecting the Data Sources palette and using the Add data source icon.

Tip: When creating a report you can select one or multiple fields from the data source list and then just drag them onto the canvas. DB2 Web Query will automatically create a region for the report, autosize it and place alpha fields in the Sort By folder and numeric fields in the Sum folder. Try it. If you have a small table or view you can actually drag and drop the entire table onto the canvas and have an instant one click report.

Chapter 7. Power Painter Tutorial 141

Page 160: DB2 Web Query for System i

7214ch06.fm Draft Document for Review October 10, 2007 9:57 am

5. Drag ORDERNUMBER into the By folder.

Figure 7-20 Add additional fields to report

6. Drag the remaining columns as depicted in Figure 7-21 onto your Query Palette. You do not have to drag COUNTRY under the Coordinated folder. Once you name place a column under the Coordinated folder it is automatically there for every report or graph in your layout. You have now completed the specifying the columns to be used in your query

Figure 7-21 Completed query palette.

Let’s add some subtotals when the sales rep changes and when the country changes. We also want to add grand totals at the end of our report.

7. Open the query palette if it is closed, highlight SALESREP and go to the properties display. Scroll down to subtotal and click on the ellipsis button. This will bring up the Sub Total window.

8. Select the Sub Totals radio button. Enter “subtotal for “ in the text box and select OK.

Tip: If your data files are very large and complex you might consider changing the Data preview option under Document properties from Live data to Sample data. The Design record limit controls the number of live data records read while designing and previewing the report.

142 DB2 Web Query for System i

Page 161: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch06.fm

9. The default for a column is to sum or total it. This can be overridden and you can request column functions such as average or count.

Figure 7-22 Adding subtotals

Next we want to add grand totals for each section or country in our report. To do this we need to have Country as a by column not just a coordinated column.

10.Select Country from the data sources panel and add it as a By column and then move it to the top of the By column list.

We don’t actually want to see a column for Country in our report since it will be the same on the entire page. We need to hide the column but still have the properties available to indicate that sub totaling is desired.

11.Open the query palette if it is closed, highlight COUNTRY under the By folder and go to the properties display.

12.On the Field properties display change Visible to No.

13.Scroll down, highlight subtotal and click on the ellipsis button. This will bring up the Sub Total window.

14.Select the Sub Totals radio button. Enter “Grand totals for “ in the text box and select OK.

Figure 7-23 Grand totals for each country

Chapter 7. Power Painter Tutorial 143

Page 162: DB2 Web Query for System i

7214ch06.fm Draft Document for Review October 10, 2007 9:57 am

Finally we want to add grand totals to our report. These totals are not associated with any specific column changing but rather with the report itself.

15.Highlight the report and go to the Report properties panel.

16.Under the Report properties window locate Column totals and select Totals.

Figure 7-24 Column totals

If our report is longer than the frame we have drawn we need to tell DB2 Web Query what to do.

17.Highlight the report so that you can work with the report properties.

18.The Overflow property controls what happens when the report has too many rows to be displayed in the defined region. The default value of fixed indicates that the report will be restricted to the exact area you have defined. If it overflows the rows will continue in the same area on the next page until the report is complete. If you select Flowing the report will ignore the vertical boundaries and flow from the top to the bottom of each following page until it is complete.

19.We want our report to take full pages and flow until it is finished. Make sure that the Overflow parameter is set to Flowing.

Figure 7-25 Controlling report overflow

20.Save and run your report.

144 DB2 Web Query for System i

Page 163: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch06.fm

Figure 7-26 Page 2 of a flowing report

21.Notice that our report is quite long. Trying to find any individual country could be time consuming. To solve this problem we can add a Table of Contents with an entry every time the COUNTRY changes, we have a page break and the report layout starts over again.

22.From the Query palette under Coordinated highlight COUNTRY. Go to the properties panel specify Yes for Table of Contents.

Figure 7-27 Table of contents property

Chapter 7. Power Painter Tutorial 145

Page 164: DB2 Web Query for System i

7214ch06.fm Draft Document for Review October 10, 2007 9:57 am

23.Save and run your report.

Figure 7-28 PDF with Table of Contents

You have now created your first Power Painter compound PDF report.

Note: There is a lot more that you can do in Power Painter. This tutorial has barely scratched the surface. Try dragging multiple fields at once on the page. Voila! You have a new report. Other things to try on your own include looking at “relationships” and using the advanced graphics. There is even a speedometer which is very nice for dashboards.

You can open any Report Assistant or Graph Assistant report in Power Painter. This gives you a starting point before you continue to add new reports using the Power Painter functionality.

146 DB2 Web Query for System i

Page 165: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214p03.fm

Part 3 Tutorials for DB2 Web Query Optional Features

Part 2, “Tutorials for DB2 Web Query” covered the base features included in DB2 Web Query. Part 3, “Tutorials for DB2 Web Query Optional Features” will cover the optional components which are ordered as feature codes for 5733-QU2.

This section includes:

� Active Reports - which enable analysis of reports by users even when they are not connected to the System i

� Configuring Developer Workbench - this chapter is a prerequisite for both the On Line Analytical Processing chapter and the HTML Layout Painter tutorial

� On Line Analytical Processing - the graphical hierarchy/dimension design components of Developer Workbench that are a pre-requisite for OLAP-enabling your reports. Once these hierarchical structures are defined it is a very simply step for a report developer to include the them in existing reports.

� HMTL Layout Painter - is a component of Developer Workbench. With it you can create compound reports, dashboards and highly paramaterized reports.

� Additional Developer Workbench features: Developers Workbench is a set of advanced tools for programmers. This chapter include advanced metadata definition, data profiling, impact analysis, SQL Wizards and creating business views of your data.

Part 3

© Copyright IBM Corp. 2007. All rights reserved. 147

Page 166: DB2 Web Query for System i

7214p03.fm Draft Document for Review October 10, 2007 9:57 am

148 DB2 Web Query for System i

Page 167: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch07Act_Rpt.fm

Chapter 8. Active Reports

Active Reports is the first of the optional features available from IBM for DB2 Web Query that we are going to exercise here. While the base product is licensed to named users Active Reports is licensed to a System i based strictly on software tier (P10, P20 etc.). Any user who can create a report using one of Report Assistant, Graph Assistant or Power Painter, is entitled to create an Active Report. Since Active Reports is intended for disconnected users the individual end users do not require a license to actually use the reports. The html reports must be made available to the end users. This might be via email, or a shared network drive or via additional tools from Information Builders such as Report Caster. As you will see shortly, with Active Reports, the data as well as the reporting controls are all stored within the html page. Once the user has access to the html page he/she can access, manipulate and analyze the data with no requirement for any additional licensing.

With Active Reports sales reps might sign on to the System i in the morning and run a report for each of the customers they are planning on visiting that day. They can then save the reports on their local hard drive. From their car the sales rep can then look at and analyze the data for their customer immediately prior to visiting them.

8.1 Active Reports

Active Reports allows users to interact with their reports and work disconnected from the System i. HTML Active Report pages are self-contained reports. Both the data and the Java Script are compressed within a single efficient file. This file can be stored by the users on their local drive. It can be stored on the server for retrieval by the users or it can be emailed to users.

Active Reports are well suited for the mobile worker who is frequently disconnected from the web. With Active Reports you can create a variety of simple or advanced charts (pie, line, bar, or scatter), roll-up analysis, or pivot reports.You might want to allow your sales reps to analyze the buying patterns for the clients they are due to visit that day. Your service reps

8

Attention: To use Active Reports the server requires a license key that can be purchased as an optional feature of DB2 Web Query 5733-QU2.

© Copyright IBM Corp. 2007. All rights reserved. 149

Page 168: DB2 Web Query for System i

7214ch07Act_Rpt.fm Draft Document for Review October 10, 2007 9:57 am

might want to view the service history of a customer before they visit. You might even choose to email your customers or partners reports detailing their activities with you. The end user of an Active Report requires no special software and there are no licensing fees for end users.

HighlightsWith Active Reports your users can:

� create graphs and charts based on their data

� filter or highlight their data

� change the report sort sequence to any column

� apply calculations such as sum, min, max, avg, count and count distinct to their data

� change the look of a report by hiding columns, changing the pagination and more

� add data visualization bars to compare and contrast values in a column

Users can continue to work with their reports in a browser window or they can download the reports to MS Excel or even pull their data and graphs directly into MS Power Point.

Figure 8-1 Active Reports Sample

150 DB2 Web Query for System i

Page 169: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch07Act_Rpt.fm

8.2 Creating an Active Report

We will take the RA3_GrossPft report that we created in chapter 4 and enable it to be used when the end user is not connect to the server. You have to have upgraded your license key prior to starting this section. The only requirement for Active Reports is that the server be properly licensed. There are no end user requirements.

1. Open your RA3_GrossPft report from the DB2 Web Query home page.

2. From the Report options tab change the report type to Active Report.

Figure 8-2 Active Reports Enable

At this point you could simply Run the report. We are going to make a few formatting and highlighting changes first.

3. When you selected “Active Report” you will notice that the “Active Report Styling” button becomes active. Click this button.

4. For this example make sure that report type is Tabular, change the Row selection Hover color to yellow, change Visualization colors to red for negative numbers and dark green for positive results and press OK.

Note: Horizontal (Across) sort fields are not supported for HTML Active Reports.

Chapter 8. Active Reports 151

Page 170: DB2 Web Query for System i

7214ch07Act_Rpt.fm Draft Document for Review October 10, 2007 9:57 am

.

Figure 8-3 Active Report Styling

All we are doing on this screen is affecting the presentation and the initial look of the report for the end user. We will discuss Accordion reports later in the tutorial.

5. Save your report as AR1_GrossPft.

6. Now run your report.

Figure 8-4 Active Reports Tabular Format

7. Select a down arrow next to any column. Choose “Save Changes”. Save your report on your PC as “AR1_GrossPft.html”.

Note: You can use your browser’s “Save As” option also to save the HTML page. 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.

152 DB2 Web Query for System i

Page 171: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch07Act_Rpt.fm

Figure 8-5 Save your Active Report for offline use

In the next section we will continue to work with this Active Report but we will do so as if we were the disconnected user and not the developer.

8.3 Using an Active Report

When a user receives an Active Report they simply open it in their browser. Once your users receive this report they can then perform various types of analysis on it without connecting to the System i.

8. As an end user locate AR1_GrossPft.html in C:\ and launch it. 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 we want to do is analyze our product categories evaluating gross profit compared with revenue or Line Total.

9. Click the down area next to Gross Profit and select Sort Descending.

Tip: Once you have saved your report as an HTML file it can be emailed to end users. In this case the recipient would be able to view and analyze the report with no connectivity to the System i. To run and save an Active Report you must be a named user. To work with the .html file after it has been created you do not need to be a named user.

Note: Active Reports use ActiveX controls. Based on your browser security settings you may see warning messages and you may be asked if you want to allow blocked content.

Chapter 8. Active Reports 153

Page 172: DB2 Web Query for System i

7214ch07Act_Rpt.fm Draft Document for Review October 10, 2007 9:57 am

Figure 8-6 Active Reports Sort Descending

To make the report fit better on the page (at least in this book!) we are going to hide the Cost of Goods Sold column.

10.Select the drop down arrow next to Cost of Goods Sold and choose Hide Column.

Figure 8-7 Hiding columns

Next we want to do what is known as “Visualize” a column. This is a very powerful tool that allows you to see, at a glance, relationships between various columns.

11.Select the drop down list for the Gross Profit column and click Visualize. This will display the green or red bars in the chart below. Visualize gives you a quick visual representation of the data in a column.

Figure 8-8 Active Reports Visualize Selection

154 DB2 Web Query for System i

Page 173: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch07Act_Rpt.fm

12.Now Visualize Revenue also.

Figure 8-9 Active Reports Visualize results

13.With the visualize bars it is much easier to spot relationships. Notice that although speakers wouldn’t have ranked very high in revenue they are extremely profitable and generate the third highest profit of any Product Category.

14.From the Gross Profit drop down list choose calculate and then choose “% of Total”. Notice that we now have a new column which shows each Product Category row as a percent of the total Gross Profit in this report.

Figure 8-10 Add a “% of Total” column

15.Finally, go back to your calculation selection for Gross Profit and this type select “Sum”. Your summary will print at the top of the page by default.

Chapter 8. Active Reports 155

Page 174: DB2 Web Query for System i

7214ch07Act_Rpt.fm Draft Document for Review October 10, 2007 9:57 am

Figure 8-11 New “% of Total column” and “Total Sum”

Next we will temporarily filter the report so that we can concentrate on our audio sales.

16.Select the drop down for Product Type, choose Filter and then choose Equals.

Figure 8-12 Active Reports Filtering

17.Choosing the down arrow on the right gives you a list of the distinct values in a field. Choose Audio and select Filter.

Figure 8-13 Active Reports Where Equals clause

18.In the filtered chart you will 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. You will cycle through viewing the sum of all your data, the sum of your filtered data, and having both sums displayed concurrently.

Note: Besides your 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.

156 DB2 Web Query for System i

Page 175: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch07Act_Rpt.fm

Figure 8-14 Active Reports Filtered / Total Sum

At any point in time you can choose the option from a drop down list to “Restore Original” display. To see all the records you simply close the filter dialog box.

A helpful way of analyzing the data often involves changing the grouping and looking at your numbers slightly differently.

19.Select the Gross Profit drop down and choose Rollup and then Group By Product Category.

Figure 8-15 Active Reports Rollup Definition

Note: If instead of pressing the Filter button above you had pressed the highlight button your report would contain all the records but the ones meeting the filter criteria would now be highlighted.

Chapter 8. Active Reports 157

Page 176: DB2 Web Query for System i

7214ch07Act_Rpt.fm Draft Document for Review October 10, 2007 9:57 am

20.Now click the pie chart graph icon to change the report you are looking at into a pie chart. You could have chosen line or bar charts also.

Figure 8-16 Active Report Rollup Results

21. The chart can also be exported to Power Point, MS Excel and MS Word. Click on the first list type icon and select Export to and then select MS Excel.

Figure 8-17 Active Reports Graph

Note: You could have got the same graph directly from your full report by clicking on the Gross Profit column, selecting Chart, Pie, and Product Category as your Group by field.

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 as is displaying the filtered data select the lock icon.

158 DB2 Web Query for System i

Page 177: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch07Act_Rpt.fm

Figure 8-18 Active Reports output to MS Excel

22.Try exporting to the other MS products if you have them loaded on your system.

23.Close MS Excel and close the charting window.

24.To use the Cross tab or Pivot functionality select the Gross Profit drop down arrow and choose Pivot. Next choose Product Category for your Group By field and Product Type as the field to go across the top of your table.

Figure 8-19 Creating Pivot Tables with Active Report

Chapter 8. Active Reports 159

Page 178: DB2 Web Query for System i

7214ch07Act_Rpt.fm Draft Document for Review October 10, 2007 9:57 am

Once you have your basic pivot table you can start adding to it and changing and pivoting it.

25.Clicking on the indicated (circled) icon above moves Product Type to the left of Product Category.

Figure 8-20 Pivot Table output with Active Report

26.Clicking on the icon to the left of the arrow moves a field back and forth between being a column or a row i.e. pivoting on that field. Notice that the title changes as the column layout changes.

Figure 8-21 Active Reports Changing Sort breaks and sort priorities

Note: This report is not a very good report to demonstrate cross tab or pivot functionality. We do not actually have enough fields shown, that relate to each other, to pivot on. The next few steps are purely to demonstrate the capabilities of Active Reports.

160 DB2 Web Query for System i

Page 179: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch07Act_Rpt.fm

27.There is quite a bit more that you can do with pivot tables if it made sense for your data. You might ask to see the average profit numbers for example if you had more than one record per row grouped together.

As you can see Active Reports gives us a very nice way to allow users to quickly add some level of analysis to their reports, all without being connected to the System i.

Before we leave Active Reports we are going to have a quick look at the difference between a tabular and accordion Active Report.

28.If your report definition is closed go to the DB2 Web Query home page navigate to it, right click and open it.

29.Go to the field selecting tab and remove subtotals from PRODUCTTYPE.

30.Remove the check mark from the grand totals box.

Figure 8-22

31.Select the Report Option tab and the Active Report Styling button.

32.Select Accordion instead of Tabular and press OK and Run.

Tip: To size the window above scroll down to the bottom and in the bottom right corner is an area of the window that you can drag to widen and size the pivot table. Click once outside the box when you have finished dragging to release the cursor.

Restriction: With the early software subtotal and total messages would occasionally appear in an accordion report. It is currently easiest to remove them.

Chapter 8. Active Reports 161

Page 180: DB2 Web Query for System i

7214ch07Act_Rpt.fm Draft Document for Review October 10, 2007 9:57 am

Figure 8-23 Accordion Active Report

Only the data values at the highest level (first vertical sort field) are shown initially.

33.Clicking on the plus sign expands a field, clicking on the - sign compresses the data. In the above example we clicked on Product Type - Audio. We now see all the Product Categories within Audio. If we had more Sort By columns in our report we could keep going, expanding down each of the levels.

Figure 8-24 Active Reports Accordion Format

34.Have a look at some of the other options available under the drop down arrows. You will see that you can export data to CSV files, to HTML files and directly into MS Excel. If you have filtered your data you will have the choice of exporting the entire dataset or just the filtered records.

Active Reports is a tool that works extremely well when your end users are remote and not connected to the System i. Also, even with local users there is no named user licensing requirements to work with and analyze an Active Report. You can create an Active Report and email it to a user and they can analyze to their hearts content. The person who originally runs the report does need to be a licensed named user. The report is stored in a highly compressed format. As I am sure you have seen, Active Reports is one more excellent tool for you in your Query/Reporting kit bag.

Tip: HTML Active Reports can support up to 20,000 rows of data. It is recommended if you are using a Firefox browser to use only up to 15,000 rows of data and if you are using an Internet Explorer browser to use only 5,000 rows of data.

162 DB2 Web Query for System i

Page 181: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch08MRD.fm

Chapter 9. Configuring Developer Workbench

Developer Workbench provides an integrated development environment for building and maintaining a DB2 Web Query reporting environment. Developer Workbench includes additional tools to work with your metadata. The synonym editor allows you to change the way a field is displayed to the end users. You can add commas and decimal signs, convert date formats, convert alpha to numeric fields or even change the length of a field. The synonym editor also allows you to create calculated fields for the end users. You can predefine joins for the users or create business views that simplify the structure and number of columns the user sees. If you plan on using the optional OLAP feature you will need to define your hierarchies or dimensions with Developer Workbench.

Utilizing the metadata layer Developer Workbench provides the ability to do impact analysis at both a file and field level. If you need to make changes to a field you can see which reports and graphs use that field and what business views it is part of.

Developer Workbench provides you with the capability of “profiling” your data. This allows you to see the patterns in the actual text characters. For example, profiling the telephone number in the Stores table might show us that five records have a format of 9 numeric characters instead of 10. Are these five records a quality problem? Data profiling also shows you the minimum and maximum values in a column and identifies outliers.

The SQL Wizard allows you to import SQL into Report or Graph Assistant.

One of the major tools within Developer Workbench is the HTML Layout Painter. HTML Layout Painter is specifically designed to create HTML pages which can contain compound reports or dashboards. A complete tutorial for this component can be found in Chapter 11, “HTML Layout Painter Tutorial” on page 197.

In this chapter we will configure your System i DB2 Web Query environment and set up some Developer Workbench default settings. This chapter is a prerequisite for the Chapter 10, “OLAP (Online Analytical Processing)” and Chapter 11, “HTML Layout Painter Tutorial”. More information on Developer Workbench can be found in Chapter 12, “Additional Developer Workbench features” on page 225.

9

© Copyright IBM Corp. 2007. All rights reserved. 163

Page 182: DB2 Web Query for System i

7214ch08MRD.fm Draft Document for Review October 10, 2007 9:57 am

9.1 Configuring Developer Workbench

1. Developer Workbench is a PC application. Install the software on the developer’s PC.

When you start Developer Workbench the first thing you need to do is add the definition of your System i environment.

2. Right click on WebFOCUS and select Add.

Figure 9-1 Add System i Environment

3. Fill in the name and description of your System i.

4. Verify that port 11331 is selected and that the HTML Alias is /webquery_html and press OK.

Figure 9-2 System i Environment properties

Tip: If you have changed the default DB2 Web Query default port number you will need to uncheck the Use Default box and specify your installation’s port number.

164 DB2 Web Query for System i

Page 183: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch08MRD.fm

5. The first time you open the System i environment or connection that you just added you will need to sign on.

6. Signon with your admin or developer authorized profile.

Figure 9-3 Initial opening of System i connection

7. Expand down the path system name, Data Server, EDASERVE. At this point you will be asked to log on again.

Figure 9-4 Metadata Login

Note: Asking the system to remember your user name and password in this sign on and the next sign on means that you will not be prompted with these screens again for this System i connection.

Chapter 9. Configuring Developer Workbench 165

Page 184: DB2 Web Query for System i

7214ch08MRD.fm Draft Document for Review October 10, 2007 9:57 am

8. After logging in to the reporting server continue down the metadata path by expanding EDASERVE to Applications and then baseapp. Select baseapp.

Figure 9-5 Metadata files

Here you will see all your metadata or 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 which actual name and location of the physical table and the primary keys for the table. Nearly all your work will be 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. That branch is where you go if you wanted to create a new report or modify an existing one.

9.2 Setting Developer Workbench default options

Developer Workbench has a set of options that can be tailored specific to an individual user. These options can be accessed from the Window menu on the tool bar. See Figure 9-8 on page 167 for tailoring options used in later tutorials.

Figure 9-6 Displaying Developer Workbench options

166 DB2 Web Query for System i

Page 185: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch08MRD.fm

Here is a screen display of the General options.

Figure 9-7 General options tab

Developer Workbench allows you to show your Windows desktop explorer tree in the same window as your DB2 Web Query explorer tree.

Figure 9-8 Explorer options

Showing your Windows desktop tree within Developer Workbench has a few definite benefits. The first and obvious benefit is just being able to stay within one working environment as a programmer. The less that you have to flip back and forth between your development mode and Windows the better.

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 we are copying and pasting a text file containing SQL statements into our “Other Files” folder in the Common Domain. From here the SQL is available to be accessed and run via the SQL Wizard in Developer Workbench or the SQL metadata creation option from the DB2 Web Query home page.

Restriction: It doesn’t appear that Report Assistant is picking up all the reporting options set under the Reporting tab at this point in time.

Chapter 9. Configuring Developer Workbench 167

Page 186: DB2 Web Query for System i

7214ch08MRD.fm Draft Document for Review October 10, 2007 9:57 am

Figure 9-9 Coping files between the PC and DB2 Web Query

For more details on using Developer Workbench please see:

� Chapter 10, “OLAP (Online Analytical Processing)” on page 169

� Chapter 11, “HTML Layout Painter Tutorial” on page 197

� Chapter 12, “Additional Developer Workbench features” on page 225

� on-line help text

168 DB2 Web Query for System i

Page 187: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch09OLAP.fm

Chapter 10. OLAP (Online Analytical Processing)

On-Line Analytical Processing or OLAP is best known as the technology that allows user to “slice and dice” their data or drill down into their data. DB2 Web Query makes it extremely easy to provide users with a sophisticated drill down, slice and dice interface without the report developers needing to literally do anything at all. This may sound like an exaggeration but by the time you have finished this tutorial you will understand the great technology that makes this possible. After taking a standard report created with Report Assistant the report developer selects an output option to “OLAP-enable” the report. This automatically provides an interface with drop down lists, and drill capable columns that allow the end user to slice and dice and/or pivot their data and perform a variety of local analytics on the original report. Tables need to have any embedded hierarchies predefined via the Developer Workbench. Once this is done the users have an easy and intuitive way to navigate and drill down on the hierarchy within their data.

OLAP analysis typically starts with a question such as “What were my regional sales numbers across the United States?” At this point in time you might look at the numbers and ask to see the details for the Eastern region which looks out of line with the other regions. If you then find that a single state is pulling down the region you might ask to see the revenue for that state split out by the different product groups you sell. After you find a product group that appears to be in trouble you might ask to see the sales for that product group in that state summarized by month for the last two years. This type of analysis is sometimes called “Having a conversation with your data.”. It is OLAP technology that enables this quick and easy interaction with the data. A user could have created a separate ad hoc query for each of the above questions but that would probably not occur in real life. On the other hand, if a user simply had to click on a specific field of interest to go down to the next level of detail they would be far more likely to continue with their analysis.

10

© Copyright IBM Corp. 2007. All rights reserved. 169

Page 188: DB2 Web Query for System i

7214ch09OLAP.fm Draft Document for Review October 10, 2007 9:57 am

10.1 Getting Started with OLAP

Before a user can successfully OLAP enable a report the tables used must have any existing hierarchies or dimensions defined to DB2 Web Query.

Hierarchies, also known as dimensions, can involve elements from multiple tables although the norm would be to have a single hierarchy composed of columns from a single table.

10.1.1 OLAP Terminology

Let’s cover some basic OLAP terminology so that we are all talking about the same things.

Table 10-1 OLAP Terminology

Term Definition

Dimension A set of columns structured in a hierarchy. For example, a Geographic dimension might include a City that belongs to a State which is in a Region which is part of a Country. In this example Country is the top level and City is the bottom level of the dimension.

A Product dimension might include Product Type at the top level and below that a Product Category which would contain multiple Models and each Model would contain multiple part numbers or SKUs.

Drill down Drilling down usually involves going from one level in a hierarchy to the next lower level. For example, if a user was to drill down on Country they would see the different Regions that make up the country. If they then drilled down on Region the States that compose the region would be displayed.

Drilling down can also involve invoking more detailed reports or graphs. For example, in an earlier tutorial we drilled down on Product Type and passed the Product Type as a parameter to a second report. If this type of drill down is defined for a column it will take precedence in an OLAP report over drilling down through the hierarchy.

Hierarchy A Hierarchy is the structure or sequence of each of the columns within the dimension. In the example above the Geography dimension would have a hierarchy of Country, Region, State, City.

Hyperlinks When a column shows up in blue in a report this indicates that the user can click on this hyperlinked column to initiate an action. The standard action that is linked to a column is the ability to drill down to the next level of data. A hyperlink can also take you to another report as previously demonstrated.

170 DB2 Web Query for System i

Page 189: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch09OLAP.fm

10.2 Defining OLAP metadata using the Developer Workbench

1. If you have not yet started working with Developer Workbench please see Chapter 9, “Configuring Developer Workbench” on page 163.

The first thing that we need to do before a user can OLAP enable a report is define any hierarchies that are present in our data. This is done once by a developer and is automatically used by DB2 Web Query whenever any user in future asks to OLAP enable a report that references tables containing these hierarchies.

2. Start Developer Workbench and expand down the following tree:

– DB2 Web Query Environments

– System name

– Data Servers

– EDASERVE

– Applications

– Baseapp

Remember that the term synonym is synonymous with Metadata. To define a hierarchy we need to edit the metadata for a table. This is done through the Synonym Editor.

3. Right click on the table cen_orders.mas and select the first choice Edit in Synonym Editor.

Measure Measures are numeric fields that you wish to analyze at the various levels of a hierarchy and at various intersection points. For example you might want to analyze sales of video equipment in the United States. This would be the specific intersection or slice of the data that you are interested in. Normally these fields are summed or totalled but they don’t need to be. For example you might want to report your revenue by Country and then drill down to the revenue in the regions that make up the Country. Now the revenue would be summed by Region. You might also want to see the average profit on an order across States or Regions to see if certain areas are offering too deep a discount. In this case profit is an average measure not a summed or totaled measure.

Pivot When you pivot data within a report you typically move a field from a column to a row or vice versa. For example Year might be one of your “by” fields where the different years are listed down the side of your report. If instead you wanted the various years “across” the top of your report you would pivot the field or heading “Year”.

This can be done in multiple ways in an OLAP report including dragging and dropping the field or using the control panel to pivot your data.

Term Definition

Chapter 10. OLAP (Online Analytical Processing) 171

Page 190: DB2 Web Query for System i

7214ch09OLAP.fm Draft Document for Review October 10, 2007 9:57 am

Figure 10-1 Developer Workbench Metadata

4. Select the Modeling View. This is the easiest way to define hierarchies to DB2 Web Query.

Figure 10-2 Developer Workbench Synonym Editor

Note: Notice that the window you just opened shows four tables Orders, Inventory, Plant and Stores even though you only opened the master file or metadata for the Orders table. This tells you that the Orders table was defined on the System i with foreign keys pointing to the Inventory, Plant and Stores tables. When you do this DB2 Web Query automatically pulls in the metadata for all four tables into one “clustered” table.

172 DB2 Web Query for System i

Page 191: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch09OLAP.fm

5. If the Dimension Builder is not visible select “Dimension Builder” from the Synonym menu.

In this view you see the tables and their relationship to the base tables Orders. You can either view the tables as icons or you can view a column list for each table.

Figure 10-3 Dimension Builder

6. Double click on the Inventory table icon to switch to column view. A second double click would revert back to icon mode.

Figure 10-4 Icon or detailed table view

Chapter 10. OLAP (Online Analytical Processing) 173

Page 192: DB2 Web Query for System i

7214ch09OLAP.fm Draft Document for Review October 10, 2007 9:57 am

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 we need to describe this hierarchy to DB2 Web Query.

7. Right click on Dimensions, select Add Hierarchy and select Levels.

Figure 10-5 Add Hierarchy

There are two types of hierarchies one is based on levels and the other is based on parent child relationships. We will be using level hierarchies. The level hierarchy is the example we have been using so far i.e. Country, Regions, State, City is a level hierarchy.

For more information on different types of hierarchies see the Developer Workbench help text.

8. Right click on your new dimensions icon and select Rename. Change the name to Product Hierarchy.

9. Starting at the top of the hierarchy (Product Type), drag the column name and drop it on Product Hierarchy. Repeat for each of the three levels.

Figure 10-6 Product Hierarchy

Tip: A quicker way to achieve the same result is to use the circled icon at the top of the Dimension Builder.

174 DB2 Web Query for System i

Page 193: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch09OLAP.fm

10.Define the Date dimension shown in Figure 10-7.

Figure 10-7 Date Dimension

11.Continue with defining the Plant hierarchy and the Stores hiearchy as shown in Figure 10-7.

Figure 10-8 Developer Workbench Multiple hierarchies for OLAP

12.If you do not see the additional date fields such as ORDERDATE_YEAR you need to decompose your date as explained in the section 12.1.1, “Date Decomposition” on page 228.

13.Save your definition.

Chapter 10. OLAP (Online Analytical Processing) 175

Page 194: DB2 Web Query for System i

7214ch09OLAP.fm Draft Document for Review October 10, 2007 9:57 am

You have now completed the all the definition required for OLAP enabling your reports. Typically this will be done once by the IT department. After this, any user with authority to create reports will be able to choose to OLAP enable their report.

It is honestly as easy as this to define a hierarchy in your data and create the necessary metadata to be able to OLAP enable your reports for detailed analysis.

10.3 Enabling an OLAP report (OL1_Revenue)

1. Open (not Run) your original RA1_Revenue report in your Tutorials folder.

2. Select the Report Options tab.

3. Since we know this is a small report let’s turn off the default page numbering.

Figure 10-9 Turning off default page numbering

4. Under the Enable OLAP drop down select Show Tabbed.

Note: OLAP is an optional feature with DB2 Web Query. As you have just seen Developer Workbench, also an optional feature, is a prerequisite for creating OLAP enabled reports. Developer Workbench is the only interface for defining the hierarchies required by OLAP.

176 DB2 Web Query for System i

Page 195: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch09OLAP.fm

5. Under the Automatic drill down select Dimensions and Measures. This will give you the maximum drill down capabilities. When creating your own reports you may simply choose to drill down on the Dimensions and not the Measures.

Note: Enable OLAP Options

The Enable OLAP options control how users can interact with an OLAP report and access OLAP tools

� OFF. Provides an OLAP button to open the OLAP Control Panel. There is no top Selection pane.

� Columns only. Allows you to sort, hide, drag and drop columns. There is no top Selection pane and there is no access to the OLAP control panel.

� Columns with panel. Looks the same as Columns only but when you click the square blue button over a dimension you will open up the OLAP control panel.

� Show filters on top / bottom. This adds the OLAP Selections pane to the top (or bottom) of the report. This option looks fine with a very few dimensions and only a few levels in each hiearchy. It tends to look quite messy when you get too many levels within different dimension. Try it to see the difference between showing dimensions and hierarchies as filters or as tabs.

� Show Panel in Report. This is the same as Columns with Panel but also includes a small OLAP symbol in the lower left to more obviously allow the user to open the OLAP control panel.

� Show Tabbed. For OLAP reports that have multiple dimensions, this option groups the dimension elements under a tab labeled with the dimension name. This is the option we will be using.

Note: Automatic Drill Down Options

� None. The user cannot drill down to a lower level in the hierarchy within the report itself.

� Dimensions. The user can drill down on a dimension to proceed to the next level down in the hierarchy.

� Dimensions and Measures. In addition to drilling down on the dimensions the user can drill down on the measures within the report. This allows the users to drill to the lowest level of all displayed hierarchies.

Chapter 10. OLAP (Online Analytical Processing) 177

Page 196: DB2 Web Query for System i

7214ch09OLAP.fm Draft Document for Review October 10, 2007 9:57 am

Figure 10-10 OLAP enabling a report

6. Save your report as OL1_Revenue.

You have now completed OLAP enabling your report. To summarize, we took a basic report and selected an output option to enable OLAP. This simple selection will automatically give you an enormous amount of analysis capabilities as you will see in the next section.

10.4 Working with an OLAP enabled report

1. Run your OL1_Revenue report.

Figure 10-11 OL1_Revenue Report

Note: If you run your report from the DB2 Web Query home page there is a “maximize” icon to the far right. This sends your report to a new browser window.

178 DB2 Web Query for System i

Page 197: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch09OLAP.fm

Notice the addition of a completely new panel at the top of the report. This is called the Selection Pane. This panel 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 graphs directly from the report. There are three ways to work with your OLAP data: from the report itself, from the Selections pane, and from the Control Panel. In the above report you cannot see the control panel. In this example the control panel starts up hidden or closed. It can be opened via the OLAP button or by clicking on the blue square beside the Product Type heading.

10.4.1 Slicing / Dicing and Drilling Down for more details

2. Notice that the heading for every column either has a blue square or a set of arrows. The blue square allows you to drag and drop the column and to rearrange or pivot it. It also allows you to open up the OLAP control panel. The arrows allow you to sort the measures or numeric fields.

3. Click on the sort arrow to the left of Revenue.

Figure 10-12 Sorting a Measure

4. Because Revenue was previously unsorted neither half of the arrow was dark and the prompt read “sort Revenue”. Now that you have sorted by Revenue hover over the column again. Notice that the bottom half of the arrow is dark indicating that if you click on it you will sort in descending sequence. Try this.

Figure 10-13 Sort from highest to lowest

5. Right-click on the column heading Revenue to bring up a context menu.

Tip: The first thing that you will learn when working with an OLAP enabled report is there are multiple ways to accomplish the same end result.

Chapter 10. OLAP (Online Analytical Processing) 179

Page 198: DB2 Web Query for System i

7214ch09OLAP.fm Draft Document for Review October 10, 2007 9:57 am

Figure 10-14 Measures context menu

6. Notice that this was another way we could have sorted Revenue.

7. From the context menu select Visualization. As we saw in Active Reports selecting Visualization displays bars to help you quickly note trends or to easily compare two columns.

Figure 10-15 Revenue visualization

8. Select the Store Hierarchy tab.

Selecting the Store Hierarchy tab brings up a drop down tab for each element in the hiearchy proceeding from the top of the hierarchy to the bottom.

9. By default each of the drop down list boxes contain all the unique values for that column. For example, initially every region in the world would be available under the region tab. To start to filter and drill down on your data use the Country drop down list and select United States.

Note: Positive numbers are visualized with blue bars while negative numbers are visualized with red bars.

Tip: You can select multiple values using the control or shift keys.

180 DB2 Web Query for System i

Page 199: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch09OLAP.fm

Figure 10-16 Selecting a hierarchy

10.Look at the Region drop down list. Notice that the only regions displayed are for the United States. Select the North region.

Figure 10-17 Continuing to filter within hierarchy

11.Your filters in the Selection Pane do not take effect until you press Run. Have a look at your current totals and select Run.

Figure 10-18 Run your filtered report

Your report will now show the revenue and number of orders for the North region in the United States.

12.Notice that immediately to the right of COUNTRY and REGION was an equal sign. Click this button. Basically each time you fill in a value you are filtering your data by creating a WHERE clause. Instead of selecting COUNTRY equal to United States we could have selected all countries except the United States by changing the button to a not equal. Press the button multiple times and cycle through your choices.

13.Use the reset button to reset the report back to its initial state. We could also have used the back arrow on our browser to go back one screen at a time.

14.Select the Product Hierarchy tab but don’t select any drop down lists.

Chapter 10. OLAP (Online Analytical Processing) 181

Page 200: DB2 Web Query for System i

7214ch09OLAP.fm Draft Document for Review October 10, 2007 9:57 am

Figure 10-19 Drill down on Product Type

15.Let’s try to drill down within the report instead of via the hierarchy tabs. Click on Audio.

Figure 10-20 Drill down on Product Category

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.

16.Now drill down on Amplifiers to see the actual Products that compose the Amplifier category.

Figure 10-21 Results of Product Category drill down

Again notice that the dropdown 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.

182 DB2 Web Query for System i

Page 201: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch09OLAP.fm

17.Continuing to analyze our data we now want to drill down to see only the Amplifier sales that occurred in January 2007. Select the Date Dimension tab.

Figure 10-22 Selecting values in non consecutive levels

18.Select the Year 2007. You can then select the quarter or go straight to month and select 01. Press Run.

Figure 10-23 Slice of your data (January 2007)

19.Press reset to start back at the beginning with an unfiltered report.

20.This time we will see what happens when we drill down on a measure or total field. Drill down on the Revenue column for Office products.

Figure 10-24 Drill down on a measure

21.After drilling on the revenue for Office products the Office product type gets expanded to its sub categories and products. Revenue and Order count are now grouped at a much more detailed level.

Figure 10-25 Results of drilling down on a measure

22.Reset your report now so that all drill downs are removed.

Chapter 10. OLAP (Online Analytical Processing) 183

Page 202: DB2 Web Query for System i

7214ch09OLAP.fm Draft Document for Review October 10, 2007 9:57 am

The next request from our users is to generate a report that shows revenue by product type by year.

23.Drag ORDERDATE_YEAR from the Selections pane into the area of the report where you want it i.e. across the top. The plus symbol shows you that you are in a valid area to drop the field.

Figure 10-26 Drag and drop dimensions

24.Right click on Order Count and choose Hide from the submenu.

Figure 10-27 Hiding a field

25.We now have a very nice pivot table. If you decide that you would prefer 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 will direct you to where you can validly drag and drop the field.

Figure 10-28 Pivot report

26.It is now time to save our new pivot report. Press the save button.

27.See what happens when you save to MS Excel and PDF output formats.

184 DB2 Web Query for System i

Page 203: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch09OLAP.fm

28.To save your new version of your OLAP report select Save Report.

Figure 10-29 Saving an OLAP report

29.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.

Figure 10-30 Saving a report to your folder

Our users have now changed their minds and decided that they don’t want a pivot table. Instead they would like to see the year and product type to the left of revenue.

30.Drag ORDERDATE_YEAR from the Sort across portion of the report to the Sort by section.

Figure 10-31 Pivot a column

In addition to dragging and dropping from the Selection pane area there are other methods to display additional columns in the report.

Chapter 10. OLAP (Online Analytical Processing) 185

Page 204: DB2 Web Query for System i

7214ch09OLAP.fm Draft Document for Review October 10, 2007 9:57 am

31.Right click on ORDERDATE_YEAR and then select Unhide. You will 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.

Figure 10-32 Unhide columns

32.Try the same process on the Revenue field. Notice that here you only see the numeric fields that are available to you.

33.Click on the down tab for Measures. You will see a list of all the measures available to you in this report. Notice that Order Count has no check mark. This is because we hid it. To display Order Count simply check it again.

34.Click on the box next to revenue. Notice that you can cycle through the different options for displaying, visualizing and hiding the measure. We want to visualize Revenue and display Order Count and then Run the report again.

Figure 10-33 Measures tab

35.Select the graph tab drop down menu. Check Revenue and then cycle through the graph types on the right until you come to pie charts. Press Run.

186 DB2 Web Query for System i

Page 205: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch09OLAP.fm

Figure 10-34 Graphing an OLAP report

36.Make the pie chart window larger by dragging down the horizontal break line between the graph and the report.

37.Notice that there is one pie chart for each year which was your major sort by axis.

If the measures in the original report were drill down capable then the graph can be drilled into.

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 2007 revenue you could select the year 2007 from the ORDERDATE_YEAR drop down list.

Chapter 10. OLAP (Online Analytical Processing) 187

Page 206: DB2 Web Query for System i

7214ch09OLAP.fm Draft Document for Review October 10, 2007 9:57 am

Figure 10-35 Graph drill down

38.Drilling down on the graph generates the same report as if you had drilled down on the revenue field in the original report.

39.Experiment with the various options for drill down and filtering your report. When you are finished press reset to restore the report to its original values.

10.4.2 Using the OLAP Control Panel

So far we have manipulated the OLAP report through the Selection pane at the top of the report and directly through hyperlinks in the report itself. We are now going to use the third method for interacting with the data and that is via the OLAP control panel.

1. Select the OLAP button at the bottom of the Selections pane to open the OLAP control panel. Alternatively, you could have clicked on the blue square next to Product Type.

Tip: If our 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 our report contained profit, you could superimpose a line graph on a bar graph with the line representing the profit and the bar representing revenue.

188 DB2 Web Query for System i

Page 207: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch09OLAP.fm

Figure 10-36 OLAP Control Panel

Although the most frequently used functions are available directly from an OLAP report and/or from the Selections pane, several can only be performed from the Control Panel. The control panel can do everything that can be done from the OLAP report and the Selections pane and more.

Here are some of the unique OLAP functions that can only be performed from the Control Panel.

– Selecting a Top or Bottom n rows report

– Ability to group numeric data by percentile (or decile, quartile, etc.)

– advanced row selection criteria

– Stacking multiple measures vertically in a report as opposed to horizontally

Next we want to see our data in columns by quarter.

2. Expand the Date dimension.

3. Click on the Drill Across box. When selected it should be surrounded by a blue rectangle.

4. Now click on the ORDERDATE_QUARTER field. It should appear in the Drill Across box.

Tip: If your OLAP control panel shows the selection criteria pane press OK to get back to the view shown in Figure 10-36.

Tip: If Quarter appears in the Drill Down box by accident simply highlight it and use the Pivot button to pivot Quarter from rows to a columns.

Chapter 10. OLAP (Online Analytical Processing) 189

Page 208: DB2 Web Query for System i

7214ch09OLAP.fm Draft Document for Review October 10, 2007 9:57 am

Figure 10-37 Working with the OLAP control panel

5. Press Run.

6. Double click on Quarter Q1 to drill down to month.

Figure 10-38 Cross Tab drill down

Often when you have multiple measures and sort across columns the report can become very wide and unwieldy.

7. Open the OLAP control panel and check Stack Measures.

190 DB2 Web Query for System i

Page 209: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch09OLAP.fm

Figure 10-39 Stack Measures

8. Run.

Figure 10-40 Stacked measures report

There is a potential problem with this report as it stands right now. If the Orders table contains data for multiple years we now have the sales for every Q1 added up together. Although this is technically accurate it probably isn’t what the user wanted to see.

9. From the OLAP control panel expand Date Dimension and select Values for ORDERDATE_YEAR. This will open up a selection window.

10.Check the Range box. This isn’t appropriate for our data that only contains records from 2006 and 2007 but it is interesting to see the capability. Uncheck Range.

11.Select Year 2007 and press Add.

Chapter 10. OLAP (Online Analytical Processing) 191

Page 210: DB2 Web Query for System i

7214ch09OLAP.fm Draft Document for Review October 10, 2007 9:57 am

Figure 10-41 Filtering an OLAP report

12.At this point in time you could simply press Run. For demonstration purposes press OK to see the full Selection Criteria panel.

13.Notice that Q1 is prefilled in for the quarter. This is because we had already drilled down and selected Q1 prior to opening the control panel.

14.If you use the scroll bar on the right you will see all the various dimensions and their individual elements or columns that were available through the tabs in the Selection pane. You can continue to filter your data here.

15.If you want to filter on Product Type you have two choices. You can select the drop down arrow next to Product Type or you can click on the Select button. In both cases you will see a list of all the unique values for Product Type. Using the Select button takes you to a second screen. This is easier to use when you are selecting multiple values.

16.Again, when filtering you can modify the operand for each filtered column.

Note: For most dimensions, when you press Values you will see the actual list of values from your table. The date components are prefilled in with general dates. If you expand ORDERDATE_MONTH you will see that the actual month names i.e. June, are filled in for ease of use for the end user.

192 DB2 Web Query for System i

Page 211: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch09OLAP.fm

Figure 10-42 OLAP filtering

17.Without actually filtering on Product Type press Run.

Figure 10-43 2007 only report

18.If you are still on the Selection screen in the OLAP control panel press OK to return to the initial layout. Notice that you can press Selection Criteria in the bottom right of the control panel to return directly to the Selection Criteria layout.

19.Select the Revenue field in the Measures box. Click on the actual field name.

Note: Best practices states that you should always display any filters in effect on a report. DB2 Web Query has the capability from the OLAP panel to document your filters at the beginning or the end of your report.

Chapter 10. OLAP (Online Analytical Processing) 193

Page 212: DB2 Web Query for System i

7214ch09OLAP.fm Draft Document for Review October 10, 2007 9:57 am

Figure 10-44 Working with Measures

If we wanted to see a Top 3 analysis report we would choose the selections shown in Figure 10-45.

Figure 10-45 Top 3 OLAP report

20.Notice that if you expand Measure Calculations you can ask to see the Revenue column in multiple ways. For example you could ask to see each Revenue as a percentage of the product type revenue in that quarter (Row Percent). You can ask to see the average revenue per order and much more.

10.4.3 Grouping Data into Percentiles

The reports and data used in these tutorials do not lend themselves to grouping into tiles (percentiles, deciles, quartiles etc.) but you should be aware that this capability exists.

The example described here starts with a report that simply has one record for each sales rep showing their revenue attainment. The company wants to reward the top 10% of their reps. In other words, if the company had 200 sales reps, they want to know who the top 20 are. If the 20th and 21st salesreps are tied, that would move the 21st sales rep into the top decile (ten percent) as well.

Below are the screen shots involved in this analysis.

Tip: If you wanted to see a report showing your bottom Products by revenue you would choose to sort from Low to High and then rank and select your top 3.

194 DB2 Web Query for System i

Page 213: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch09OLAP.fm

Figure 10-46 Starting report showing sales reps and their attainment

Figure 10-47 OLAP control panel

From the OLAP control panel we highlighted the revenue field (LineTotal1) and pressed the Sort button. This brought up a second panel where we made chose a high to low sort sequence and then pressed the Tile tab. Within the tile panel we specified that we wanted to see our revenue numbers evenly split into ten groups. We wanted the new column with the group number to be called Decile. If we only wanted to see the top 10% we would have asked to restrict the display to the 1st tile only.

If we had wanted to see the top 5% of the sales reps we could have asked the system to split the reps into 20 groups and then we would have picked the top group. We could also have split the reps into 100 groups with 1% in each group. To get the top 5% we would have picked groups 1 - 5.

Chapter 10. OLAP (Online Analytical Processing) 195

Page 214: DB2 Web Query for System i

7214ch09OLAP.fm Draft Document for Review October 10, 2007 9:57 am

196 DB2 Web Query for System i

Page 215: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chHTML.fm

Chapter 11. HTML Layout Painter Tutorial

HTML Layout Painter is a component of IBM Developer Workbench. Prior to starting this set of tutorials you must have completed “Configuring Developer Workbench” on page 164.

HTML Layout Painter is specifically designed, as the name would suggest, to design HTML pages. HTML Layout Painter does not create reports or graphs, rather it references existing ones. You can create compound reports with background style sheets, add company logos and other standard HTML components. The design of the HTML page could be set to match your company intranet standards.

Both HTML Layout Painter and Power Painter can create compound reports. Power Painter is architected for PDF output and has additional controls specific to large PDF reports. It can also create other types of output such as HTML pages. HTML Layout Painter is architected for HTML pages and it can only create HTML pages. It cannot create a PDF report. The products both have very different end user interfaces. You have already tried Power Painter. In this tutorial you will get the chance to try HTML Layout Painter. Choose the one that fits your companies needs the best.

In this tutorial we will design two very different HTML pages. The first will be a compound report with a single input parameter. This style of report can be used as the basis for key performance indicators or KPI dashboards where the user might request the KPIs for a specific country or product type etc. This type of report is often designed by IT and deployed to senior management and executives within a company.

The second report will be a single, very highly parameterized active report. Again, this will be a report typically developed by IT but, in this case, often deployed to business analysts or disconnected users who want to highly segment the data they are analyzing. This tutorial assumes that you have completed the Active Reports tutorial and understand that concept. Here we will be looking at taking an existing active report and initiate it from an HTML page containing a large number of input parameters in an end user friendly manner.

11

© Copyright IBM Corp. 2007. All rights reserved. 197

Page 216: DB2 Web Query for System i

7214chHTML.fm Draft Document for Review October 10, 2007 9:57 am

11.1 Compound Parameterized report (HTML1_KPI)

In the first exercise we will take two graphs and one report created in previous exercises, add a common parameter and bring them all together on one HTML page for the end user. The final page will look like Figure 11-1.

Figure 11-1 Compound report

11.1.1 Adding parameters to existing reports

We will do all our work in this tutorial from Developer Workbench. Report Assistant and Graph Assistant can be run either from the Developer Workbench or from the DB2 Web Query home page.

We need to add product type as a parameter to the three reports that we want on our KPI page. We will modify the existing reports to accept this parameter and then save them under new names.

In the previous chapter you were introduced to the two main functional areas of Developer Workbench. The first leg of the explorer tree expands through Data Servers to allow you to

Note: The generic term report is used for both text reports and graphs. It is also used to refer to the completed HTML page. In the first exercise the completed HTML page will be a compound report.

198 DB2 Web Query for System i

Page 217: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chHTML.fm

work with your metadata. The second branch expands down through Managed Reporting to allow you to work with the folder in your domains.

1. Open Developer Workbench. You will see WebFOCUS Environments under Developer Studio Desktop. You may or may not see Windows Desktop. This is an optional setting described in Chapter 9, “Configuring Developer Workbench”.

2. Expand WebFOCUS Environments and then down the reporting leg of the explorer tree.

3. Navigate to the graph titled GA3_Trend in your Tutorials folder. Right click on the report and select Copy.

Figure 11-2 Developer Workbench reports

4. Keeping your cursor in the same panel i.e. the list of your reports, right click and select Paste. You should now have a report titled GA3_Trend1.

5. Right click on your new report and select Rename. Give the report the name HTML1_KPI_LINE.

6. Right click on HTML1_KPI_LINE and select “Edit in Developer Studio Tool”.

Restriction: Report Assistant, when accessed via Developer Studio, does not currently support the “Save as” capability. This is a known requirement. As a workaround we will Copy and Paste the report into the same directory.

Tip: Even though you have renamed the report on the screen to HTML1_KPI_LINE if you look in the IFS or look at the properties of the new report you will see that the object name is still ga3_trend1.fex. You have just changed the display title of the report not the physical name on disk.

Chapter 11. HTML Layout Painter Tutorial 199

Page 218: DB2 Web Query for System i

7214chHTML.fm Draft Document for Review October 10, 2007 9:57 am

Figure 11-3 Edit in Developer Studio Tool

7. DB2 Web Query knows what tool was used to create your report. Taking the default option will open the report in either Report Assistant or Graph Assistant, whichever is appropriate. Power Painter is not directly supported in Developer Workbench. In this example Graph Assistant will open.

8. Within Graph Assistant choose the Selection criteria tab.

9. Delete all existing selection criteria.

10.Drag and drop PRODUCTTYPE onto the Selection panel, choose Select values, select Parameter and then Auto Prompt.

11.Accept all the defaults for PRODUCTTYPE prompting.

Figure 11-4 Selection criteria and parameter prompting

12.Press OK twice.

Figure 11-5 Completed selection criteria

We are going to remove the months from the X axis labels. This will free up more room in our small output frame for the graph itself.

13.Select the Properties and then the X axis tab.

200 DB2 Web Query for System i

Page 219: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chHTML.fm

14.Uncheck the Show axis labels checkbox.

Figure 11-6 Removing X axis labels

15.Under the Properties tab select the Options tab.

16.From experience we know that the frame for our graph will be about 350 pixels wide by 250 pixels high. This can be an iterative process. You may need to design your actual 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.

Figure 11-7 Properties tab

17.Save your graph.

Next we will basically repeat the above steps for the existing bar chart GA1_Bar. If you need more detailed assistance refer to the previous steps and figures.

18.Copy and paste the GA1_Bar and rename it HTML1_KPI_Bar.

19.Add a PRODUCTTYPE parameter, accepting the auto prompting defaults. Your report should have only one parameter.

20.Set the output size to 350 pixels wide by 250 pixels high.

21.To save space for our graph, remove the X axis field label Country from the Show - Field options panel under the Field selection tab.

Chapter 11. HTML Layout Painter Tutorial 201

Page 220: DB2 Web Query for System i

7214chHTML.fm Draft Document for Review October 10, 2007 9:57 am

Figure 11-8 X axis field label

22.Save your graph.

11.1.2 HTML Layout painter

23.Navigate to your Tutorials folder in the reporting leg of the Developer Workbench explorer window.

24.Right click on the Tutorials folder, Select New and HTML File.

Figure 11-9 New HTML File

25.Call your new report HTML1_KPI and press Create.

26.The final layout design of our compound report is show in Figure 11-10.

Tip: To create a text report or graph you would select New - Procedure. You would then see a screen that would allow you to choose between using Report Assistant, Graph Assistant or the SQL Wizard to create your new report.

202 DB2 Web Query for System i

Page 221: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chHTML.fm

Figure 11-10 Design layout for HTML report

The instructions below reference Figure 11-10 unless otherwise specified.

Including a line chart27.Select the graph icon from the toolbar.

Figure 11-11 HTML Layout toolbar

28.Draw a box similar to box 1 in Figure 11-10. Look at the properties box in the right hand panel. Your box should be 250 pixels high and 350 pixels wide. This is the size we designed our graph for.

29.Right click in box 1 and select “Reference existing procedure”. This will not only show us what the graph will look like in this frame but it will also reference any parameters used by the graph.

1 2

3

Chapter 11. HTML Layout Painter Tutorial 203

Page 222: DB2 Web Query for System i

7214chHTML.fm Draft Document for Review October 10, 2007 9:57 am

Figure 11-12 Reference existing procedure

30.Open your HTML1_KPI_Line in the Tutorials folder. Notice the actual file name displayed.

Figure 11-13 Procedure being referenced

31.The system will present you with a list of the parameters used in HTML1_KPI_Line.

32.Accept the default control type of Drop down list.

33.Change the parameter grouping option to “Do not create a form” and click OK.

204 DB2 Web Query for System i

Page 223: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chHTML.fm

Figure 11-14 Defining a parameter

34.Delete the label PRODUCTTYPE. We will reference Product Type in our overall report heading.

35.Move the drop down list and the run button as shown in Figure 11-10. Your run button will look slightly different at this stage.

36.Select the line graph. In the properties panel on the right change the name to LineGraph.

Note: If you had accepted the default “New form element” the system would have created one panel containing your parameter label, the drop down box, a run button and a refresh button.

We said no to this because we want to be able to move each of these elements separately on our page.

Chapter 11. HTML Layout Painter Tutorial 205

Page 224: DB2 Web Query for System i

7214chHTML.fm Draft Document for Review October 10, 2007 9:57 am

Figure 11-15 Setting the name property

37.Select (click) the drop down control box in the report.

38.Select the Parameter tab in the bottom right corner.

39.Check the Add “All” option and specify “All Products” to be displayed.

206 DB2 Web Query for System i

Page 225: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chHTML.fm

Figure 11-16 Adding the “ALL” option to a parameter

Including a bar chart40.Select the graph icon.

41.Draw a box or frame similar to box 2 in Figure 11-10.

42.Select the Properties tab at the bottom of the right pane. Right click on the new graph frame and select “Reference existing procedure”.

43.Select HTML1_KPI_Bar.

44.To make the two graph frames the same size you can use the properties box and manually size the frames to both be 250 x 350. The other alternative is to select frame 2 and then also select frame 1 using the control key and click the “Make same size” icon . Notice that it is the LAST element selected that controls the final size of all the selected elements.

45.Again select frame 2 and then frame 1 and click the “Align top” icon .

46.In the properties panel on the right change the name to BarGraph.

Chapter 11. HTML Layout Painter Tutorial 207

Page 226: DB2 Web Query for System i

7214chHTML.fm Draft Document for Review October 10, 2007 9:57 am

Including the gross profit report (RA4_Advanced)

Figure 11-17 HTML Layout Painter toolbar

47.Select the report icon as shown in Figure 11-17.

48.Draw a box similar to box 3 in Figure 11-10.

49.Right click on the frame and point to the RA4_Advanced report.

50.In the properties panel on the right set size and scrolling to No. This will automatically adjust the size of your frame so that your report will fit in it and you do not need to scroll within the frame.

51.In the properties panel on the right change the name to GrossPftReport.

HTML page optionsTo make this page look a little cleaner we want to remove the frames around each of the reports.

52.Highlight each of the three reports and from the properties box on the right set Frame border to No.

53.To have the all three reports in our compound HTML page automatically run when the page is opened highlight each of the three reports and from the properties box on the right set Auto Execute to True.

Next we want to give our report a title.

54.Select the text icon.

Figure 11-18 Adding text to an HTML page

55.Draw a box on the screen where you wish your report title to be.

56.Enter the text “Product Type Indicators”.

57.Click on your text box so that it is surrounded by a straight line frame and not slashes.

58.On the properties panel on the right select the ellipsis next to Styling: Font.

59.Select the styling for your heading: arial, 18pt, bold, underlined, blue.

RUN button executionThe last thing we will do is tell the system what reports need to execute when the Run button is clicked.

208 DB2 Web Query for System i

Page 227: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chHTML.fm

60.Right click on Run button and choose hyperlink properties.

61.Change the display text to RUN and appropriately size the RUN button.

62.Select the add icon on the right.

The RUN button is initially set to execute the original report that was used to import the parameter. We need to tell it to also execute our other two reports when the user presses RUN.

63.To add the second graph choose the Action “External procedure”.

64.Under Source click the ellipsis, and navigate to and select HTML1_KPI_Bar.

65.Specify a Target Name of BarGraph to indicate which frame the report should run in.

66.Repeat the process and select the external procedure RA4_Advanced and point it to the frame GrossPftReport.

67.Your hyperlink Properties should look like Figure 11-19.

Figure 11-19 Hyperlink Properties

68.Save and run your report.

Figure 11-20 Run button

Final Output69.Your dashboard or KPI (key performance indicators) should look like this.

Tip: You could return to the DB2 Web Query home page and run this dashboard. The easiest thing for a developer to do is 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.

Chapter 11. HTML Layout Painter Tutorial 209

Page 228: DB2 Web Query for System i

7214chHTML.fm Draft Document for Review October 10, 2007 9:57 am

Figure 11-21 Completed compound report

11.2 Highly parameterized report (HTML2_Parm)

In this exercise we are going to take an active report that we created previously and add multiple parameters to it. This will allow a user to segment the data they wish to analyze in many different ways. Although we will be basing this tutorial on an active report we could have invoked any report or graph. This highly parameterized technique is very effective for subsetting the data a user wishes to download to MS Excel. This exercise will use the Active Report AR1_GrossPft which can be seen in Figure 11-22. You may want to quickly run this report and make sure that it looks like the figure below.

210 DB2 Web Query for System i

Page 229: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chHTML.fm

Figure 11-22 AR1_GrossPft Active Report

1. The first step in this exercise is to open Developer Workbench and navigate down the Managed Reporting branch to the Tutorials folder. Locate the AR1_GrossPft report and create a copy of it using copy and paste on the right click submenu.

2. Rename the new copy to HTML2_Parm_AR.

3. Open the new report.

Figure 11-23 Open report in Developer Workbench

Tip: If your active report is in accordion format open the report, go to Report options, choose Active Report Styling and select Report view Tabular. Save your report.

Chapter 11. HTML Layout Painter Tutorial 211

Page 230: DB2 Web Query for System i

7214chHTML.fm Draft Document for Review October 10, 2007 9:57 am

4. Choose the selection criteria tab and enter, in sequence, the following parameters. Based on the table below all the conditions are WHERE conditions. The table shows you the field name to drag onto the selection criteria palette and the condition to use. For all parameters you will click on “Select values”. In all but ORDERDATE you will then select the autoprompt wizard. On the autoprompt screen choose “select multiple values” before you press OK.

5. For the date fields, instead of using the autoprompt wizard simply enter a parameter name that you wish to use. We will use From_Date for the first date parameter and To_Date for the second date parameter.

Figure 11-24 Date parameter

Your finished selection criteria panel should look like Figure 11-25.

Fieldname Condition Select values

WHERE PRODUCTTYPE EQUAL to � select parameter, � autoprompt� select multiple values

WHERE PRODUCTCATEGORY EQUAL to � select parameter, � autoprompt� select multiple values

WHERE SALESREP EQUAL to � select parameter, � autoprompt� select multiple values

WHERE COUNTRY EQUAL to � select parameter, � autoprompt� select multiple values

WHERE REGION EQUAL to � select parameter, � autoprompt� select multiple values

WHERE STATE EQUAL to � select parameter, � autoprompt� select multiple values

WHERE PLANTNAME EQUAL to � select parameter,� autoprompt� select multiple values

WHERE ORDERDATE GREATER THAN or EQUAL to

� select parameter� Enter field name From_Date

under Parameter(do NOT autoprompt)See Figure 11-24

WHERE ORDERDATE LESS THAN or EQUAL to

� select parameter� Enter field name To_Date under

Parameter(do NOT autoprompt)

212 DB2 Web Query for System i

Page 231: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chHTML.fm

Figure 11-25 Selection criteria parameters

6. Save and close the report.

11.2.1 Creating the report in HTML Layout Painter

7. Navigate to the Tutorials folder in Developer Workbench.

8. Right click on Tutorials, select New and HTML File.

Figure 11-26 Creating new HTML File

9. Enter a report name of HTML2_Parm.

Chapter 11. HTML Layout Painter Tutorial 213

Page 232: DB2 Web Query for System i

7214chHTML.fm Draft Document for Review October 10, 2007 9:57 am

Figure 11-27 New report name

In this example we will be creating an HTML page that contains the various parameters and a Run button. When pressed the Run button will open a new window containing our active report. We need to import the report onto our HTML page so that DB2 Web Query will automatically bring in all the parameters defined in the report and save us of having to add them manually. We will remove the report frame itself once we have all the parameters imported.

10.Select the report icon and draw a small box in the upper left corner of the screen.

Figure 11-28 Importing a report

11.Right click on the report and select “Reference existing procedure”.

Figure 11-29 Link to existing procedure

12.Select the HTML2_Parm_AR report that you just created.

214 DB2 Web Query for System i

Page 233: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chHTML.fm

You will be presented with a list of parameters referenced by this report.

Figure 11-30 Select parameter control types

13.Change the control type for SALESREP to a Double list control.

14.Change the control type for COUNTRY to a Radio button.

15.Change the control type for PLANTNAME to Check box.

16.Change the control type for both dates to Calendar.

17.Choose the grouping option “Do not create a form”.

18.Next the system will lay out all your chosen parameters in a column on your HTML page similar to the layout in Figure 11-31.

Chapter 11. HTML Layout Painter Tutorial 215

Page 234: DB2 Web Query for System i

7214chHTML.fm Draft Document for Review October 10, 2007 9:57 am

Figure 11-31 Imported parameters

19.Making sure that you keep the headings and controls together, drag the parameters into a layout similar to Figure 11-32. You will need to scroll to see the entire page of parameters. See following instructions for sizing the Country control box.

20.Make sure that you leave enough room at the top of the report for a report heading.

21.Some of the boxes such as SALESREP will need resizing. Keep any frames that are within a panel, in the panel when they are moved or resized.

216 DB2 Web Query for System i

Page 235: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chHTML.fm

Figure 11-32 Rough layout for parameters

We want to change Country from being one column wide to two columns wide.

22.Highlight the Country control box.

23.From the properties panel select columns and enter “2”.

24.Size the control box appropriately.

Note: This exercise is designed to introduce you to many of the controls and capabilities of HTML Layout Painter. Is it not expected to be used to teach screen design. Do NOT design a screen that has this many different controls and looks like this in production applications.

Chapter 11. HTML Layout Painter Tutorial 217

Page 236: DB2 Web Query for System i

7214chHTML.fm Draft Document for Review October 10, 2007 9:57 am

Figure 11-33 Two column radio control box

Parameter controls25.Highlight the Product Type control box.

26.On the properties panel to the right select Tab index and enter “1”. Tab index controls the sequence the cursor moves from field to field.

Figure 11-34 Properties Tab

27.Select the tab Parameters at the bottom of the right hand panel. This is where you could override options such as your type of control box or the text to go with the ALL option. Select the add “ALL” option for every parameter except the dates.

28.Highlight the Product Category control box.

29.Select the properties tab, and enter the value “2” under Tab index.

Chaining controls togetherWe want to set up our parameters so that the value selected for product type modifies (filters) the values displayed in the product category drop down box.

30.Click the product type control box, holding down the shift key also select Product category.

31.Click the add chain button shown in Figure 11-35. This will chain the parameters together in the sequence you selected them.

218 DB2 Web Query for System i

Page 237: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chHTML.fm

Figure 11-35 Chaining parameters

32.Highlight the Salesrep control. In the properties panel specify Tab index “3”.

33.Highlight the Country control. In the properties panel specify Tab index “4”.

34.Highlight the Region control. In the properties panel specify Tab index “5”.

35.Highlight the State control. In the properties panel specify Tab index “6”.

36.We want the Country parameter to control or filter the Region parameter and we want the Region parameter to filter the State list box. To chain Country to Region to State, select the Country control box, hold down the shift key, select the Region control box, still holding down the shift key select the State control box. Click the add chain button shown in Figure 11-35.

37.Highlight the Plantname control. In the properties panel specify Tab index “7”

Using calendar controls38.Right click the calendar beside From_Date and select Calendar Properties.

39.Select static dates ranging from Jan 1 2006 to Dec 31 2007.

40.Select date format YYMD.

41.Highlight the From_Date control. In the properties panel specify Tab index “8”.

42.Repeat these calendar control steps for To_Date using a Tab index of “9”.

Tip: If you right click on a control box that is chained to another control you can override the chaining logic. The default in our example is to show all product categories that have a product type EQUAL to what the user selected. You could have chosen any relationship to the controlling parameter i.e. Less than, greater than etc. In our example EQUAL is really the only choice that makes sense and it is always the default.

Tip: The more common calendar option is probably relative dates i.e. within the last two years. Since our data only contains dates in 2006 and 2007 we chose the static dates for this example.

Chapter 11. HTML Layout Painter Tutorial 219

Page 238: DB2 Web Query for System i

7214chHTML.fm Draft Document for Review October 10, 2007 9:57 am

Figure 11-36 Calendar controls

43.Right click the “Run report1” control box and select Hyperlink properties.

44.Change the Display Text to RUN.

45.Change the Target Type to Window. This will run the report in a new window instead of in the frame drawn on the current HTML page.

Figure 11-37 RUN button hyperlink properties

46.Delete the original frame you drew when importing the report. It will be located below all the parameters.

47.Select the RUN control box. Change the Tab index on the properties tab to “10”.

48.Resize the RUN button by dragging the frame.

Next we need to add a heading to our report.

49.Click on the text icon on the toolbar and draw a box to contain your heading.

220 DB2 Web Query for System i

Page 239: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chHTML.fm

Figure 11-38 Adding text to a page

50.Enter a title of “Gross Profit Active Report”.

51.Click on your text box so that it is surrounded by a straight line frame and not slashes.

52.On the properties panel on the right select the ellipsis next to Styling: Font.

53.Select the styling for your heading: arial, 18pt, bold, underlined.

Figure 11-39 Styling text

54.Click on the background area of the HTML. On the properties tab select the ellipsis next to Background color and choose a pale color.

Note: In addition to text and reports you can import images to your page using the icon to the left of the text icon. You can use define cascading style sheets to tailor the look of your page.

Chapter 11. HTML Layout Painter Tutorial 221

Page 240: DB2 Web Query for System i

7214chHTML.fm Draft Document for Review October 10, 2007 9:57 am

Figure 11-40 Background color

55.Almost done. When we modified all the parameter control boxes we changed the tab index in the properties box. This controlled the sequence that the users would tab through the fields on the screen. We still have a problem in that some of the other elements on the page have a tab index that may conflict or proceed our sequence numbers. Starting with the title, highlight the frame, and find the tab index number. If it is less than or equal to 10 change it to an arbitrary number above 20. Our Run button had a tab index of 10 and we want it to be the last in our normal sequence. Don’t forget to check the arrow elements in Salesrep.

56.Save and run the report.

57.For our first test simply select ALL for Salesrep and January 1, 2006 to December 31, 2006 for the dates.

Tip: If you hover over the icon second from the left that looks like a hand and multiple small boxes you should see the text “Tab Order”. Selecting this will show you the sequence of your tabs for the end user. Make sure that you don’t have duplicates and the order is left to right top to bottom for INPUT capable fields.

Tip: Having chosen the double list control for Salesrep means that you will always have to select at least one item for SALESREP. This could be ALL but there needs to be a value in the output list.

222 DB2 Web Query for System i

Page 241: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chHTML.fm

Figure 11-41 Prompting for Parameters

58.Click RUN.

Chapter 11. HTML Layout Painter Tutorial 223

Page 242: DB2 Web Query for System i

7214chHTML.fm Draft Document for Review October 10, 2007 9:57 am

Figure 11-42 Final output

59.Now try and run the report taking advantage of the parameter chaining. Selecting a product type will change the product categories list box. Similarly choosing a region will change the state displayed.

60.For the final step go back to your parameters design page and start tailoring the page to look like something you might actually show to an end user.

224 DB2 Web Query for System i

Page 243: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chMRDextra.fm

Chapter 12. Additional Developer Workbench features

This chapter will cover the following additional features of Developer Workbench:

� Synonym Editor

– metadata

– date decomposition

– creating filters

– joining tables

– business views

– impact analysis

– data profiling

� SQL Wizard

Each feature above has a short tutorial to introduce you to the feature. There are many more capabilities within each of the features than is described in this chapter. See the on-line help text in Developer Workbench for more details.

12

© Copyright IBM Corp. 2007. All rights reserved. 225

Page 244: DB2 Web Query for System i

7214chMRDextra.fm Draft Document for Review October 10, 2007 9:57 am

12.1 Synonym editor

DB2 Web Query can create basic metadata from the DB2 Web Query home page or via the Synonym Editor in the optional, but highly recommended, Developer Workbench tool. Once the basic metadata exists you must use the Synonym Editor if you wish to enhance the metadata or take advantage of some of the more advanced metadata capabilities. Within the synonym editor you can change the way a field is displayed to the end users. In our previous examples if we had added commas and floating decimal signs to LINETOTAL in the metadata and then the developers would never have needed to do this in the individual reports. Other examples include converting date formats, converting alpha to numeric fields or even changing the length of a field. The synonym editor also allows you to create new calculated fields for the end users. This includes the easy ability to break dates down into their various components. If you plan on using the optional OLAP feature you will need to define your hierarchies or dimensions through the synonym editor. More details on defining hierarchies for OLAP use can be found in Chapter 10, “OLAP (Online Analytical Processing)” on page 169.

1. To start the Synonym editor expand the metadata portion of the WebFOCUS Environments. In other words navigate down the Data Servers leg and select baseapp. Highlight the table that you wanted open in the Synonym editor, in our case it will be cen_orders, and right click on the file name.

2. Select Edit in Synonym Editor.

Figure 12-1 Starting the Synonym editor

This will present a screen showing the different attributes of the table that are stored in the metadata.

Tip: Basic synonyms can be created from within Developer Workbench using the same routines that are used from the DB2 Web Query home page. Right click on baseapp and select new and then Synonym to invoke the metadata creation screens.

226 DB2 Web Query for System i

Page 245: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chMRDextra.fm

Figure 12-2 Metadata: Orders master file

3. Have a look at the file attributes available. Some of the attributes, such as DBSPACE are not applicable to DB2 for i5/OS.

4. Highlight LINETOTAL to see the field’s metadata attributes displayed.

5. In this example we want to specify that, by default, LINETOTAL will display in reports with commas and a floating dollar sign.

Figure 12-3 Field/column level attributes

Note: The synonym editor does not allow you to make any changes that would render the Master file unusable.

Chapter 12. Additional Developer Workbench features 227

Page 246: DB2 Web Query for System i

7214chMRDextra.fm Draft Document for Review October 10, 2007 9:57 am

Another interesting attribute on this display is the USAGE attribute. To demonstrate this we will use the ORDERDATE field. Highlight and select ORDERDATE.

Figure 12-4 Date field attributes

ACTUAL refers to how a column is stored in DB2 for i5/OS. USAGE refers to how the end user sees and works with a column. USAGE allows us to override or change the length and attributes of a column from how it is stored and displayed by default.

For many System i customers, USAGE becomes very important for date fields. If you have a field defined to DB2 as an integer 8 field that happens to contain the value 20070901 there is no automatic way for DB2 Web Query to know that this is a date field. The ACTUAL for this column would display as integer 8. Using the very powerful USAGE attribute allows you to specify a USAGE of type Date with a format of YYMD. This now enables many of the date and time functions, calculations and formatting options available in DB2 Web Query to work with your integer field.

12.1.1 Date Decomposition

In many of the reports we have created so far we have had to take our date field and break it down into years, quarters and even months. This is a very common requirement. To save having to do this manually in every report DB2 Web Query provides you with a feature to automatically decompose the date in the synonym editor.

6. Right click on the ORDERDATE field and select “Decompose Date”.

Tip: The display in Figure 12-3 also allows users to specify a description and title for a column. User’s can set up multiple titles for a column based on the language of the end user. Selecting the ellipsis (three dots) next to these attributes allows you to specify which title you want displayed based on the language chosen.

228 DB2 Web Query for System i

Page 247: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chMRDextra.fm

Figure 12-5 Decompose date column

7. Select all four sub components of ORDERDATE to be created for you.

Figure 12-6 Decomposed date

8. Notice that the system has generated four new fields for the user’s to access.

Figure 12-7 Results of Decomposing a date

Note: You could have manually created these fields by right clicking on a column or the table and specifying Add, Virtual column. This would allow you to create any new column that you would have normally created during the report definition stage. Creating it here means that it is available to all reports.

Creating a column such as PROFIT, in the metadata, means that the definition of the column is standard across all your reports.

Chapter 12. Additional Developer Workbench features 229

Page 248: DB2 Web Query for System i

7214chMRDextra.fm Draft Document for Review October 10, 2007 9:57 am

12.1.2 Additional Date Manipulation

This short section is read only. Our Century database very nicely stores dates in DATE format. We know that many System i customers do not. We have added in here a few suggestions for how you might want to work with dates that are stored in alphameric or numeric formats i.e. 20070914 might be stored as an char 8 field.

The first thing you want to do is highlight your date column, in this case my date field is called DATEA8 and modify the ACTUAL attribute from A8 to A8YYMD assuming that your date is stored like 20070914. You could also modify it to A8DMYY if you stored your date as 14092007. If you have a six character field you would change the YY above to simply Y. In other words tell the system you have a two character year instead of a four character year.

This also works if your date is stored as a numeric or packed field.

Figure 12-8 Defining your current character or numeric date field

Having done this your user’s can now do basic date formatting. In a report the user can choose to format the field as a YYMTRD field. This would print the date in the report as 2007, SEPTEMBER 14. The user can also create separate year, month and day fields from this date.

To get fancier and use various date functions and date arithmetic you need to actually create a true DATE field. To do this you would create a define field with your new date field name, the format would be similar to YYMD and the expression would simply be your original numeric or alpha date field that you had formatted like A8YYMD.

Figure 12-9 Redefining a character date

In the example above you can now use the field PROPERDATE to do date arithmetic or use date functions such as adding 7 business days to a date or finding the end of the next quarter. These functions are described in the section “Date Functions” on page 325.

230 DB2 Web Query for System i

Page 249: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chMRDextra.fm

If you use two digit years you can use the DEFCENT and YRTHRESH column attributes to define your century. If the year is greater than or equal to the threshold (YRTHRESH) then the two additional significant digits in the year become equal to the default century value (DEFCENT). If your two digit year is less than YRTHRESH then the additional two digits equal DEFCENT plus one.

Assume YRTHRESH equals 40 and DEFCENT equals 19. Any year from 40 - 99 would be translated to 1940 - 1999. Any year from 00 - 39 would be assumed to be 2000 - 2039. If you use a century field you can create your own formula in a define field to calculate a new date field correctly.

If you store year, month and day in individual fields you would first need to create an interim field that had the format of A8YYMD (or A6YMD) and it would equal YRFLD | MTFLD | DAYFLD. You would then take this interim field and create a new date field as was shown in Figure 12-9 on page 230.

Once you have created your new date field this would be the ones that the users would use in all their reports. This format opens up a lot of additional date formatting and arithmetic functions.

12.1.3 Creating filters

You can predefine standard selection criteria in the master file. This allows the criteria to be specified once and used in multiple reports.

9. Right click on the master file name or a field name and select Add, Filter.

Figure 12-10 Adding a filter to a master file

10.In this example we will create a filter called Europe. This will allow us to easily run a report including European only countries.

Chapter 12. Additional Developer Workbench features 231

Page 250: DB2 Web Query for System i

7214chMRDextra.fm Draft Document for Review October 10, 2007 9:57 am

Figure 12-11 Creating a filter

Notice that the filter Europe is defined as an I1 (integer one long) column. This means that we can test if for true or false in our reports.

11.The filter will show up in your list of column names when you are creating a report. Dragging the filter onto the Selection criteria panel generates the “WHERE filter is true” statement by default. This report will now only include the countries defined in the Europe filter.

Figure 12-12 Using a predefined filter

12.1.4 Joining Tables

If you haven’t been able to define foreign keys in your DB2 tables you can accomplish the same result for end users using Developer Workbench. In this example we will start by working with our Orders table without using foreign key support. We will then join this table to the inventory table we have already defined. This will create a “cluster join” where the two tables look like one to the end user.

1. To start we need to create another synonym for our Orders table, this time without selecting Foreign Key support. We can do this either from the DB2 Web Query home page or directly from within Developer Workbench.

Tip: Using the + sign beside a field name to expand it returns a list of distinct values in that field. You can then drag and drop this list of values into your filter expression.

232 DB2 Web Query for System i

Page 251: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chMRDextra.fm

2. Expand your DB2 Web Query server tree down the metadata path and right click on basepp. Select New, Synonym.

Figure 12-13 Creating synonyms from Developer Workbench

3. Since our table is a normal DB2 for i5/OS table stored on our local system choose *LOCAL and OK.

Figure 12-14 Create metadata for local DB2 tables

4. Specify that the candidates for synonyms are the list of tables in the QWQCENT library.

Figure 12-15 Filtering synonym candidates

5. Ensure that the application is baseapp and select only the ORDERS table. Do not select “with foreign keys”.

Chapter 12. Additional Developer Workbench features 233

Page 252: DB2 Web Query for System i

7214chMRDextra.fm Draft Document for Review October 10, 2007 9:57 am

Figure 12-16 Selecting tables

We do not need to create a synonym for the INVENTORY table as we did that in an earlier exercise.

6. After successfully creating the synonym for the ORDERS table Open it.

Figure 12-17 Successful creation of a synonym

7. Right click on ORDERS, select Add, Segment from Existing Synonym.

234 DB2 Web Query for System i

Page 253: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chMRDextra.fm

Figure 12-18 Adding a segment or secondary table

If metadata for INVENTORY hadn’t yet been created you could have selected Add, Segment Via Metadata Import.

8. Select cen_inventory as the table to join to ORDERS.

Figure 12-19 Selecting the secondary join table

DB2 Web Query will create a default join between the two tables.

9. Under SEGTYPE the join will default to Multiple or a one to many join. If you wanted to specify a one to one join you would change Multiple to Unique.

10.To see and possibly modify the join type and join conditions right click on CEN_INVENTORY and select Join Properties.

Note: You can add your join from the Modeling view tab at the bottom of the screen as well as from the Tree View. Most of the steps are identical. From the modeling view, right click on the table icon and select Add, Segment from Existing Synonym.

Chapter 12. Additional Developer Workbench features 235

Page 254: DB2 Web Query for System i

7214chMRDextra.fm Draft Document for Review October 10, 2007 9:57 am

Figure 12-20 Specifying Join Properties

11.Notice that DB2 Web Query has chosen an Inner Join where Product Number from both tables is equal.

12.From this screen you can override the Join Type and Join Conditions you require.

Tip: If you are using the Modeling view you can either click on the file icon or you can double click the arrowed lines between the files to see the Join Properties.

236 DB2 Web Query for System i

Page 255: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chMRDextra.fm

Figure 12-21 Default join

12.1.5 Business Views

Business Views allow you to define a logical view of your data typically to simplify ad hoc reporting for the end user. With business views you can simplify the fields in your master file.

In a view, fields can be grouped into folders for logical partitioning of the data elements. You may choose to have a folder that contains all the elements of an employee’s address or you may want a folder that stores all your filters selected from the master file synonym.

Business views also allow you to specify changes to your underlying table, such as new column headings, format changes etc. These changes are not lost if you need to reimport the underlying table. If you make these changes in the master file for the base or underlying table and you need to recreate the synonym for that table you will lose many of the attributes that you have changed.

Business views also allow you to add define and compute fields to a table so that all users have access to them in their reports. The new define fields or virtual columns could contain system variables such as &DATE or the current user name. The current user name can be retrieved using the GETUSER function.

1. From the synonym editor right click on cen_orders and select Create Business View.

Chapter 12. Additional Developer Workbench features 237

Page 256: DB2 Web Query for System i

7214chMRDextra.fm Draft Document for Review October 10, 2007 9:57 am

Figure 12-22 Creating a Business View

2. You will be presented with a screen where you can create folders (right mouse click) and drag and drop columns, defined fields, computed fields or filters into your view.

3. Create the business view shown in Figure 12-23.

Figure 12-23 Business View

4. This view is now available to the end user creating reports just like the original Orders table cluster was.

Tip: If you create a business view for a user, the user can open Power Painter and drag theentire business view onto the Power Painter palette instantly creating a report that utilizesall the columns in the view. This allows the user to basically create a “one step” report.

238 DB2 Web Query for System i

Page 257: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chMRDextra.fm

12.1.6 Impact Analysis

5. If you are changing a table layout you can use Impact Analysis to determine the effects of the change on existing reports or business views. To find the reports in the Common Domain that would be affected by a change to the Orders cluster navigate to Common domain, right click and select Impact Analysis.

Figure 12-24 Starting Impact Analysis

6. Double click on baseapp to see all our tables and views.

Figure 12-25 Navigating to the master files

7. Open Cen_orders.mas.

Tip: To see all reports affected across all folders and all domains right click one level higher on Domains.

Chapter 12. Additional Developer Workbench features 239

Page 258: DB2 Web Query for System i

7214chMRDextra.fm Draft Document for Review October 10, 2007 9:57 am

Figure 12-26 Selecting a master file

8. At this point you can either analyze the impact of modifying individual fields or simply find any report that references the cen_orders table.

9. Press analyze to find all reports accessing any column in the cen_orders table.

Figure 12-27 Selecting fields and analyzing

10.All reports in the Common Domain that use the Cen_orders table will be listed in the bottom panel.

240 DB2 Web Query for System i

Page 259: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chMRDextra.fm

Figure 12-28 Impact analysis results

12.1.7 Data Profiling

Developer Workbench provides you with the capability of “profiling” your data. This allows you to see both the patterns in the actual text characters. In Figure 12-32 on page 243 you can see the four different patterns of postal codes that you have in your data. These patterns may be perfectly acceptable because the different patterns represent different countries or they may indicate data quality issues. Data profiling also shows you the minimum and maximum values in a column and identifies ten possible outliers. This is done through showing you the ten highest and ten lowest values in a column as seen in Figure 12-33 on page 243.

1. You can profile all the columns in a table by selecting Data Profiling at the file level or you can pick an individual column to profile.

2. Choosing data profiling at the table level may take a while. Every column in the table is analyzed. The system looks at items such as patterns in the layout of the data in a column, average, minimum and maximum values and lengths of the data. The number of distinct values is calculated. The number and percent of null values in a column is also calculated. In our example we will profile all the columns in the cen_orders cluster table.

3. After opening cen_orders in the synonym editor, right click on the table name and select Data Profiling.

Figure 12-29 Data Profiling

4. Selecting data profiling on our cen_orders table produces the summary report shown in Figure 12-30.

Tip: To find the business views that use a specific master file or column open the table in the Synonym editor and right click on the table or column name and choose Impact Analysis.

Chapter 12. Additional Developer Workbench features 241

Page 260: DB2 Web Query for System i

7214chMRDextra.fm Draft Document for Review October 10, 2007 9:57 am

Figure 12-30 Data Profiling results at a table level

5. Notice the fields in blue. These fields are hyperlinks. Click on postal code to see output similar to Figure 12-32. You can profile an entire table, receive this type of a summary, hyperlinked chart and drill down into the various options. Another way of getting to these options is to directly profile the field.

6. Return to the list of columns shown in Figure 12-31. This time we will profile an individual column rather than the entire file.

7. Select POSTALCODE, right click and choose Data Profiling. Notice the different choices you have when profiling a field. Select Statistics.

Figure 12-31 Data profiling selection at a field level

8. You can either see the values and patterns associated with postal code by selecting them from the data profiling submenu or by clicking on the appropriate columns in the output report from the statistical analysis.

242 DB2 Web Query for System i

Page 261: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chMRDextra.fm

Figure 12-32 Data Profiling results at the field level

9. To see data outliers we are going to switch to the QUANTITYINSTOCK column.

10.Return to the screen in Figure 12-33, right click on QUANTITYINSTOCK and select Outliers.

Figure 12-33 Data outliers

11.Data outliers are the ten highest and ten lowest values for a column.

12.2 SQL Wizard

In addition to working with the metadata, Developer Workbench also includes report development tools. You can directly access Report Assistant and Graph Assistant from within Developer Workbench. One developer’s tool that is unique to Developer Workbench is the SQL Wizard.

Chapter 12. Additional Developer Workbench features 243

Page 262: DB2 Web Query for System i

7214chMRDextra.fm Draft Document for Review October 10, 2007 9:57 am

With the SQL Wizard we have three different ways of providing SQL statements to DB2 Web Query. In all cases the SQL statements will be run and the temporary result set will become the input to a query. You can then modify the output with Report Assistant or Graph Assistant. This is a very similar technique to importing Query/400 definitions.

After the report has been tailored with one of the GUI tools it looks like a standard report to the end user. When the user chooses to run the report the actual SQL statement or SQL stored procedure is executed on the System i and the result set is passed to the reporting procedure for formatting and further modifications. The output is then presented to the end user.

1. Before we start using the SQL Wizard we need some SQL to import into DB2 Web Query. Create a file on your PC hard drive called SQLStmt.sql. This file should contain the statement below.

SELECT INVENTORY."ProductType", INVENTORY."ProductCategory", SUM(ORDERS."LineTotal") AS Revenue, SUM(ORDERS."CostOfGoodsSold") AS COGS FROM QWQCENT/ORDERS AS ORDERS, QWQCENT/INVENTORY AS INVENTORY WHERE INVENTORY."ProductNumber" = ORDERS."ProductNumber"GROUP BY INVENTORY."ProductType", INVENTORY."ProductCategory" ORDER BY INVENTORY."ProductType" ASC, INVENTORY."ProductCategory" ASC

Running SQL statements from a file requires the file to be in the DB2 Web Query directories in the IFS. Although there are many ways to copy your SQL statement there, we will use the functionality in Developer Workbench.

2. Make sure that you have Windows Desktop displayed in your Developer Workbench explorer tree. If it isn’t displayed see the Explorer options in “Setting Developer Workbench default options” on page 166.

3. Open your explorer tree to Common Domain, Other Files.

4. Navigating in your Windows Desktop tree highlight SQLStmt.sql and drag and drop SQLStmt.sql from your PC to “Other Files” in Common Domain.

Figure 12-34 Moving PC files to DB2 Web Query directories

Now that we have the SQL we wish to execute on the System i we want to start the DB2 Web Query SQL Wizard.

5. Right click on your Tutorials folder, select New Procedure.

244 DB2 Web Query for System i

Page 263: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chMRDextra.fm

Figure 12-35 Starting the SQL Wizard

6. Create a procedure called SQLReport using the SQL1.

Figure 12-36 Initiating the SQL Report Wizard.

7. Next you will be presented with a screen with three options. Select “Included from an external ‘.sql’ file.

Tip: You could have gone directly to the prompt in Figure 12-36 by using the Quicklinks option of “SQL Based reports and graphs”.

Chapter 12. Additional Developer Workbench features 245

Page 264: DB2 Web Query for System i

7214chMRDextra.fm Draft Document for Review October 10, 2007 9:57 am

Figure 12-37 SQL Report wizard

8. Take the defaults for how to access the database.

Tip: SQL stored procedures are not included in the SQL wizard as importing SQL stored procedures is part of the base product. This can be done through the “Create Synonym” functionality in either the base product or optionally through Developer Workbench.

Note: The three options in the SQL Wizard are:

Include an external .sql file

– The .sql file must be located in the DB2 Web Query directories in the IFS. The SQL statements in the file should generate a single result set.

Type SQL commands directly

– This option allows you to directly enter an SQL command that will create a result set that can be used by DB2 Web Query

Import an existing .sql file and modify

– This is the same as the first option except you are presented with an additional display where you can edit the SQL statements in the file

All options will generate an internal, temporary file to hold the results of the SQL execution called SQLOUT.

246 DB2 Web Query for System i

Page 265: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chMRDextra.fm

Figure 12-38 Accessing DB2 for System i data

9. Navigate to “Other Files” under “Common Domain”.

10.Open your .sql file SQLStmt and press Next to continue.

Figure 12-39 Browse for your .sql file

11.You will be presented with a summary or the options you have chosen.

Tip: Prior to continuing you have the option to test the SQL statement against a limited number of records. The output will be sent, in default html format, to your display.

Chapter 12. Additional Developer Workbench features 247

Page 266: DB2 Web Query for System i

7214chMRDextra.fm Draft Document for Review October 10, 2007 9:57 am

12.From the summary page you have the choice to invoke Report Assistant or Graph Assistant. Instead of selecting a table you wish to query, you will be presented with the output from the SQL.

Figure 12-40 SQL Wizard option summary

13.Notice in Figure 12-41 that the input fields to Report Assistant are the output fields from your SQL execution. You can now choose to format the fields, you can create additional calculated fields such as PROFIT = REVENUE - COGS, you can apply style sheets and anything else that you would normally do to query a table in Report Assistant.

Figure 12-41 Report Assistant with SQL output

14.Make some formatting changes, add a heading and run your report.

12.3 IBM Developer Workbench Summary

Between Chapter 9, “Configuring Developer Workbench”, Chapter 10, “OLAP (Online Analytical Processing)”,Chapter 11, “HTML Layout Painter Tutorial” and finally this section

248 DB2 Web Query for System i

Page 267: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214chMRDextra.fm

Chapter 12, “Additional Developer Workbench features” you have been introduced to many of the features of Developer Workbench. Developer Workbench is a complete GUI development environment. The authors of this redbook highly recommended it for DB2 Web Query developer’s.

CONGRATULATIONS. You have finished all the tutorials for DB2 Web Query. Now it is time for you to start using this query and reporting tool against your own data. We have tried to introduce you to some of the more common features within this product. There are many additional features that we haven’t touched upon. Feel free to experiment and don’t forget that the help text is always there. The help text accessed from Developer Workbench is much more detailed and complete than the basic help text available from the other web components.

Chapter 12. Additional Developer Workbench features 249

Page 268: DB2 Web Query for System i

7214chMRDextra.fm Draft Document for Review October 10, 2007 9:57 am

250 DB2 Web Query for System i

Page 269: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214p04.fm

Part 4 Miscellaneous or Additional Topics

This section covers:

� Migrating Query/400 reports to DB2 Web Query

� Performance Considerations

� Frequently Asked Questions

Part 4

© Copyright IBM Corp. 2007. All rights reserved. 251

Page 270: DB2 Web Query for System i

7214p04.fm Draft Document for Review October 10, 2007 9:57 am

252 DB2 Web Query for System i

Page 271: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch11.fm

Chapter 13. Using DB2 Web Query to run existing Query/400 reports

This chapter discusses the similarities and differences between Query/400 and DB2 Web Query. It discusses some common uses for Query/400 and how DB2 Web Query can also maintain that same functionality. It also shows how to create metadata from your QRYDFN objects so DB2 Web Query can run your existing queries.

13

© Copyright IBM Corp. 2007. All rights reserved. 253

Page 272: DB2 Web Query for System i

7214ch11.fm Draft Document for Review October 10, 2007 9:57 am

13.1 Query/400 - A reliable reporting tool

By now you have probably been exposed to the idea that DB2 Web Query is the intended replacement for Query/400. First of all, this is not to imply that familiar commands such as WRKQRY and RUNQRY are going away. (the product 5722SS1 is going away) You may personally use older, yet robust, technologies that have stood the test of time and are still useful to your business. Likely Query/400 falls into this category and has been a reliable reporting tool that your users have become easily adept with. Query/400 appeals to users because it is easy to learn and does not require programming skills or knowledge in SQL. Also since IBM development has not made recent changes to the Query/400 code, the user interface has remained familiar and code defects are practically non-existent.

DB2 Web Query has the ability to run your existing Query/400 reports without needing to change or run a conversion process on the QRYDFN object. All you have to do is create metadata on the QRYDFN object just as you would for a DB2 table. Then DB2 Web Query submits the actual RUNQRY command to the server and displays the results to your browser. Just as RUNQRY has the three output options of display, spool file, or database file, Web Query will also perform the output option that is defined in the QRYDFN.

As discussed in Chapter 3, “DB2 Web Query Fundamentals”, DB2 Web Query requires special metadata to read from table objects. This is also true of QRYDFN objects. The process of creating metadata on QRYDFN objects is quite similar to the process for tables. Once the metadata is created, DB2 Web Query treats table and QRYDFN metadata in quite the same way.

13.2 DB2 Web Query vs. Query/400 - What functions are similar

The following list outlines how DB2 Web Query and Query/400 have the same functionality:

� Report appearance - Based solely on report appearance, a basic user will not be able to tell if the report she is running is based on a DB2 object or a QRYDFN object. The look and feel of both final reports based on QRY/400 metadata versus DB2 file metadta are identical.

� Spool File output - If your QRYDFN object is defined with output option of Printer, DB2 Web Query will send the output to a spool file.

� Database file output - If your QRYDFN object is defined with output option of Database file, when DB2 Web Query runs that report, it will send the output to a Database file.

� Batch capabilities - It is common to submit a CL program to batch that performs several RUNQRY commands. DB2 Web Query can also perform this functionality. The eventual goal in some shops may be to completely replace their QRYDFN objects with DB2 Web Query reports. With this in mind, DB2 Web Query has a thread-safe command that will allow all your reports developed in DB2 Web Query to be used in your batch jobs.

� Right Join - WRKQRY does not support Right Join, and neither does DB2 Web Query.

Just as DB2 Web Query supports Query/400 functions, likewise the reverse is true. With the exception of what is discussed in section 9.3.2, all Report Assist functions can be used on Query/400 metadata. Recall that DB2 Web Query sees the Query/400 result set much like a table.

254 DB2 Web Query for System i

Page 273: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch11.fm

13.3 Web Query verses Query/400 - What functions are different

This chapter discusses functionality that Query/400 has that DB2 Web Query does not have. In all cases the limitation is explainable and a workaround is provided.

Parameter passingIt is possible to create a QRYDFN object that can accept parameters at run time. This is done by using a variable in the selection clause. Figure 9-1 shows how this is used. Then this QRYDFN is called using the STRQMQRY ALWQRYDFN (*YES) command, which prompts the user for parameters.

Figure 13-1

As noted earlier in this chapter, Web Query literally sends the RUNQRY command to the server. It does not send any version of STRQMQRY. So this limitation means QRY/400 queries that were coded for use as STRQMQRY ALWQRYDFN(*YES) to allow parameter input must instead use the Web Query parameter passing. First, you must change your QRYDFN object to not accept parameters. After you have created the metadata, you may use Report Assist to code the parameters into the Selection Criteria. (See section 4.1.3 for creating a parameterized report).

Using output files for the next queryIt is common to use RUNQRY outfile results for use in the next RUNQRY. It is still possible to do this “chaining” in DB2 Web Query, although you must first create metadata on the intermediate output files. The metadata is hard-coded only with library and file name, it does not check the format level identifier of the file as some programs do.

For example, library QGPL is used to hold the work files. You will need to run all the reports and generate the outfiles to QGPL. Do not delete the QGPL files. Then you create the metadata only once on the QGPL work files, and create reports off the work files. When the job is done, the work files are deleted. The next time the job runs the work files are created again. As long as the files are created with the same fields and format as before, the previously created metadata will successfully run the report. DB2 Web Query does not know the underlying files have since been deleted and recreated.

Commonly the library QTEMP is used to store these intermediate work files. The limitation of DB2 Web Query is that you can not create metadata on any object in QTEMP. So the intermediate file must be in a different library, then the metadata can be created. If you can not change your work files to be in QTEMP, you will not be able to do query chaining. If you do change your workfiles from QTEMP to another library, be mindful to change your program to delete the work files.

Chapter 13. Using DB2 Web Query to run existing Query/400 reports 255

Page 274: DB2 Web Query for System i

7214ch11.fm Draft Document for Review October 10, 2007 9:57 am

To sum up, metadata remains valid even if the underlying object is deleted and recreated. However, if the underlying object is changed, then the metadata is stale and needs to be recreated.

13.4 How to create metadata from Query/400 objects

Just as Web Query requires metadata to read from DB2 files, it also requires metadata to read from Query/400. When creating metadata on QRYDFN objects, there are a few extra screens you must remember to finish otherwise the metadata creation will not be complete.

As noted earlier, if you change the format of your underlying files, you must re-create the metadata on those files. If you change the QRYDFN on the server side, you must recreate the metadata on that QRYDFN.

The process of creating metadata on a Query/400 will actually run the query at that time. This is because it is gathering information on the files and columns used in query output. For this reason, the processing of creating metadata on a Query/400 object may be somewhat longer than on a DB2 table.

DB2 Web Query will ask for the library name where your Query/400 objects are stored. You can choose to create metadata for all queries in a library in a single execution.

Following are screen shots that walk you through the process when creating Metadata for Query/400. There are two additional screens for creating metadata on a Query/400 object verses on a DB2 object. Just make sure to push Next until you no longer see a Next button.

1) First you must select which adapter to use in the left panel. In this case it will be the Query/400 adapter. LEFT click on the adapter and select Create Synonym.

Figure 13-2 Selecting the Data Adapter

2) In the dialogue box, you must enter the library where the QRYDFN object resides. In this case, it is library RMMASON. Then click Submit as shown in figure 9.

256 DB2 Web Query for System i

Page 275: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch11.fm

Figure 13-3 Creating a Synonym

3) After clicking submit, you will see this screen below. Here you will check the box in front of which Query/400 object you wish to create metadata on. Only use the “Overwrite Existing Synonym” if you have previously created a synonym on this object and wish to replace it. In our case it is the first time creating metadata on QRYDFN in this library, so we will check the box next to “Default synonym name.” This will select every QRYDFN in the entire library. You will get a warning window that looks like Figure 13-4. Click OK.

Figure 13-4 Warning message - Creation of Synonyms

4) After you click OK, you will see every QRYDFN object is checked. Then click Create Synonym and be patient.

Chapter 13. Using DB2 Web Query to run existing Query/400 reports 257

Page 276: DB2 Web Query for System i

7214ch11.fm Draft Document for Review October 10, 2007 9:57 am

Figure 13-5 List of QRYDFN objects

5) The next screen appears to be a success screen, but you’re not quite done. You have to press the Next button as in Figure 13-6.

Figure 13-6 Created successfully - message

6) You will need to push Next on the following window. Note the figures 9-6 and 9-7 look slightly different. For example, there is a Report Name column with a white background in Figure 13-7. This is the last screen you will need to push Next on. Web Query is actually creating a report from your QRYDFN.

258 DB2 Web Query for System i

Page 277: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch11.fm

Figure 13-7 Final confirmation window - Creation Synonym for Query/400

Figure 13-8 shows the final success screen for Query/400 metadata creation. You can close out this box.

Figure 13-8 Created successfully message - Conversion from Query/400 to DB2 Web Query

Now if you go back into your Web Query domain, you will notice the metadata is already created as a report. You may simply click on this report to run it, or right click for the editing options.

Options When Creating Metadata - Prefix and Suffix. The guidelines for adding a prefix and suffix to metadata are the same as outlined in Chapter 3, “DB2 Web Query Fundamentals”. Keep in mind that after metadata creation, you will not be able to tell if the underlying object is a DB2 table or a QRYDFN. You may want to add a prefix or suffix that will help you to identify that the object being queried on the server side is a QRYDFN.

Chapter 13. Using DB2 Web Query to run existing Query/400 reports 259

Page 278: DB2 Web Query for System i

7214ch11.fm Draft Document for Review October 10, 2007 9:57 am

13.5 Use Web Query to edit a QRYDFN

Once you have created metadata, DB2 Web Query understands the metadata as a result set. You can use Web Query to edit, sort and filter that report; but you can only work within that result set. You can not add new columns to the report, even if the column is from a table used in the report. Web Query, in effect, sees the Query/400 result set as any other table.

For example, in Chapter 5, “Report Assistant” we learned the difference between compute and define. Since compute is data manipulation done on the client side, you may still use Compute on your Query/400 reports. However the define operation is data manipulation performed on the server side, so you will not be able to do this when editing a Query/400 object. (currently bad data is returned, may change into an error message instead)

If you edit the report from Web Query, those changes will not be reflected in the QRYDFN object.

When editing a Query/400 report that contains a join, you may add a new join with DB2 Web Query. However, you will not be able to edit the joins already defined in Query/400.

260 DB2 Web Query for System i

Page 279: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch12.fm

Chapter 14. Performance

Minimizing the processing time for report requests and maintaining the accuracy and integrity of the report data are major goals for most organizations. In this chapter, DB2 Web Query performance considerations and recommendations, are covered. Also included is a case study intended to demonstrate some steps you could take to tune a DB2 Web Query report.

14

© Copyright IBM Corp. 2007. All rights reserved. 261

Page 280: DB2 Web Query for System i

7214ch12.fm Draft Document for Review October 10, 2007 9:57 am

14.1 Performance basics

When the objective is to obtain optimal report performance, one should bear in mind the following DB2 Web Query characteristics regarding how it approaches performance optimization:

� When a DB2 Web Query report is run, the tasks of row selection, joining, ordering, and aggregating must be performed. These tasks can be carried out by the DB2 for i5/OS database engine, DB2 Web Query, or a combination of both.

� DB2 Web Query attempts to translate the source code of a DB2 Web Query report into equivalent SQL statement(s). When the report is run, the SQL statement is submitted to the database engine for processing.

� Like most other Relational Databases Management Systems (RDBMS), DB2 for i5/OS database engine knows its own data. Its optimizer component uses complex costing algorithms to determine the ideal access plan, what indexes to use, etc. so it can retrieve the data in the most efficient manner. To aid in its decision making processes, it maintains various forms of statistics about the data. In addition, much of the database code lies below the Machine Interface (MI) layer of i5/OS, an attribute that can yield great efficiencies during the query optimization and execution steps.

� For accomplishing all processing tasks in an efficient manner, the database engine should be preferred over DB2 Web Query. Therefore, the goal of DB2 Web Query optimization should be to push as much of this processing, decision making, and execution as possible down to the database level.

If a request is not optimized, DB2 Web Query is forced to perform tasks such as joining, sorting, and aggregating. In these cases, the database engine will retrieve all the rows necessary for the request based on the translation. DB2 Web Query will then complete that processing necessary to prepare the data for the report. This can result in the following:

� Higher processing costs for both the database engine and DB2 Web Query.

� Potentially higher network communication costs since larger-than-necessary result sets are moved around the network.

� Higher personnel costs since time is wasted waiting for inefficient queries to execute and return the requested data.

14.2 DB2 CLI adapter performance

In this section, performance considerations specific to the DB2 CLI adapter are discussed.

14.2.1 Report request process flow

As a foundation for understanding DB2 Web Query performance factors, you should first understand the overall process flow when reporting from relational data. It is important to comprehend this process flow so that you can see where their difference phases of optimization occur when a report request is made, and how you can influence them. The process of running a DB2 Web Query request consists of two phases:

Attention: SQL translation does not occur for reports that go through the Query/400 or DB Heritage Files adapter. Those adapters use different methods to access the data.

262 DB2 Web Query for System i

Page 281: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch12.fm

� The execution phase

� The report production phase

The flow of the request through these two phases is shown in Figure 14-1.

Figure 14-1 Flow of DB2 Web Query report run request

Report execution phaseThe following steps occur during the execution phase of a report request:

1. The web browser client sends the request to the web server/application server for processing.

2. The web server/application server routes the request to the Reporting Server.

3. The tasks handled by the DB2 Web Query Reporting Server component during the Execution Phase are the following:

a. Reads and parses the DB2 Web Query metadata.

b. Parses the procedure (checks the syntax of the source code).

c. Sends a DESCRIBE request to DB2 for i5/OS, so that the Reporting Server can create metadata for the result set that will be returned.

d. The Reporting Server passes the procedure to the Data Adapter for processing.

4. The tasks handled by the DB2 Web Query Data Adapter component during the Execution Phase are the following:

a. Analyzes the DB2 Web Query Master File for the specific SQL module and dialect to use, and to retrieve the SQL column names.

b. Analyzes the DB2 Web Query Access File for the specific table to access, and which connection to use.

c. Translates (optimizes) the DB2 Web Query request to the appropriate SQL statement(s).

`

HTTP Clients Web Server/Application Server

Web Query Reporting Server

DB2 for i5/OS

Execution phase

Report production phase

Report

Databaseresult set

Web Queryresult set

Chapter 14. Performance 263

Page 282: DB2 Web Query for System i

7214ch12.fm Draft Document for Review October 10, 2007 9:57 am

d. Passes SELECT statement(s) to the DB2 for i5/OS database engine.

5. The tasks handled by the Database Engine component during the Execution Phase are the following:

a. Analyzes and optimizes the SQL statement(s).

b. Chooses the appropriate access path and retrieval method.

c. Retrieves the data.

d. Creates the database result set.

6. The report Execution phase ends

Report production phaseAt the completion of the report execution phase, the report production phase begins. The task handled by the database engine component during the Report Production Phase is to send a row and a SQL status code to the Reporting Server.

The tasks handled by the Reporting Server component during the Report Production Phase are the following:

1. Reads the row from the database result set and processes any remaining actions on that row (IF/WHERE, DEFINEs, etc. that were not translated by the database engine).

2. Converts non-standard data into DB2 Web Query format, making it available to DB2 Web Query.

3. Puts the valid row into the DB2 Web Query result set.

4. Asks the database engine for the next row (FETCH).

5. Tasks 1 – 4 repeat (loop) until the end of the database result set (SQL status code +100).

6. The DB2 Web Query result set is processed, style sheets applied, and the report output formatted as requested by the instructions in the procedure.

7. Finally, the report is displayed via a browser or native program based on the type of output produced (i.e. Adobe or Excel).

14.2.2 Adapter processing and optimization

When reporting from relational data sources, the Data Adapter attempts to translate the source code of a DB2 Web Query procedure into equivalent SQL statements. Adapter optimization is the degree to which a DB2 Web Query request is translated to pure SQL statements to be handled by the database engine. Maximizing the adapter optimization should be a major goal of any DB2 Web Query application. If all the commands in a DB2 Web Query report request are translated into the equivalent operation in SQL, then all joining, sorting or aggregating functions are handled by the database engine. When this occurs, the request is considered (from a DB2 Web Query perspective) to be totally optimized.

Table 14-1 on page 265 displays the DB2 Web Query operations and the SQL equivalent.

Note: The database engine is now interfacing with the database result set and not the native relational data on DB2 for i5/OS.

264 DB2 Web Query for System i

Page 283: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch12.fm

Table 14-1 DB2 Web Query operations and SQL equivalent

Operation SQL Equivalent

Retrieve rows for columns specified SELECT

SELECT DISTINCT(….)

Identify the table from which to report FROM

Simple aggregation functions SUM, COUNT, AVG, MIN, MAX

Retrieve specific rows WHERE

Ordering rows ORDER BY

Retrieve specific aggregated rows HAVING

Creating logical table structures (joins) FROM...WHERE...

Chapter 14. Performance 265

Page 284: DB2 Web Query for System i

7214ch12.fm Draft Document for Review October 10, 2007 9:57 am

Selection and ProjectionTwo important processes that occur during the SQL translation step of the Execution Phase are selection and projection. Each is discussed in this section.

� Selection

Selection is the process of retrieving the table rows that meet the request criteria. Selection will be translated to various predicates of the SQL WHERE clause except those expressions listed in Table 14-2.

Table 14-2 Selection disablers

Table 14-3 DEFINE expressions that can be translated to SQL

Selection disabler Description

Non-translatable DEFINE fields Certain DEFINE expressions can be translated to SQL as part of aggregation or record selection operations, and in some circumstances, be used as part of a define-based join. Example of translatable DEFINE expressions include the following:� For selection, the DEFINE expression must

be an arithmetic valued expression, a character string valued expression or a logical expression.

� For aggregation, the DEFINE expression must be an arithmetic or character string valued (COUNT) expression.

� These expressions are based on what is built (i.e. on the right-hand side of the equal sign) in the DEFINE expression, NOT the format of the field that is being defined.

More information on the DEFINE field expressions that can be translated to SQL can be found in Table 14-3

Non-translatable DATE fields DATE fields with formats other than YMD or YYMD

Spanned DEFINE fields DEFINE fields that span more than one segment in a joined structure

Expression® SQL translatable conditions

Arithmetic ExpressionsNEWSAL/D12.2 = ((CURR_SAL + OTIME_SAL) * 1.1) - 100;

� Real-field operands of numeric data types (I, P, D, F)

� Numeric constants � Arithmetic operators (**, *, /, +, -)� Subtraction of one DATE field from another� DEFINE-field operands satisfying any of the

above

Character String Expressions FORMAL_NAME/A36 = LAST_NAME | ', ' | FIRSTNAME;

� Real-field operands of alphanumeric data types. (TEXT field formats are not supported with DEFINE expressions)

� String constants � String concatenation operators� DEFINE-field operands satisfying any of the

above

266 DB2 Web Query for System i

Page 285: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch12.fm

For more information on creating DEFINE fields, refer to “Define and compute fields” on page 74.

� Projection

The process of retrieving the table columns that meet the request criteria. Projection will be translated to be objects of the SELECT statement as follows:

– Columns referenced in PRINT, SUM or COUNT commands.

– Columns used as objects in JOIN or DEFINE operations.

– PRINT * and SEG.fieldname will return all columns in the Master File only.

It is important to understand the DB2 Web Query selection and projection operations because they are both processes that reduce the volume of data being returned from the database, which helps to improve performance, efficiency and report response time.

Optimization hierarchyIn addition to individual operations being optimized, a progressive optimization hierarchy affects the SQL being generated. The order of adapter optimization is shown in Figure 14-2:

Logical Expressions (Expressions that are evaluated as true, 1, or false, 0.)

SALES_FLAG/I1 = (DIV_CODE EQ 'SALES') OR (COMMISSION GT 0);

QUOTA_CLUB/I1 = (SALES_FLAG) AND (UNITS_SOLD GT 100);

� Real-field operands of any DB2 Web Query-supported data type (including DATE fields)

� Constants with same data type as field(s) in the predicate

� Relational operators (EQ, NE, GT, LT, GE, LE)

� Logical operators (AND, OR, NOT)� Arithmetic or character string expression

operands (above) � DEFINE-field operands satisfying any of the

above

Note: SELECT * is never generated by DB2 Web Query.

Expression® SQL translatable conditions

Chapter 14. Performance 267

Page 286: DB2 Web Query for System i

7214ch12.fm Draft Document for Review October 10, 2007 9:57 am

Figure 14-2 DB2 Web Query adapter optimization order

This hierarchy is mentioned because it is important for you to know what to focus on first. If your report’s ordering or aggregating is not being performed by the database engine and you are unable to determine why, it could be because the join optimization is failing. Therefore, if you have a poor performing report that is joining two or more tables, your analysis should begin with join optimization.

Join optimizationA join operation is a complex function that requires special attention in order to achieve good performance. Again, it must be stressed that the goal is to allow the database engine to perform as much of the optimization and processing as possible. Due to their potential complexity, this is especially true for join operations.

If the join is processed by the database engine, the following steps occur:

� The DB2 Web Query request is optimized and is translated to a single SQL select statement.

� The database engine will retrieve the data from the tables specified in the select statement.

� The database engine will merge the rows using its chosen join implementation

� Screening conditions are applied, if any.

Note: Regardless of the hierarchy above, the adapter always tries to translate row selection (WHERE) and projection operations to their SQL equivalents.

Creation of logical table structures (JOIN)

Aggregating rows (SUM/COUNT)

Ordering rows (SORT)

If the join optimization fails, so will the sort and aggregation optimization.

If the sort optimization fails, so will the aggregation optimization.

Aggregation optimization will occur only if the join and sort operations were optimized and aggregation was required.

268 DB2 Web Query for System i

Page 287: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch12.fm

� The columns in the request are then applied.

� Any column function values and/or expressions are calculated.

� One result set is produced.

Table 14-4 Quick guide to strengths of DB2 Web Query and DB2 for i5/OS

DB2 for i5/OS usually handles the join if:

� All the DB2 Web Query commands (where possible) are translated to their SQL equivalent; however, because of the processing hierarchy, sorting and aggregation could still fail.

Conditions that prevent full DB2 Web Query optimizationOnce a query request is submitted, there are several conditions that will cause the adapter to disable the optimization of the join operation. These join disablers are shown in Table 14-5 on page 269. You must eliminate these conditions if you want full DB2 Web Query optimization to occur.

Table 14-5 Join Disablers

DB2 Web Query strengths DB2 for i5/OS strengths

DB2 for i5/OS federated joins Joining on local tables(SELECT...FROM...WHERE)

Complex calculations Row and Column selection (SELECT…WHERE)

Sophisticated formatting Sorting (SELECT…ORDER BY)

Generate graphs Aggregation (SELECT…GROUP BY)

Note: As of V5R3, the SQL Query Engine also has Referential Integrity (RI) and Constraint Awareness. This means that the optimizer is capable of using the RI conditions to rewrite the queries to eliminate unnecessary join combinations. This can result in significant performance gains for queries with complex joining and is another compelling reason to try to achieve full DB2 Web Query optimization.

Join Disabler Description

DEFINE based JOINs (only if the DEFINE expression is not translatable)

A DB2 Web Query define-based join allows joining a cross-reference file to a host file field that was created by a DEFINE statement. As mentioned previously in the section “Selection and Projection” on page 266, there are cases in which DEFINE fields are not translated to SQL. When this happens, and that DEFINE field is used as a join field, the join will not be translated either.

DEFINE fields that span more than one segment in a joined structure

Joining tables based on DEFINE fields will prevent the database engine from processing the join.

Chapter 14. Performance 269

Page 288: DB2 Web Query for System i

7214ch12.fm Draft Document for Review October 10, 2007 9:57 am

When you create a join connection (via the join tab) between tables, DB2 Web Query may choose to generate and run multiple SQL statements to compute the correct output for your report. In some cases, DB2 Web Query can reduce these multiple SQL statements to a single SQL statement thereby improving DB2 Web Query's performance considerably. In particular, when the joined in table (called the target table on the right of the join panel) is joined via a unique join, DB2 Web Query can process the entire report in one underlying SQL query. A unique join is one where given a row from the initial table(s) (called host tables on the left of the join panel)matches at most one row in the joined in target table (again the target table is on the right tab). The join must be unique over the entire set of target table joined columns (note that no one column must be unique in the target table).

Optimization and avoiding the multiplicative effectDB2 Web Query allows developers who know they have a unique join to the target table to configure their report with this knowledge. As a result, DB2 Web Query can potentially reduce the number of SQL statements generated, thereby improving performance. On the Report Options tab, the developer can select the "Use Database Optimization" check box as shown in Figure 14-3. This instructs DB2 WebQuery that it is safe to pass the entire report down to the database engine in a single SQL statement. Note that choosing to "Use Database Optimization" when there is not a unique join to the target table can result in incorrect results in the report (due to the multiplicative effect described above). Consequently, it is very important to only select this option when you are certain of the uniqueness of the underlying data.

Multiplicative Effect An aggregation at any level other than the lowest level of the JOINed structure, OR a child table whose foreign key doesn’t totally cover it’s primary key (causing the parent table rows to be duplicated) For more information on the multiplicative effect, refer to he section “Optimization and avoiding the multiplicative effect”.

Federated Joins Joining DB2 for i/OS tables on different systems, partitions, or IASPs will be carried out by DB2 for DB2 Web Query and not the database engine.

Join Disabler Description

270 DB2 Web Query for System i

Page 289: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch12.fm

Figure 14-3 Database optimization setting

To determine if it is safe to use the Database Optimization checkbox and avoid the multiplicate effect, one of two verification methods can employed:

� Database constraint verification

If either a primary or unique database constraints is in place for a table against a specific column or combination of columns, the database will guarantee data uniqueness based on that constraint. In such cases, it is safe to turn on "Use Database Optimization" for that join.

� Manual verification

Tables may have unique data without strict database constraint enforcement. You can also verify the data is unique via inspection and/or knowledge of the data. The database administrator can run queries similar to the following to see if the current state of the data is unique:

SELECT CASE WHEN count(*) = count(distinct JoinColumn1||JoinColumn2||...||JoinColumnN) then 'Unique' else 'Not Unique' END FROM target_table

If the state of the data is currently unique, the administrator must use their judgement and knowledge of the data to decide if future states of the data will also be unique. If you are not sure if future states of the data will be unique over the join columns, then it is better to err on the side of caution and leave the "Use Database Optimization" unchecked.

Sorting OptimizationIf any of the following conditions listed in Table 14-6 are true, DB2 WebQuery performs the sorting:

Chapter 14. Performance 271

Page 290: DB2 Web Query for System i

7214ch12.fm Draft Document for Review October 10, 2007 9:57 am

Table 14-6 Sorting and aggregating disablers

Aggregation OptimizationIf any of the following conditions listed in Table 14-7 are true, DB2 WebQuery performs the Aggregation:

Table 14-7 Aggregation disablers

Other ways to influence optimizationThe conditions discussed above help dictate whether DB2 Web Query or the database engine performs the bulk of the report processing. In addition, there are some techniques that can be used to influence this behavior and improve report response time.

Create SQL ViewsDuring DB2 Web Query report development, you may encounter situations in which a report will not fully translate to an SQL statement. If this happens, one technique to help move toward full DB2 Web Query optimization is to create an SQL view with all of the appropriate selection, join, and aggregation syntax specified. Next, create the synonym for the view, and in your report definition, select that view, rather than the table(s), from the database description list. This will instruct DB2 Web Query to use the view and push the selection, join syntax, and aggregation down to the database engine. This particular technique is used to tune a problem report in the section “Performance case study” on page 280.

The advantages of using views are many. The following list gives you an idea of what they can do:

� Provide the ability to specify additional join types not supported by the DB2 Web Query product.

DB2 Web Query will allow you to specify inner joins and left outer joins. With SQL views, you can define those and the following join types:

– Right Outer

– Left Exception

Sort Disablers Description

DB2 Web Query managed join See table above

Sort on a non-translatable DEFINE field Any request that contains a sort on a non-translatable DEFINE field

Interface-managed join SQL will sort the answer set by the table(s) primary key(s), causing DB2 WebQuery to re-sort for the display report.

Aggregation Disablers Description

DB2 Web Query managed join or sort See tables above

DB2 Web Query managed row selection Some WHERE clauses aren’t passed to the database engine

Non-direct SQL operators The request contains direct operators, such as PCT., TOT. that can’t be translated into SQL

Aggregation on ‘non-translatable’ DEFINE Aggregating on a DEFINE field that cannot directly translate to SQL.

272 DB2 Web Query for System i

Page 291: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch12.fm

– Right Exception

� Allow you specify CASE statements to handle more complex, conditional logic

� Provide fullselect support

An SQL fullselect is the term for generating an SQL result set by combining multiple SELECT statements using the UNION, INTERSECT, and/or EXCEPT operators. This is a feature that helps you solve more complex business requirements.

� Provide Common Table Expression (CTE) and recursive SQL support

CTEs can be thought of as temporary views that only exist during the execution of an SQL statement. The CTE, once defined, can be referenced multiple times in the same view. This can be used to reduce the complexity of the view, making it easier to comprehend and maintain.

Among the V5R4 enhancements for DB2 for i5/OS, was the ability for a CTE to reference itself. This feature provides the mechanism for recursive SQL, which is especially useful when querying data that is hierarchical in nature (such as bill of materials, organizational charts, and airline flight schedules).

For more information on recursive CTE’s refer to the article “V5R4 SQL Packs a Punch” which can be downloaded at http://www-03.ibm.com/servers/eserver/iseries/db2/pdf/rcte_olap.pdf

� Allows business logic to reside in the database layer, making it available to all users and all SQL interfaces.

� Provide an database abstraction layer

� Provide security granularity

Once views are in place, you can restrict users from accessing tables directly and only allow access through the views. Because both selection and projection can be specified on the views, you can control specific rows and columns that users (or groups of users) can access.

Establish and use foreign key relationshipsIf you have foreign key relationships explicitly defined in i5/OS database, you can take advantage of a DB2 Web Query feature to include with the selected table’s synonym, every table related to the selected table by a foreign key. The resulting multi-table synonym describes all of this table’s foreign key relationships. This can greatly simplifying the process of creating reports with joins. In fact, in this scenario, you do not even define a join in your report. All columns from the related tables are displayed on the “Field Selection” tab and you simply select the columns that you want to include in the report. Through the foreign key relationships, DB2 Web Query is able to understand the join syntax that needs to be created and generates the appropriate SQL statement.

The process of creating synonyms with foreign key relationships is discussed in “Metadata creation supports referential integrity” on page 40.

Create Materialized Query Tables (MQTs)MQTs provide another method of improving performance of your queries. An MQT is a table that contains the results of a previously run query, along with the query’s definition. It provides a mechanism for improving the response time of complex SQL queries. While it can be

Important: Views should not be confused with indexes. They are implemented as non-keyed logical files. This means that views, unlike indexes, have no access paths and thus, no access path maintenance. If you or your DBA are concerned about access path maintenance, this is simply not an issue with views.

Chapter 14. Performance 273

Page 292: DB2 Web Query for System i

7214ch12.fm Draft Document for Review October 10, 2007 9:57 am

thought of as a summary table, what sets an MQT apart from a regular summary table is the fact that the SQE optimizer is aware of it and its relationship to the query and base tables that were specified when it was created and populated. This means that the optimizer will consider using the MQT in the access plan of subsequent similar queries if it determines that it is appropriate to do so. Because the MQT is already created, populated, joined, aggregated, and sorted, this can result in significant performance improvements for complex queries.

It is important to understand that an MQT is a table (a physical file with an object type of *FILE) that resides in a library (schema) on the System i. Because of this, it can be accessed directly, just like any other table on the system. While it is usually the optimizer’s job to select and implement an MQT in the access plan of a query request, DB2 Web Query does have the ability to create metadata against an MQT. This means that you can create DB2 Web Query reports that access an MQT directly, and not be forced to rely on the optimizer to select the MQT.

To obtain this behavior, you must first create the metadata for the MQT by taking the following steps:

1. From the DB2 Web Query home page, right mouse click on your reports folder and select Metadata. The Configuring Data Adapter browser window opens.

2. From the left navigation pane of the Configuring Data Adapter browser window, click on *LOCAL under the DB2 CLI folder. Select Create Synonym.

3. From the Select Synonym Candidates for DB2 CLI (*LOCAL) window, specify the collection and check the MQTs selection box as shown in Figure 14-4. Press Next.

Figure 14-4 Creating synonym for MQT - specify collection

The Create Synonym for DB2 screen is displayed as shown in Figure 14-5.

Figure 14-5 Creating synonym for MQT - select MQT

274 DB2 Web Query for System i

Page 293: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch12.fm

4. Specify a prefix and suffix, check the MQTs listed, and click on the Create Synonym button.

Once the synonyms have been created for the MQTs, you can create reports against them as you would any other table object on the system.

While their potential performance efficiencies are appealing for DBAs, query developers, and report users, MQTs do have several attributes and limitations that must be understood prior to implementation. Probably the most important thing to be aware of is that MQTs are not automatically maintained. This means that as the base tables used to populate the MQT change, the data in the MQT does not also change. If the data in your reports needs to be up to date, the MQT must first be manually refreshed. Therefore, before implementing MQTs, you must be willing to accept some level of data latency. This is may be acceptable for queries that report on data that is historical in nature. However, if your report requires data that is dynamic and up-to-the- minute, you may come to the conclusion that an MQT isn’t the right fit. For more information on MQT’s see the white paper Creating and using materialized query tables (MQT) in IBM DB2 for i5/OS.

14.2.3 Remote database access considerations (including cross system joining)

One of the features of the DB2 Web Query base product is the ability to access data on remote DB2 for i5/OS systems or partitions. This feature, available only for the DB2 CLI adapter, gives you option to pull data for your reports in one of the following ways:

� Local - All the data resides on the local system

� Remote - All the data resides on one remote system or partition

� Cross system - Data is spread across the local system and/or one or more remote systems/partitions.

If full DB2 Web Query optimization can be performed for Local and Remote database access (and there are no other external factors negatively influencing query performance), you can expect your reports to perform reasonably well, Again, this is because DB2 Web Query is able to generate one SQL statement and allow the DB2 for i5/OS database engine to process the request.

However, you must be aware of the performance implications if the data is spread across two or more System i machines or partitions. In this scenario, DB2 Web Query will generate a separate SQL statement for each connection and submit the statement to each connection. The answer set from each of these multiple sources is then joined together by the Reporting Server. Depending on how the joins are specified, this can be a lengthy and time consuming process. Consider the following scenario:

A fact table (ORDERS) has 32,283 rows and is joined to a dimension table (STORES) which has 116 rows.If both of the tables are on the local (or even remote system), DB2 Web Query will generate a single SQL statement and submit it to DB2 for i5/OS. That statement would like something like the one shown in Example 14-1.

Example 14-1 Single SQL statement

SELECT T2."Country",T2."State", SUM(T1."LineTotal") FROM CENTURY/ORDERS T1,CENTURY/STORES T2 WHERE (T2."StoreCode" = T1."StoreCode") GROUP BY T2."Country",T2."State" ORDER BY T2."Country",T2."State"

Chapter 14. Performance 275

Page 294: DB2 Web Query for System i

7214ch12.fm Draft Document for Review October 10, 2007 9:57 am

FOR FETCH ONLY

Since one statement is generated and the database engine handles all the joining, grouping, and ordering, you could expect this report to run quite efficiently.

However, if dimension table STORES resides on another system and Report Assistant is used to create a nearly identical report (the only difference being a cross system join specification to STORES), DB2 Web Query now creates two SQL statements, one for each system.

� Local system:

Example 14-2 Local system SQL statement

SELECT T1."StoreCode",T1."LineTotal" FROM CENTURY/ORDERS T1FOR FETCH ONLY

� Remote system:

Example 14-3 Remote system SQL statement

SELECT T5."Country",T5."State" FROM "CENTURY"/"STORES" T5 WHERE (T5."StoreCode" = ?) FOR FETCH ONLY

Inefficiencies occur because the remote SQL statement is submitted multiple times on the remote system. The local system fetches each row from the (local) ORDERS table result set and generates the appropriate local selection to return the matching row from the remote STORES table. With this implementation, the report takes significantly longer before the results are displayed to the browser.

If the report was modified to specify STORES (with only 116 rows) as the base table, the join fan-out would be greatly reduced. This results is a report that runs significantly faster, but still not nearly as fast as when all tables are on same system.Therefore, it is generally recommended that you avoid creating reports with cross system joins when the tables have a substantial number of rows. However, if such an implementing is required, consider the following suggestions to enhance the report’s performance:

� Eliminate the report’s requirement of multiple connections by making local copies of the remote tables. Once all tables are on one system, join optimization can be enabled and DB2 Web Query will attempt to generate a single SQL statement.

� Determine which of the tables has the smallest number of rows (after applying local selection) and make that the base table of the report. This will reduce the fan-out effect of the join, thereby reducing the number of rows that must be retrieved from the other (larger) tables.

� Edit the report source and add the following line

SQL DB2 SET JOINTYPE SORTMERGE

An example of this setting specified in the report source is shown in Figure 14-6.

276 DB2 Web Query for System i

Page 295: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch12.fm

Figure 14-6 SORTMERGE setting

This setting impacts the number of "FOR FETCH" lines when one of the tables is remote. What is does in effect is turn all of the tables into local internal tables and sort merges them.

14.3 Query/400 adapter performance

One of the features of DB2 Web Query is the ability to run most existing i5/OS Query/400 queries. This is done by utilizing the Query/400 adapter that is provided with the base offering of 5733-QU2. This adapter functions by actually running the Query/400 query during both the synonym creation process and report execution. This means that if you have an existing Query/400 object that does not perform very well and takes several minutes to run to completion, it will require just as much time (and perhaps more) to create the DB2 Web Query synonym. Once the synonym has been created and you run the new DB2 Web Query report, you can again expect it require at least the same amount of time to run.

Because the adapter is running the existing query, you will be limited in the tuning that can be done to make each of the DB2 Web Query processes perform better. In most cases, the sole tuning knob is to ensure that the appropriate indexes are in place for the optimizer to use when creating the access plan for the query. Approaches for implementing an indexing strategy are discussed in the upcoming section “Indexes” on page 279.

Recall from a discussion in an earlier section that the Classic Query Engine (CQE) processes non-SQL database requests such as those from Query/400 queries. CQE does provide some index advisory information for query selection. Missing from CQE is the ability to create index advisories for joining, grouping, and ordering. Analysis and tuning that is more manual in nature is required for these types of requests. If your Query/400 reports and not performing to

Chapter 14. Performance 277

Page 296: DB2 Web Query for System i

7214ch12.fm Draft Document for Review October 10, 2007 9:57 am

you satisfaction, make sure that indexes exist over all join fields, order by fields, and fields that are aggregated.

14.4 DB2 for i5/OS optimization

By now you should be convinced that getting DB2 Web Query to hand off as much of the processing as possible to the database engine is a key factor in achieving optimal report performance. There are also factors within the i5/OS database itself that can affect efficiency.

These types of factors are usually the responsibility of the Database Administrator (DBA) and not the end users; however, a little knowledge of what these factors are and how they can affect efficiency will better enable an end user to communicate effectively with the DBA.

Once the end users have done everything they possibly can from their end in the efficiency spectrum (the report definitions are as good as they can be), these are the factors that can still have an influence on the overall efficiency of the request. The DB2 for i5/OS factors that can affect efficiency are:

� Database design

� Indexes

� Available hardware

� Number of concurrent users

14.4.1 Database design

Good performance starts with a good database design. If your database structure is flat in nature and not normalized, the files are likely to have redundant data that is difficult to navigate, retrieve, and maintain. The complexities of retrieval and maintenance are often handled by High Level Language (HLL) program written in RPG or COBOL. This approach works when those programs were the only interface to the data and could hide the complexity from end users. However, problems and confusion are likely to result when you expose your database and allow other interfaces such as DB2 Web Query to access and report against the data. The following list provides some of the shortcomings of a poorly designed database:

� Complexity

The application programs contain most/all business rules and data relationships. Therefore, the data is difficult to query because it is hard to understand rules and relationships. Because of the complexity, programmers (and not end users) are forced to develop the reports. Often the reports themselves are HLL programs than can be complex and difficult to maintain. Programmers can find themselves constantly creating new copies of reports to satisfy a seemingly endless list of end-user ad hoc reporting requirements.

� Lacks flexibility

The database is difficult to maintain, adapt, and expand. Repeating groups must be squeezed into a single record. This places limits on how many repeating groups that can fit into a single record format

� Less optimal access methods

Performance of these reports can suffer because of the database complexity. Programmatic selection, joining, ordering, and grouping are often implemented with a row at a time coding techniques. Record blocking and set at a time processing are not utilized, thus the report performance is not maximized.

278 DB2 Web Query for System i

Page 297: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch12.fm

If this describes your current database design, you might want to consider investing in a robust data modeling tool that will help you implement a database design that is both functional and efficient.

14.4.2 Indexes

Like any other application that accesses information from the database, efficient DB2 Web Query performance is heavily dependent on having the right indexes in place. Once your database is in production, it may be difficult to implement recommended database design practices such as database normalization. However, at this point, you can still implement an indexing strategy that will help optimize the performance of your query reports.

Indexes over your database tables provide the following advantages:

� Provide statistics to the optimizer

Indexes against the queried tables give the optimizer a better opportunity to select the most efficient access method. This is because they provide relevant statistics and information such as the average number of duplicate values and column cardinality of the tables being queried. Such useful information provided to the optimizer results in a better access plan and a better performing query.

� Improve efficiencies

The optimizer may choose to use the index during implementation, thus avoiding more costly implementation alternatives such as table scans or creation of temporary structures. If a table scan is performed, every row in the database table must be read. Depending on the size of the tables and the complexity of the query, this an be a lengthy process and can consume a significant share of system resources.

� Ensure uniqueness

A unique index on a column will ensure that no duplicate values exist for that column.

Some of the ramifications of indexes might include:

� As mentioned previously, they can speed data retrieval. In some cases, requests might only need to use the index, never accessing the actual data (a condition referred to as Index Only Access).

� Even secondary indexes can be utilized in the case of data selection statements.

� Indexes add overhead to a database. Indexes must be maintained by the database whenever the data in the underlying table changes. Sometimes DBAs are reluctant to add indexes for reporting application efficiency if the database is one that is not dedicated to reporting purposes.

Indexing strategies is a broad topic that is covered in detail in the white paper “Indexing and Statistics Strategies for DB2 for i5/OS (which can be downloaded from this URL: http://www.ibm.com/servers/enable/site/education/ibo/record.html?indxng), but the following tips can help you get started:

� Take a proactive approach and make sure there are indexes available over all of the selection, joining, ordering, and grouping columns of your queries.

� In a reactive mode, run your queries and use the available database feedback mechanisms to determine what indexes the optimizer would like to see created.

When a query is executed, the database engine provides index advice during the optimization phase. This occurs when it determines that a useful index does not exist against the table(s) being queried; and it makes a recommendation that the index be

Chapter 14. Performance 279

Page 298: DB2 Web Query for System i

7214ch12.fm Draft Document for Review October 10, 2007 9:57 am

created. Afterward, this advice can be obtained from various sources, including the following:

– Index Advisor

– SQE Plan Cache

– SQL Plan Cache snapshot, 3020 record

– SQL Performance Monitor, 3020 record

– Visual Explain

The index advisories can be extracted from these sources of optimizer feedback and used to create the recommended indexes.

For more information on SQL and database performance analysis, refer to the redbook OnDemand SQL Performance Analysis Simplified on DB2 for i5/OS in V5R4, which can be downloaded at the following URL: http://www.redbooks.ibm.com/abstracts/sg247326.html?Open

14.5 Performance case study

In this section, a case study is conducted against a long running DB2 Web Query report to delve further into performance analysis and demonstrate some available optimizations techniques. The objective is to determine why the particular report has an excessive runtime and provide some example approaches in order to reduce the overall runtime.

The following steps are described in this section:

� Identify long running report

� Perform analysis, looking for optimization disablers

� Determine report tuning options

� Create an SQL view, and synonym, change report to use view

� Create a new report based on the SQL view

� Perform additional database analysis and tuning

14.5.1 Identify long running report

During unit testing, a report that was created using Report Assistant and the SQL CLI adapter was identified as one that required an excessive amount of time to run to completion. This report (named “Order Revenue within 180 days by Year, Month“) was taking several minutes to run, while reports similar in nature (same general format and approximately same number of rows returned) were running in seconds.

Important: Once an advised index has been created and the query is run again, you may observe that the optimizer does not use that index during implementation. Indexes are sometimes advised for the information they can provided to the optimizer. This information is used to help the optimizer cost each access method and it may actually help the optimizer determine that the advised index is not the optimal one to use during query execution.

280 DB2 Web Query for System i

Page 299: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch12.fm

14.5.2 Perform analysis, looking for optimization disablers

To help determine the reasons behind the substantial run time, DB2 Web Query provides an option to run the report and generate an SQL trace. The trace statements that are displayed help reveal any optimization disablers that might be present in the report.

Figure 14-7 Run w/SQL trace

When the report is run using this option, the SQL trace information is displayed as HTML output to the browser as shown in Figure 14-8.

Figure 14-8 Report trace results

This trace reveals a couple of interesting things. First, it shows that part of the report could not be translated to SQL. In this case, translation failed for the Defined field DAYS_DIFF because of an unsuccessful IF/WHERE Test. Second, notice how the trace shows the SQL statement that was generated (and what would ultimately be submitted to the database engine). So even though part of the translation failed, the reporting server was able to construct a meaningful SQL statement.

Chapter 14. Performance 281

Page 300: DB2 Web Query for System i

7214ch12.fm Draft Document for Review October 10, 2007 9:57 am

Using the trace, you can conclude that the problem with this report is the use of the Define field DAYS_DIFF. The line in the trace “FOCUS IF/WHERE TEST CANNOT BE PASSED TO SQL. DAYS_DIFF” indicates that DB2 Web Query attempted (and failed) to generate an equivalent search condition for the SQL statement’s WHERE clause.

Figure 14-9 Define field DAYS_DIFF

Anytime a Define field can be passed to the database engine, a more efficient report will result, particularly when the Define field is part of the selection process (which it is in the case of our example). If the Define field can not be passed to the database engine, then all the rows from the result set of the generated SQL statement are returned to the Reporting server, which now is responsible for the selection (and sorting if the report is sorted by the Define field). This is the kind of behavior that can negatively impact performance and should be avoided if at all possible. Once again, it must be emphasized that the report will be more efficient if the entire database access portion of the report definition can be pushed down to the database engine for processing.

14.5.3 Determine report tuning options

Tuning this particular report basically meant selecting one of the following three actions:

a. Eliminate the culprit Define field

b. Modify the report in an attempt to enable SQL translation for the Define field

c. Push Define field logic down to database using SQL views

For this example, the Define field was absolutely required to deliver the necessary information in the report (and therefore could not be removed). In addition, repeated efforts to fix the translation for the Define field proved to be futile. Therefore, only option C remained.

14.5.4 Create an SQL view and synonym

The next step was to create an SQL view that contained all the required tables, join syntax, columns, and selection (including the DAYS_DIFF field selection that DB2 Web Query was

282 DB2 Web Query for System i

Page 301: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch12.fm

unable to directly translate to SQL). To provide the ability to calculate the number of days between the date 1998-01-31 and the value of the SHIPDATE column, a new result column was added to the view. This result column, also named DAYS_DIFF is show in Example 14-4.

Example 14-4 DAYS_DIFF result column

DAYS('1998-01-31') - DAYS(T1.SHIPDATE) AS DAYS_DIFF

To create the new view, the following steps were taken:

1. From iSeries Navigator, open a connection to the System i server and open a Run SQL Script window

2. Type in the CREATE VIEW statement, or better yet, use the SQL selection statement displayed in the trace as a base for this view definition and make the necessary modifications. Simply copy/paste the statement into the Run SQL script window and begin making the changes. For the copy/paste method, Figure 14-10 shows more details on what needs to be added and removed from the selection statement to form the CREATE VIEW statement.

Figure 14-10 Anatomy of CREATE VIEW statement

Notice that the local selection was removed from the CREATE VIEW statement. This will be added to the statement that references the view. Also observe that the ORDER BY clause was removed. This is because views cannot be ordered. Ordering will be specified in the report definition.

Once all the necessary modifications have been made, the CREATE VIEW statement should look something like what is shown in Example 14-5

Example 14-5 Create SQL view

CREATE VIEW STAR1G.DAYS_DIFFERENCE_VIEWAS SELECT T1."SHIPDATE",T1."CUSTKEY",T1."REVENUE_WO_TAX",

T2."CUSTOMER",T3."YEAR",T3."MONTH",

Chapter 14. Performance 283

Page 302: DB2 Web Query for System i

7214ch12.fm Draft Document for Review October 10, 2007 9:57 am

DAYS('1998-01-31') - DAYS(T1.SHIPDATE) as DAYS_DIFFFROM STAR1G.ITEM_FACT T1, STAR1G.CUST_DIM T2,STAR1G.TIME_DIM T3 WHERE (T2."CUSTKEY" = T1."CUSTKEY") AND (T3."DATEKEY" = T1."SHIPDATE")

3. Execute the statement to create the view

4. From browser, open DB2 Web Query metadata window and create a synonym against the new view.

14.5.5 Create a new report based on the SQL view

Once the new view and its synonym were in place, a new report was created to access the contents of the view. To do this, the following steps were taken:

1. From DB2 Web Query home page, select Report Assistant to create a brand new report

2. From the Select from available database descriptions window, select the new view as shown in Figure 14-11

Figure 14-11 Report Assistant - select new view

3. Continue creating the new report with the view, specifying the same field format and selection criteria fields (as the original report). Examples are shown in Figure 14-12 and Figure 14-13.

284 DB2 Web Query for System i

Page 303: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch12.fm

Figure 14-12 Report using SQL view - field selection tab

Figure 14-13 Report using SQL view - selection criteria tab

4. Save the report and Quit

5. Run the new report

6. Record performance measurements

Chapter 14. Performance 285

Page 304: DB2 Web Query for System i

7214ch12.fm Draft Document for Review October 10, 2007 9:57 am

In the case of this example, significant improvements in performance were observed. In fact, simple benchmark measurements revealed that the report using the view ran over 10 times faster than the original version of the report. This is not meant to imply that you will experience the same improvements if you conduct such a tuning exercise. It is only intended to serve as an example of the kinds of efficiencies that can be obtained. Many factors can affect report performance, so your results may vary.

14.5.6 Perform additional database analysis and tuning

Once your report is using the SQL view and all database processing is being handled by the database engine, your work may not yet be done. You can potentially gain further efficiencies by performing regular database analysis and tuning. The following tools and technologies can be used to assist you in this effort:

� SQE Plan Cache

First made available in V5R2, the SQE Plan Cache is an internal, matrix-like repository that is used to store all of the statements and access plans implemented by SQE. In V5R4, an interface to this information was made available through the iSeries Navigator toolset. From this interface, you can find the SQL statement generated by DB2 Web Query and begin performing your analysis.

� Visual Explain

Visual Explain provides a graphical representation of the optimizer implementation of a query request. The query request is broken down into individual components with icons that represent each unique component. Visual Explain also includes information about the database objects that are considered and chosen by the query optimizer. Visual Explain’s detailed representation of the query implementation makes it easier to understand where the greatest cost is incurred.

� Index Advisor

Introduced in V5R4, this feature provides an easy and quick interface to index advisories issued by the optimizer. If the optimizer determines that a permanent index against a reference table might be beneficial, it returns the key columns necessary to create the suggested index. The data of the System-wide Index Advisor is placed into SYSIXADV table in the QSYS2 schema.

� Database monitor

The Database Performance Monitor is a set of integrated tools used to collect database-specific performance information for all SQL requests. It can be thought of as an SQL tracing facility, one that tracks all SQL statements, access plans used to implement the statements, resources used, and subsequent performance results. All this information is stored to a database tables, where it can be analyzed and used to identify and tune performance problem areas.

� Materialized Query Tables (MQTs)

As mentioned previously, an MQT is a DB2 table that contains the results of a query, along with the query’s definition. Because the selection, joining, and aggregation have already been performed and the results stored in the MQT, great efficiencies can be gained if the optimizer uses this table for implementation.

� Index Only Access (IOA)

The database optimizer can utilize IOA if all of the columns specified in the SQL statement are represented in the index as key columns. Because all of the columns necessary to satisfy the request are present in the index, the database engine does not have to perform random access to the table to retrieve this data. The elimination of this additional I/O operation can result in significant improvements in query response times.

286 DB2 Web Query for System i

Page 305: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch12.fm

Database performance analysis and tuning are rather broad topics that are briefly discussed in the section “DB2 for i5/OS optimization” on page 278. For a more extensive discussion on this subject, it is strongly recommended that you refer to the IBM Redbook: OnDemand SQL Performance Analysis Simplified on DB2 for i5/OS in V5R4 which can be downloaded at http://www.redbooks.ibm.com/abstracts/sg247326.html?Open

For this exercise, feedback from the optimizer (obtained by locating the statement in the SQE plan cache and launching Visual Explain) suggested the creation of the indexes shown in Example 14-6.

Example 14-6 Indexes created for case study

CREATE INDEX STAR1G.CUST_DIM_CUSTKEY_CUSTOMER ON STAR1G.CUST_DIM ( CUSTKEY ASC , CUSTOMER ASC ) PAGESIZE( 64 ) ;

CREATE ENCODED VECTOR INDEX STAR1G.ITEM_FACT_CUSTKEY_EVI

ON STAR1G.ITEM_FACT ( CUSTKEY ASC ) WITH 65355 DISTINCT VALUES ;

CREATE INDEX STAR1G.ITEM_FACT_CUSTKEY_SHIPDATE

ON STAR1G.ITEM_FACT ( CUSTKEY ASC , SHIPDATE ASC ) PAGESIZE( 64 ) ;

CREATE ENCODED VECTOR INDEX STAR1G.ITEM_FACT_SHIPDATE_EVI

ON STAR1G.ITEM_FACT ( SHIPDATE ASC ) WITH 65355 DISTINCT VALUES ;

CREATE INDEX STAR1G.TIME_DIM_YEAR_MONTH

ON STAR1G.TIME_DIM ( "YEAR" ASC , "MONTH" ASC ) PAGESIZE( 64 ) ;

These indexes were created and the report run again. Simple benchmark testing revealed modest improvements to the runtime once these indexes were created.

14.6 Performance benchmark

A performance benchmark was conducted to help deteremine DB2 Web Query runtime performance expectations relative to the equivalent Query/400 objects and SQL statements.

14.6.1 Objectives

The objectives of the benchmark were the following:

� Measure the overhead and resource usage of using DB2 Web Query product to execute existing Query/400 reports

� Measure the overhead and resource usage of running DB2 Web Query reports versus equivalent SQL statements

Chapter 14. Performance 287

Page 306: DB2 Web Query for System i

7214ch12.fm Draft Document for Review October 10, 2007 9:57 am

14.6.2 Scenarios

The benchmark test bucket included six scenarios, each with a set of eight different queries/statements. Each query was run with ten different sets of host variable values to measure variances in selectivity and cardinality. The following six scenarios of queries were measured:

1. Query/400 *QRYDFN objects (using the i5/OS RUNQRY command)

2. DB2 Web Query running the *QRYDFN objects

3. Direct SQL statements

4. DB2 Web Query reports using the DB2 CLI adapter

5. Direct SQL statements with all full open and re-optimization

6. DB2 Web Query reports using the DB2 CLI adapter with all full open and re-optimization

For each measurement the following data was captured:

1. Total execution time for a given number of loops of the executed queries and reports

2. Performance monitor data

3. Task-Profile trace. Also known as TRPOF, this is a sample-based trace that queries the processor, at user-defined intervals, to gather data on what is currently running on the processor (or processors).

14.6.3 Database and system configuration:

For all of the benchmark measurements, a sample database with approximately 1 gigabyte of data was used.

The measurements were done on an eClipz system with 1 or 2 processors, 7.5GB of memory and 6 disk arms. After running sets of measurements on the system, it was determined that 1 processor was a better match for the amount of memory and number of disk arms on the system. So all measurements reported were done with a 1 processor configuration.

14.6.4 Metrics

The measurement data was summarized down to 4 key metrics.

1. Minimum average response time per query

2. Maximum throughput

3. CPU usage

4. Memory usage

Minimum average response time per queryThe metric for minimum average response time shows the average response time per query for a single user. The average response time (sec/query) was computed as the inverse of the measured throughput (queries/sec) for a single user running back-to-back queries with no think time. The chart shows that there is a moderate response time increase for *QRYDFN objects run through DB2 Web Query compared to *QRYDFN run through Query/400. Some response time increase would expected when running from a remote client. As would be expected, the direct SQL statements had the fastest response time. The response time of the DB2 Web Query reports, though longer than the direct SQL statements, was significantly faster than the response time of the *QRYDFN objects. This is primarily due to the

288 DB2 Web Query for System i

Page 307: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch12.fm

efficiencies of the SQL generated by the DB2 Web Query running through SQE. With all queries incurring full open and optimization, more like ad hoc queries, the DB2 Web Query response time was only slightly increased. The is the case due to server jobs being recycled after each DB2 Web Query report. So the extra overhead of more full opens is incurred in the base DB2 Web Query response time numbers as well.

The results of this metric are shown in Figure 14-14

Figure 14-14 Minimum average response time chart

Maximum throughputThe objective of measuring maximum throughput is to show the maximum number of queries per second that ran before hitting a system botteneck, such as processor or disk utilization. This limit was measured by increasing the number of users running queries until no additional throughput was gained. The maximum throughput for *QRYDFN objects run through the Web Query interface was almost equivalent to the maximum throughput of running the *QRYDFN objects through Query/400. As would be expected, the executed SQL statements had the greatest throughput. DB2 Web Query does introduce some additional overhead compared to SQL, however the maximum throughput for the DB2 Web Query reports was much greater than the throughput of the DB2 Web Query *QRYDFN runs. This is due to the efficiencies of the SQL generated by the Web Query product running through SQE. With all queries incurring full open and optimization, more like ad hoc queries, the Web Query maximum throughput was only reduced slightly. The is the case due to server jobs being recycled after each Web Query report. So the extra overhead of more full opens is incurred in the base Web Query throughput numbers also.

Chapter 14. Performance 289

Page 308: DB2 Web Query for System i

7214ch12.fm Draft Document for Review October 10, 2007 9:57 am

Figure 14-15 Maximum throughput chart

Resource usage: CPUThe chart of CPU resource usage shows the amount of CPU resource used per query on average. The CPU utilization was measured when the system was running at maximum throughput. The CPU usage was then calculated as the CPU utilization divided by the queries per second at the maximum throughput point. The chart shows the small increase in CPU resource used when *QRYDFN objects are run through the Web Query interface compared to the CPU used by *QRYDFN objects run through Query/400. The chart also shows the dramatic reduction in CPU used by Web Query reports and SQL compared to the *QRYDFN objects. This is due to the efficiencies of SQL running in SQE. The Web Query reports do use more CPU than the equivalent plain SQL.

Figure 14-16 CPU usage chart

Resource usage: memoryThe chart of memory resource usage shows the minimum amount of base pool memory needed to be able to maintain the corresponding maximum throughput rates shown in the maximum throughput chart.. The memory requirement was determined by collecting a memory curve. Throughput for a fixed number of users was measured at various base pool

290 DB2 Web Query for System i

Page 309: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch12.fm

sizes. The smallest memory size measured with the high level of throughput was the memory requirement point. Web Query running *QRYDFN objects compared to *QRYDFN objects run through Query/400 required more memory. This would be expected due to the additional server jobs used by Web Query. As would be expected, the plain SQL queries required the least amount of memory. Web Query reports, running at a higher throughput rate, required about the same amount of memory as the *QRYDFN objects run through Query/400.

Figure 14-17 Memory usage chart

The data used in the above graphs is shown in Figure 14-18.

Figure 14-18 Benchmark results table

14.6.5 Conclusions

The results of the benchmark were used to derive the following conclusions:

� Comparisons of the DB2 Web Query *QRYDFN versus the Query/400 *QRYDFN runs show an increased response time. This would be expected when running to a client application as is the case with DB2 Web Query. The server CPU used was 9% more and there was more memory required.

� Comparisons of Web Query (using DB2 CLI adapter) reports to Query/400 *QRYDFN are very positive. Even with running to a client the DB2 Web Query reports ran faster, used less much less CPU, and required about the same amount of memory. This can primarlily

Chapter 14. Performance 291

Page 310: DB2 Web Query for System i

7214ch12.fm Draft Document for Review October 10, 2007 9:57 am

be attributed to the DB2 CLI adapter generating SQL and using the new SQL Query Engine (SQE). The

� Comparisons of Web Query to SQL show that Web Query has longer response times, again expected when running to a client, and uses more resources. The CPU used by Web Query is 2-4X the CPU used when running SQL, depending on whether or not the full open re-optimization was forced every time. One thing to note is that Web Query recycles the server jobs for every query

� If you are using DB2 Web Query to modernize Query/400 queries (by creating new reports), there is very little additional overhead.

� If you are creating new reports, always bear in mind that SQL is being generated, thus an understanding of SQL performance basics is vital.

292 DB2 Web Query for System i

Page 311: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch13.fm

Chapter 15. Frequently Asked Questions (FAQs)

In this chapter we list some of the most frequently asked questions (FAQs) regarding DB2 Web Query.

15

© Copyright IBM Corp. 2007. All rights reserved. 293

Page 312: DB2 Web Query for System i

7214ch13.fm Draft Document for Review October 10, 2007 9:57 am

15.1 DB2 WebQuery FAQ

This section contains the DB2 Web Query FAQ’s.

15.1.1 What was announced?

On April 10, 2007, IBM announced plans to deliver a Web-based query and report writing product that replaces the IBM Query for iSeries (also commonly known as Query/400) product.

IBM DB2 Web Query for System i will include the Query for iSeries technology to assist customers in their transition to DB2 Web Query, while offering a more modernized, Java based solution for a more robust, extensible, and productive reporting solution. DB2 Web Query will provide reporting and graphing assistants and a WYSIWYG report "painter." Customers will be able to modernize existing Query/400 reports while providing a foundation for building more complex business intelligence applications such as OLAP, data mining, dash boarding, or data warehouse implementations.

15.1.2 What are some of the capabilities of this new product?

DB2 Web Query will provide capabilities to query or build reports against data stored in DB2 for i5/OS databases through the latest browser based user interface technologies. Build new reports with ease through Power Painter or Report and Graph Assistant components. Simplify the management of reports by leveraging parameterized reporting. Deliver data to end users in many different formats, including spreadsheets, PDF, HTML or through the Java based thin client interface browser support.

DB2 Web Query will offer features to import Query/400 definitions and enhance their look and functionality with Power Painter or Graph Assistant. Add OLAP-like slicing and dicing to the reports, or view reports in disconnected mode for the end user on the go. Interface to all data in i5/OS through either DB2 or Open Query File native adapters that automatically identify the files to be accessed and import the metadata into DB2 Web Query.

15.1.3 We are happy with our Query/400 reports. Is there really any reason to move to this new product?

There are several reasons you might want to consider using this new technology:

� Query/400 does not leverage the latest query optimization technology in DB2 for i5/OS (called SQE). DB2 Web Query will offer the ability for the queries to use the query optimization features that have been put into DB2 for i5/OS over the last few years. DB2 Web Query will leverage the improved performance, automation, and monitoring capabilities of SQE.

� The parameterized reporting feature of this new product could substantially reduce the number of reports that have to be maintained individually, reducing the backlog of report writing requests.

� Today’s requests for information demand that the data be delivered in many different formats and on a request, scheduled, or alert basis. Information must be provided via easy to interpret graphical representations, dashboards, scorecards, or dumped into spreadsheets. Query/400 is very limited in it’s ability to meet these demands.

294 DB2 Web Query for System i

Page 313: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch13.fm

15.1.4 How do I migrate Query/400 reports into DB2 Web Query?

Migration of queries is accomplished via an automated facility that allows you to select the query or queries you wish to translate and produces the new Web Query report ready to run or to be brought into one of the new end user query components for customization. For more information on migrating Query/400 reports, see the chapter “Query/400 - A reliable reporting tool” on page 254.

15.1.5 Why a web based query and report writing function? Wouldn’t a Windows based solution be more robust?

The product is based on the latest Web 2.0 and AJAX web technologies, allowing you the functionality and usability usually associated with a Windows environment, but now available to browser based applications.

The zero footprint solution reduces complexity and costs, and allows any enterprise browser to be leveraged as the user interface. The AJAX framework allows sophisticated report building capabilities including modeless and modal dialogs, menus, multiple coordinated windows, partial screen updates, and more.

A web based solution offers the following benefits:

� Lower installation costs

� Lower maintenance costs

� Easy, incremental upgrades to existing applications

� User administration savings

� Simpler, and more controlled document backup and archiving

� Simpler, and more controlled security and compliance administration

� Software updates controlled on the server making them available to all users concurrently

15.1.6 What additional features are available with DB2 Web Query?

A number of additional capabilities will be available that leverage the foundation set by DB2 Web Query. Some examples of additional features include:

� Disconnected Analysis

� On Line Analytical Processing (OLAP) views

� Build highly customized applications with a Developers Workbench

� Integration with most popular ERP systems (for example, an Oracle/JDE adapter provides data dictionary” and security awareness, so the query product maintains security and integrity of the data).

� Adapters to query most popular database management systems

� Application Programming Interface (API) support to i5/OS based cubing or data mining products (specifically, SPSS’ ESSBASE/400 and Clementine products)

� Report publish/subscribe

• A light weight Extract Transformation and Load product

Chapter 15. Frequently Asked Questions (FAQs) 295

Page 314: DB2 Web Query for System i

7214ch13.fm Draft Document for Review October 10, 2007 9:57 am

15.1.7 What languages are supported?

DB2 Web Query supports the following languages:

� English

� French Canadian

� French Standard

� German

� Spanish

� Japanese

� Portuguese - Brazilian

� Chinese (Simplified)

� Chinese (Traditional)

15.1.8 Will I need to download data to a PC Server or install a Windows server to sit between the client and the System i server?

Many enterprise reporting tools on the market force you to move your data out of DB2, or require multiple servers to support various reporting functions. The IBM product is an i5/OS and thin client implementation, simplifying the whole reporting infrastructure for System i customers. Software upgrades are simplified, reliability can be increased, network traffic is reduced, and security and auditing may be simplified.

15.1.9 I have non DB2 data stored in other databases. Will I be able to use DB2 Web Query to query those databases?

With additional adapters as add-ons to DB2 Web Query, you’ll be able to build a “federated” query that combines data from many different back end databases into a single DB2 Web Query report. Over two hundred adapters are available to connect to other database or ERP systems.

You’ll also be able to combine data from multiple DB2 for i5/OS databases running on different servers or logical partitions, without requiring any additional adapters since the base product will ship with the DB2 for i5/OS adapter. For more information on setting up a cross system join, see “Setting up a cross system join” on page 47.

15.1.10 Does the Software Maintenance Agreement (SWMA) for the Query/400 product 5722QU1 cover the new DB2 Web Query product 5733QU2 when licensing is obtained from an existing 5722QU1 licensed installation?

No. A separate SWMA must be purchased for the 5733-QU2 product.

296 DB2 Web Query for System i

Page 315: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch13.fm

15.1.11 What is the recommended save and restore process for DB2 Web Query?

From a save/restore perspective, you need to be concerned about the following components of DB2 Web Query

� Synonyms (also referred to as metadata)

All synonyms are stored in the IFS directory QIBM\UserData\webquery\ibi\apps\baseapp. If you find that you are regularly creating and/or refreshing metadata information, it is recommended that you save this directory frequently. For example to save all metadata into a savefile named SYNONYMS created in library QGPL, you would issue the following command:

SAV DEV('/QSYS.LIB/QGPL.LIB/SYNONYMS.FILE') OBJ(('\QIBM\UserData\webquery\ibi\apps\baseapp' *INCLUDE))

� Reports (also referred to as Focus Execs, FOCEXECs, and FEXs)

All reports are stored in the IFS directory QIBM\UserData\webquery\ibi\webfocus76\basedir\domain_name (where domain_name equals the name of the domain that the report was created in). To save all reports (distributed throughout the various domains), save the directory QIBM\UserData\webquery\ibi\webfocus76\basedir. For example to save all reports in all domains into a savefile named ALLREPORTS created in library QGPL, you would issue the following command:

SAV DEV('/QSYS.LIB/QGPL.LIB/ALLREPORTS.FILE') OBJ(('\QIBM\UserData\webquery\ibi\webfocus76\basedir' *INCLUDE))

Similar to the synonyms, it is suggested that this directory be saved on periodically, more frequently if reports are being created and updated on a regular basis.

If you would like to save both synonyms and reports in one step, simply save the directory QIBM\UserData\webquery\ibi

RST DEV('/QSYS.LIB/QGPL.LIB/ALLREPORTS.FILE') OBJ(('\QIBM\userdata\webquery\ibi\webfocus76\basedir' *INCLUDE '\QIBM\userdata\webquery\ibi\webfocus76\basedir')) ALWOBJDIF(*ALL)

15.1.12 Can I move/deploy synonyms and reports individually?

Synonyms can be copied or moved individually using either Windows Explorer (and mapped network drives) or Developers Workbench (the recommended tool for this type of activity). Both the master file (.mas extension) and the access file (.acx extension) must be moved as a pair. Bear in mind that the tables, views, stored procedures, etc. that the synonyms are based on must exist on the target system. Otherwise any reports that references the synonyms will fail to execute.

Individual reports cannot be copied or moved to another system. However, domain level movement is supported. This means that all reports within a particular domain are moved/deployed together. Use the copy/paste or “drag and drop” capabilities in Developer Workbench to carry out these tasks.

Note: If you are looking for the report files in the Common (untitled) domain, they can be found in the directory QIBM\UserData\webquery\ibi\webfocus76\basedir\untitled\app

Chapter 15. Frequently Asked Questions (FAQs) 297

Page 316: DB2 Web Query for System i

7214ch13.fm Draft Document for Review October 10, 2007 9:57 am

In addition, you can use Windows Explorer with mapped network drives to move domains by taking the following steps:

1. Manually create the domain on the target system first (from DB2 Web Query home page or Developer Workbench). The name of the target domain must match the name of the source domain.

2. From Windows Explorer, map a network drive for both source and target systems.

3. From Windows Explorer, drag the source domain directory to the target directory T:\QIBM\userdata\webquery\ibi\webfocus76\basedir (where T is the target mapped network drive letter).

4. You will see a Confirm Folder Replace dialog window stating that there “This folder already contains a folder named...” Click the “Yes to All” button.

15.1.13 How do I manage my synonyms?

Synonyms are stored in the IFS (directory QIBM\UserData\webquery\ibi\apps\baseapp) and can be managed from one of the following interfaces

� Windows Explorer

You must first set up a mapped network drive. From this interface, you can only delete existing synonyms.

� iSeries Navigator

From this interface, you can only delete existing synonyms.

� WRKLNK command

From this interface, you can only delete existing synonyms.

� Developers Workbench

From the Developers Workbench client, you can do much more than simply deleting the synonyms. By right-mouse clicking on the selected synonym, you will see the list of available options as shown in Figure 15-1.

Note: When moving or copying domains to another system, problems may occur if your reports reference (via drill downs, hyperlinks, etc) other reports or procedures that reside in another domain.

Attention: Domain movement will not work from Windows Explorer if you skip step 1!

298 DB2 Web Query for System i

Page 317: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch13.fm

Figure 15-1 Manage synonyms from Developer Workbench

Some of the more useful options available through this interface include the following:

– Synonym Editor

The Synonym Editor provides exclusive features such as the following:

• Ability to decompose date fields

• Interface for defining filters, virtual fields, and business views,

• Ability to define appropriate dimensions for the OLAP module

– Refresh synonyms

Refreshing a synonym enables you to update field information while preserving the original synonym title, description, usage, virtual field, and DBA information. The action also synchronizes the Master File with the table on which the synonym is based.

– Domain level report movement

Use the drag and drop features to move your domains from one system to another.

15.1.14 Within my reports, how can I simulate a library list-like behavior when accessing the base tables and views?

During the report development and testing phases, you may prefer to create your reports against tables or views in a test library, verify that the reports are correct, and then at some point change the report to point to data in a different (perhaps production) library. Typically, this is easily implemented from many System i interfaces by using and manipulating your library list. However, by default, your synonym is based on a table or view that is selected from a specific library, thus the library list behavior does not occur. Creating separate versions of the report for each data library is one approach to consider, but is likely not desirable or practical if you have many reports to create and maintain.

Chapter 15. Frequently Asked Questions (FAQs) 299

Page 318: DB2 Web Query for System i

7214ch13.fm Draft Document for Review October 10, 2007 9:57 am

To obtain the library list behavior and avoid having to create a separate report for each data library, you must select the synonym setting “One part name” as shown in Figure 15-2.

Figure 15-2 Specifying one part name during synonym creation

Specifying one part name for the synonym prevents DB2 Web Query from hard coding the library name in the meta data. When the report (based on a one part name synonym) is run, the requesting user’s library list is searched for the table or view name(s) that the synonym is based on. This means that you will either have to log in as a different user profile in order to have the report access data in a different library, or an easier technique would be to change the library list of the job description defined to the user profile.

As long as the formats of the files in the different libraries are the same, this method is possible to carry out.

15.1.15 I noticed that DB2 Web Query is using port 11331 for HTTP requests. What if I am already using this port for something else? Is there any way to change it?

Yes,it is possible, but if the proper steps are not taken, adverse effects can result. If there is a conflict with any of the port numbers that DB2 Web Query uses, the best option is to contact IBM Support and they can take you through the appropriate procedures for changing the assigned ports.

Note: From a DB2 Web Query perspective, the user’s library list is determined and controlled by the system values QSYSLIBL and QUSRLIBL as well as the job description that is defined for the user profile. Any other method of setting the library list is not recognized by DB2 Web Query. For example, if you are using the initial program (specified in the user profile) to manipulate the library list when the user signs on, this method will fail because the initial program is not executed during the DB2 Web Query session.

300 DB2 Web Query for System i

Page 319: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch13.fm

15.1.16 How can I limit the number of rows being retrieved during the report development phase?

If you are developing reports that are retrieving large numbers of rows from the database, you may find it useful to restrict the number of rows being returned (and avoid waiting for all this information to be returned to the client).

To obtain this behavior, follow these steps:

1. Open the report

2. Select Report Options tab

3. As shown in Figure 15-3, specify the number of records that you would like retrieved.

Figure 15-3 Limit number of rows retrieved.

4. Click Save

Important: Do not forget to remove this setting prior to moving your report into production. Failure to do so will result in a report that does not retrieve all of the rows that satisfy the selection criteria of the report.

Chapter 15. Frequently Asked Questions (FAQs) 301

Page 320: DB2 Web Query for System i

7214ch13.fm Draft Document for Review October 10, 2007 9:57 am

15.1.17 When I access the DB2 Web Query web console, I only see a limited number of options. What happened to the other options?

If you sign into the DB2 Web Query web console (port 11333) and only see the Data Adapter option on the top of the screen (as shown in Figure 15-4), you are probably not signed in as the user profile QWEBQRYADM.

Figure 15-4 Limited options from DB2 Web Query console

To see the full set of administrative options from the web console, close the browser session and sign into the web console using the QWEBQRYADM user profile. You should see the full list of menu options as shown in Figure 15-5.

Figure 15-5 All options from DB2 Web Query console

302 DB2 Web Query for System i

Page 321: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch13.fm

15.1.18 What happens to my existing queries when I upgrade to 5733QU2?

Nothing will happen to your existing queries when you upgrade to 5733QU2. They will still run and the Query/400 product will still be supported.

15.1.19 Query/400 supported exception joins. How do I specify that type of join with DB2 Web Query?

The DB2 Web Query development tools available through the web browser interface (Report Assistant, Graph Assistant, and Power Painter) do not support the specification of Left Exception, Right Exception, and Right Outer join types. If you need this functionality in your report, you must take the following steps:

1. Create an SQL view with the appropriate tables and join syntax

Example of creating a view with an exception join:

CREATE VIEW century/examplejoin AS ( SELECT a."StoreName", b."LineTotal" from century/stores a LEFT EXCEPTION JOIN century/orders b ON a."StoreCode" = b."StoreCode")

Example of creating a view with a right outer join:

CREATE VIEW century/examplejoin AS ( SELECT a."StoreName", b."LineTotal" from century/stores a RIGHT OUTER JOIN century/orders b ON a."StoreCode" = b."StoreCode")

2. Create a synonym against that view

3. Base your report on the synonym of the view

15.1.20 I have my own stylesheets that I would like to use for my reports. How do I make them available from Report Assistant?

From the Reporting Options tab in Report Assistant, you can specify a stylesheet under the field “Apply an existing WebFocus Stylesheet.” To add your own stylesheets to this drop down list, take the following steps:

1. Copy your stylesheet files to the IFS directory \QIBM\UserData\webquery\ibi\webfocus76\basedir\import

Once they are in that directory they will be available to every domain for importing.

2. To import, open the desired domain, right mouse click Other Files folder, and select Import.

The Select Files to Add dialog window is displayed, showing the list of stylesheets.

3. Select the stylesheet files from the list and click Save.

Attention: Do not remove the Query/400 Licensed Program Product 5722QU1. This LPP is still required, even after you have installed 5733QU2.

Chapter 15. Frequently Asked Questions (FAQs) 303

Page 322: DB2 Web Query for System i

7214ch13.fm Draft Document for Review October 10, 2007 9:57 am

The stylesheets are now available from Report Assistant.

15.1.21 Can DB2 Web Query handle stored procedures with input parameters?

Yes, DB2 does allow your stored procedures to have input parameters. However, you must specify a value for the input parameter during the synonym creation process. Don’t worry though - even though it must be specified here, this value is not actually stored with the synonym definition and is not passed to the procedure during execution.

When creating the report against the stored procedure. You will see the input parameter listed in the list of available fields. From the selection criteria tab, select this field as shown in Figure 15-6.

Figure 15-6 Using a stored procedure with an input parameter

If you want to have the input parameter that is passed from the report to the stored procedure be selected from a drop down list, you must specify a different source synonym (than the stored procedure).

Tip: Many sample stylesheets are provided as part of the base product and can be used in your reports. They have the file extension .STY and can be found in the IFS directory \QIBM\UserData\webquery\ibi\webfocus76\template.

To make these stylesheets available in the Report Assistant interface, simply copy the .STY files into the directory specified in step 1 above and follow the remaining steps.

304 DB2 Web Query for System i

Page 323: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch13.fm

15.1.22 How do I open my Excel spreadsheet reports in Microsoft Excel instead of the web browser?

By default, whenever you open a report whose output format is defined as an Excel spreadsheet, your browser will attempt to open the XLS file in the same browser session (using an XLS plugin). If you would rather have the spreadsheet opened in Excel, take the following steps:

1. Open Windows Explorer

2. On the Tools pull-down menu, select Folder Options

3. Select the File Types tab

4. In the Registered file types list, find and select XLS (Microsoft Excel Worksheet) and click the Advanced button as shown in Figure 15-7

Figure 15-7 Windows folder options - Advanced

5. In the Edit File Type dialog window, make sure the “Confirm open after download” and “Browse in same window” options are NOT checked as shown in Figure 15-8.

Chapter 15. Frequently Asked Questions (FAQs) 305

Page 324: DB2 Web Query for System i

7214ch13.fm Draft Document for Review October 10, 2007 9:57 am

Figure 15-8 Edit File Type

6. Click OK.

7. Close browser window and try again

15.1.23 Is the pricing for each of the IBM add-ons also based on named user pricing scheme?

With the purchase of the IBM add-on Active Reports or OLAP Module, all named users of the base product will have access to that additionally purchased feature. For the Developer Workbench, each client is licensed separately.

15.1.24 Given this is browser based access, how is the security established for the users?

A user is allowed to work with reports within a DB2 Web Query domain. Each domains is associated with 2 group profiles - one for report developers and one for report users. User profiles are then added to the appropriate group profile. If a user profile is a member of the "report developer" group profile associated with the domain, that user can create, edit, and run reports within that domain. Similarly, user profiles that are members of the "report user" group profile can (only) run all reports within the associated domain. The developer class named users are members of a group user profile name prefixed by MD, and user class named users are members of a group user profile name prefixed by MU. So for example, if your domain was named SALESREP, the developer group profile would be named MDSALESREP and the user level group profile would be MUSALESREP.

In addition, when the report is executing, normal i5/OS object level security is enforced. Therefore, if the user running the query does not have the appropriate authority to the underlying database object, the query execution will fail accordingly.

306 DB2 Web Query for System i

Page 325: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch13.fm

15.1.25 Is the Report Caster feature part of the base licensing?

No. The Report Caster product is a separately orderable feature from Information Builders.

15.1.26 What is the benefit to using the JDE adapter add-on, as compared to just using standard DB2 for Web Query access?

The adapter uses the JDE APIs and Dictionary support to enable working with and seeing both the layout and data in the JDE specific format. Additional features like security specific to JDE would also be enabled, due to the use of the JDE APIs.

15.1.27 Does the named user access apply to both a developer of queries and a user that runs a query?

Yes, both are named users. Active Reports allows disconnected access to the data already produced by a report, of course with the additional features like visualization, etc., and a user of that data does not need to be a named user.

15.1.28 Since a named user must run the report, can a report be scheduled to be run by that user?

The Report Caster feature from Information Builders is required to run scheduled reports.

15.1.29 Can a named user connect with multiple sessions concurrently? For example, I would like to work on two separate queries at the same time.

No. the named user licensing allows only one session to be active per named user. A different user profile would have to be used to activate a second session.

15.1.30 Will the imported query definition start using SQL, such that the SQL Query Engine versus the Classic Query Engine would be used?

No. The reports based on Query Definition objects are generated from the metadata available from the query object itself, and will continue to be run using the RUNQRY which uses the Classic Query Engine (CQE). A new Web Query should be created to replace an existing query, to enable an SQL interface to the data. This is the only way to have the query processed by the SQL Query Engine (SQE).

Chapter 15. Frequently Asked Questions (FAQs) 307

Page 326: DB2 Web Query for System i

7214ch13.fm Draft Document for Review October 10, 2007 9:57 am

15.1.31 The OLAP feature is enabled by defining dimensions for the database. How does DB2 Web Query get those dimensions?

The dimensions must be defined in advance using the Developer Workbench.

15.1.32 Can my DB2 Web Query reports run with adopted authority?

Yes. If you need the ability to run with adopted authority, you would need to register an existing program (one with adopted authority) as a stored procedure. You would then create a synonym against that stored procedure. In order for DB2 Web Query to receive data back and create a report against that data, the program/stored procedure (or one in the subsequent call stack) must return at least one result set.

15.1.33 My user profiles are already members of a group profile. Since this user profile parameter (GRPPRF) is already specified, how can domain authority be established?

Use the Supplemental Group (SUPGRPPRF) parameter of the CRTUSRPRF/CHGUSRPRF command. This parameter accepts multiple values and can also be used to establish the association of a user with a domain.

15.1.34 Is the server based processing performed by the Websphere Application Server, or something requiring less overhead?

A lighter weight integrated application serving environment is used, one with more specific and limited functionality. The product does not require any WAS instances to be running.

15.1.35 Can a more granular level of security be established, for example, to limit a report for a specific user?

From the perspective of what reports are displayed to the user on the DB2 Web Query launch page, the answer is “No”. Domain level is the lowest level of security and determines what reports are displayed to a particular user. However, object level security implemented on the System i5 is honored. This means that although users may see a report, if they are not authorized the underlying database objects used by the report, report execution will fail.

15.1.36 Are column headings automatically obtained for the accessed files?

Yes, column headings are obtained from the files. If you used DDS to define your file, the value of the field level keyword COLHDG. However the separate metadata layer does allow for further customization of column headings and other attributes.

308 DB2 Web Query for System i

Page 327: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch13.fm

15.1.37 I have created a report with output to an Excel spreadsheet. Does a drill-down (clicking an active link) access another spreadsheet?

Yes, but only if the spreadsheet is opened in the browser window. The drill down is active while in a browser, using an Excel plug-in to place the data from the referenced report in the browser window.

15.1.38 Is there an automated way to import Query/400 objects?

No. The process to import queries is a manual process.

15.1.39 When cascading through data in an OLAP report, is the data limited based on prior selections?

Yes. For example, specifying country United States would limit the States/Provinces list to only the states in the United State, such that no data associated with Canada would be available to cascade.

15.1.40 Is the knowledge of file relationships (Referential Integrity) a feature of the database or DB2 Web Query?

The ability of DB2 Web Query to understand the file relationships, is based on the previously defined Referential Integrity on the database. The Primary Key and Foreign Key relationships establishes the ability to implicitly understand the join relationship for such data. Once this has been established, you can select the “With foreign key “ setting (when creating metadata) to pass this knowledge to DB2 Web Query

15.1.41 Does the 5722QU1 product need to be ordered when 5733QU2 is ordered?

If you do not currently have 5722QU1, it will be delivered with the QU2 product.

15.1.42 Is there a Try & Buy for the IBM add-on components (Active Reports, OLAP Module, and Developer Workbench)?

Yes, there is a 70 evaluation period. At the end of this period, you will have to obtain license keys from IBM to continue using these components.

Chapter 15. Frequently Asked Questions (FAQs) 309

Page 328: DB2 Web Query for System i

7214ch13.fm Draft Document for Review October 10, 2007 9:57 am

15.1.43 How are the DB2 Web Query domains established?

Only an administrative class user can create new domains. Such a user must be a member of the group profile MRADMIN. Domain creation is a manual process that can only be performed by members of this group profile.

15.1.44 Will a query that was previously imported still function as an imported report, after the Query Definition has been changed?

Yes, as long as the definition of the original Query/400 object is not changed to remove fields or change existing fields to an incompatible type with those in the existing metadata.

Can an imported query be saved with removal of reference to the existing query; effectively create an actual Web Query report from the imported query?

No. To fully detach the reference to the original query definition, a new DB2 Web Query report must be created without reference to metadata from a query definition object.

15.1.45 Since the 5733QU2 product is announced as a Query/400 replacement, will either the interactive query definition-time and run-time support be removed from the system?

No. There are no plans to remove the interactive WRKQRY feature [in library QQRYLIB], nor its underlying run-time support RUNQRY [in library QSYS, an integrated part of the i5/OS].

15.1.46 When building a dashboard, can graphics be included, for example company logo?

Yes, this can be done using the HTML Layout Painter tool (part of Developer Workbench) or Power Painter. The dashboard is a web page, which can have a large variety of elements placed for viewing.

15.1.47 Will the dashboard allow a periodic report; an effective automatic update?

No. The report must be obtained or refreshed manually,

15.1.48 One of the report output options is "Excel with formulas." What does that really mean?

Calculations and summaries will be output to the Excel spreadsheet as formulas instead of literal values, such that the recipient of that spreadsheet can do row or column manipulations, for example delete a row, and the results of cells with formulas will be automatically updated.

310 DB2 Web Query for System i

Page 329: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch13.fm

15.1.49 Does a copy of the Developer Workbench come with the base product?

No. The Developer Workbench is a separately purchased feature available from IBM, and is installed on a client PC.

15.1.50 Is there an option in output to Excel, to establish 'cell protection' for formulas, to ensure that for reports sent to an analyst, that the formula can not be accidentally changed?

No, there is no current option to establish Excel cell protection.

15.1.51 How large is an Active Report file?

This depends almost entirely on the amount of data from a file. The definitional attributes to allow actively working with the data in the browser will be relatively fixed in size, by comparison to the amount of actual data included in the report.

15.1.52 Can an Active Report be saved with the active visualizations and any other changes made by the user?

Yes. The Active Report file can be saved with the current formatting and visualizations specified by the user.

15.1.53 Some Query/400 definitions are scripted in a CL Program, such that one query produces output which will be used by the next query for input. Will that be possible with Web Query?

The same thing can be accomplished, but an inhibitor may be use of the QTEMP library. The browser initiated work runs in the QSQSRVR jobs, and there is no assurance that the QTEMP for one query will be the same as for the next query. A permanent library would need to be specified.

15.1.54 How can the SQL that is produced for the report be viewed?

By using the “Run w/SQL” option. This will send the SQL statement generated by DB2 Web Query to the browser. In addition, the i5/OS database features via iNavigator such as the SQE Plan cache and Database Monitor can be used to determine what SQL statement was produced and submitted to the database engine.

Chapter 15. Frequently Asked Questions (FAQs) 311

Page 330: DB2 Web Query for System i

7214ch13.fm Draft Document for Review October 10, 2007 9:57 am

15.1.55 In parameterized reports, can more than one item be selected from the list?

Yes, as long as the parameter was defined to allow multiple selections. by using the standard Windows selection method; Ctrl-click to add or remove a selected entry.

15.1.56 Is there a way to specify double-spaced printing?

Yes, this is controlled by custom style sheets.

15.1.57 Is signon to the product available via LDAP or Kerberos?

No, there is currently no support for single signon environments like LDAP and Kerberos.

15.1.58 Can a drill-down report have further drill-downs defined?

The active link for the drill-down is just another report. As many levels as exist for which a report can represent another drill-down. The only limit is the existence of the report to process the link.

15.1.59 How does one create dashboards? Using the Power Pointer tool?

Power Painter does enable specifying multiple reports to appear on a single page. However the Developer Workbench provides an HTML Layout Painter which would typically be used to design a dashboard for an HTML interface such as the a web browser.

15.1.60 Is there any integration with the Rational tools with this product?

No, there is no Websphere or Rational integration.

15.1.61 Is there integration to portlets with Portal 6.0?

No, not with DB2 Web Query product. You would need to upgrade to Information Builders Web Focus product to integrate with portlets.

15.1.62 Report Caster seems like a good fit for our company? How would I find more information on this product?

Report Caster is an add-on component that is only from Information Builders. Any questions regarding this product should be directed to Information Builders..

312 DB2 Web Query for System i

Page 331: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ch13.fm

15.1.63 Can a model 8## system have the product QU2 installed?

Any system which has a supported release V5R4, can have the product ordered and installed.

15.1.64 Is there a *NOMAX licensing available?

No. The product is offered with user-based named user licensing only. Information Builders offers a product WebFocus which offers an unlimited number of users.

15.1.65 How are named users managed, established, or removed?

The 5733QU2 product provides programs that are interfaces to the licensing APIs to both add and remove a user. Thus the named users are tracked in the licensing information:

To view the named users: WRKLICINF PRDID(5733QU2), option 8 for feature 5050

To add a named user: CALL QWEBQRY76/WQADDLIC UsrPrfName

To remove a named user: CALL QWEBQRY76/WQRLSLIC UsrPrfName

15.1.66 Is there auditing available for running a Web Query report?

No, any auditing features would have to be implemented by other methods, such as the use of stored procedures for which specific logging could be done, the database open exit program, the SQL CLI exit program, and object journaling.

15.1.67 Can I run a DB2 Web Query report from within a CL program?

Yes, the RUNWEBQRY command is delivered with the product. However, its support is limited to output to a spooled file.

66.If there is a known join relationship that is not defined to the database as RI, is there a way to define the relationship in the metadata?

Yes, using Business Views (a feature that is part of Developer Workbench). Alternatively, to define the relationship you can create an SQL VIEW, add the RI definitions, or manually add the Join specifications for the reporting.

15.1.68 In an OLAP report, can ordering be done like in Active Reports?

Yes, you can resort the report, based on any of the displayed columns.

Chapter 15. Frequently Asked Questions (FAQs) 313

Page 332: DB2 Web Query for System i

7214ch13.fm Draft Document for Review October 10, 2007 9:57 am

15.1.69 Is there a way to automate the generation/update of the metadata? An API perhaps?

No, there is neither metadata automation nor an API to build/rebuild the metadata. It must be done manually.

15.1.70 Can selection be defined on an expression?

In some/most cases, it can, using defined fields. There are some limitations such as expressions that use aggregate functions (for example, percentage of total). In these cases one could use an SQL view or the SQL wizard to create a report with these requirements.

15.1.71 How is a parameterized report designed, specifically to establish the inputs?

The parameterized query defines the inputs using the HTML Layout Painter in the Developer Workbench.

15.1.72 Where can I find more training on the products?

System i eLearning training is available on Information Builder’s website, http://education.informationbuilders.com/edu/Systemi.html . Registrants to the training have access to the site for 30 days. Following the 30 day trial, the service is available on an annual subscription basis for a nominal fee.

314 DB2 Web Query for System i

Page 333: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214p05.fm

Part 5 Appendixes

In this section we will explain more specific topics on DB2 Web Query.

Part 5

© Copyright IBM Corp. 2007. All rights reserved. 315

Page 334: DB2 Web Query for System i

7214p05.fm Draft Document for Review October 10, 2007 9:57 am

316 DB2 Web Query for System i

Page 335: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ax01.fm

Appendix A. Metadata in the IFS

This appendix provides a more detailed understanding of what is created on the i5 server when DB2 Web Query metadata is created.

Every time a synonym is created in DB2 Web Query, two files are automatically created in the IFS that allow DB2 Web Query to read from that object. These files are located in the directory ‘/qibm/userdata/ibi/apps/baseapp’. The two files that are created are called a master file and an access file.

� Master files - This file identifies the fields of the table or, if the object is a QRYDFN, the fields of that query’s result set. The master file has an extention of .mas. The fields are described in terms of length and data type. This file is similar to the information in a DSPFFD, but the information is described in a way that DB2 Web Query understands.

Figure A-1 shows a master file for table QWQCENT/ORDERS.

A

© Copyright IBM Corp. 2007. All rights reserved. 317

Page 336: DB2 Web Query for System i

7214ax01.fm Draft Document for Review October 10, 2007 9:57 am

Figure A-1 Master File for table QWQCENT/ORDERS

� Access files - This file identifies the object name and type that the metadata is created on. The access file has an extention of .acx. If the object is a QRYDFN, it wil say QIQRY. If the object type is a table, it will say TABLENAME.

Figure A-2 shows an access file for table QWQCENT/ORDERS.

Figure A-2 Access file for table QWQCENT/ORDERS

For QRYDFN objects there are three additional metadata files: the .fex, the .txt and the .inf.

Deleting metadataThere is no interface in DB2 Web Query to delete metadata. If you know there are no more reports based on this object, nor will anymore be written, you can manually delete the metadata. Also if you have changed the underlying QRYDFN or From the System i command line run this command:

WRKLNK '/QIBM/USERDATA/IBI/APPS/BASEAPP'

318 DB2 Web Query for System i

Page 337: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ax01.fm

Take an option 5 by BASEAPP and browse that directory for the metadata you wish to delete. When you have found it, take an option 4 and push enter to delete.

If you have changed the underlying table or QRYDFN, and if you have recreated the metadat wiht the “overwrite” option, the master file is correctly updated. A new master file is not created. So you will not need to do any manual delete of metadata if you have only used the “overwrite” option.

Appendix A. Metadata in the IFS 319

Page 338: DB2 Web Query for System i

7214ax01.fm Draft Document for Review October 10, 2007 9:57 am

320 DB2 Web Query for System i

Page 339: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ax02.fm

Appendix B. Date and Time functionality

Date support is very strong in DB2 Web Query. Most of the details in this appendix can be found in the help text provided with Developer Workbench. The information is not in the help text with the base product so it has been reproduced here.

B

© Copyright IBM Corp. 2007. All rights reserved. 321

Page 340: DB2 Web Query for System i

7214ax02.fm Draft Document for Review October 10, 2007 9:57 am

Date and Time System Variables

The following table lists the date and time variables available in DB2 Web Query.

Table 15-1

Date Format

The various date formats enable you to define a field as a date and work with it as a date. Using date format, you can:

� Define date components such as year, quarter, month, day, and day of week, and extract them easily from date fields.

� Sort reports into date sequence, regardless of how the date appears i.e. January will sort before April even though, without date smarts, April alphabetically comes before January.

� Do arithmetic with dates and compare dates without resorting to special date-handling functions.

Date Format Display Options

The date format does not specify type or length; instead, it specifies date component options (D, W, M, Q, Y, and YY) and display options. These options are shown in the following chart.

System Variable Description Format or Value

&DATE Returns the current date. MM/DD/YY

&DMY Returns the current date. DDMMYY

&DMYY Returns the current (four-digit year) date.

DDMMCCYY

&MDY Returns the current date. Useful for numerical comparisons.

MMDDYY

&MDYY Returns the current (four-digit year) date.

MMDDCCYY

&TOD Returns the current time you entered DB2 Web Query.

HH.MM.SS

&YMD Returns the current date. YYMMDD

&YYMD Returns the current (four-digit year) date.

CCYYMMDD

Display Option Meaning Effect

D Day Displays a value from 1 to 31 for the day.

M Month Displays a value from 1 to 12 for the month.

322 DB2 Web Query for System i

Page 341: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ax02.fm

Y Year Displays a two-digit year.

YY Four-digit year Displays a four-digit year.

T Translate month When used with M in a date (MT or TM) The three-letter abbreviation for the month in uppercase is displayed.

t Translate month When used with M in a date (Mt or tM) The three-letter abbreviation for the month is displayed, capitalizing only the first letter of the month or day.

TR Translate month or day TR is like T but displays the full name in uppercase.

tr Translate month or day tr is like t but displays the full name in mixed case.

Q Quarter Displays the quarter Q1 - Q4.

W Day-of-Week On its own W will display the number of the day of the week (1-7, Mon=1). Used in combination with other date options W will display a three-letter abbreviation of the day of the week in uppercase.

w Day-of-Week Functions as uppercase W (described above), except that the first letter is uppercase and the following letters are lowercase.

WR Day-of-Week Functions the same as uppercase W (described above), except that the entire day name is displayed instead of an abbreviation.

wr Day-of-Week Functions the same as lowercase w (described above), except that the entire day name is displayed instead of an abbreviation.

JUL Julian format Displays date in Julian format.

YYJUL Julian format Displays a Julian format date in the format YYYYDDD. The 7-digit format displays the four-digit year and the number of days counting from January 1. For example, January 3, 2001 in Julian format is 2001003.

Display Option Meaning Effect

Appendix B. Date and Time functionality 323

Page 342: DB2 Web Query for System i

7214ax02.fm Draft Document for Review October 10, 2007 9:57 am

Sample output for various date formatting options is shown below.

Controlling the Date Separator

You can control the date separators when the date is displayed. In basic date format, such as YMD and MDYY, the date components are displayed separated by a slash character (/). The same is true for the year-month format. Year-quarter format is displayed with the year and quarter separated by a blank (for example, 94 Q3 or Q3 1994). The single component formats display just the single number or name.

The separating character can be changed to a period, a dash, or a blank, or can even be eliminated entirely. The following table shows the FORMAT specifications that can be used to change the separating character.

Table 15-2 Date Separators

Using Date Fields

Valid examples of specifying dates are shown in the following chart.

Table 15-3

Translation Display

MT JAN

Mt Jan

MTR JANUARY

Mtr January

WR MONDAY

wr Monday

Q Q1

YQ 07Q1

Format Display

YMD 93/12/24

Y.M.D 93.12.24

Y-M 93-12

YBMBD 93 12 24 (The letter B signifies blank spaces.)

Y|M|D 931224 (The concatenation symbol "|" eliminates the separation character.)

Situation Natural Date Literal

In WHERE screening WHERE MYDATE IS 'APR 25 1999'

In arithmetic expressions MYDATE - '1999 APR 25'

324 DB2 Web Query for System i

Page 343: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ax02.fm

Date Fields in Arithmetic Expressions

The general rule for manipulating date fields in arithmetic expressions is that date fields in the same expression must specify the same date components. The date components can be specified in any order, and display options are ignored. Valid date components are Y or YY, Q, M, W, and D.

For example, if NEWQUARTER and THISQUARTER both have FORMAT specifications of Q, and the value of THISQUARTER is 2, then the following statement

NEWQUARTER = THISQUARTER + 3

gives NEWQUARTER a value of 1 (that is, the remainder of 5 divided by 4).

The following example calculates the number of days elapsed since January 1, 1999:

YEARTODATE = ORDERDATE - 'JAN 1 1999' ;

Converting Date Fields

You can also convert date fields. Two types of conversions are possible: format conversion and date component conversion. In format conversion, the value of a date format field can be assigned to an alphanumeric or integer field that uses date display options; the reverse conversion is also possible.

In date component conversion, a field whose format specifies one set of date components can be assigned to another field specifying different date components. For example, the value of REPORTDATE (DMY) can be assigned to SALESDATE (Y); in this case, the year is being extracted from REPORTDATE. If REPORTDATE is Apr 27 99, SALESDATE is 99.

Date Functions

Here are a few of the more common functions that you can do with dates. These are described in more detail in the help text included with Developer Workbench.

DATEADD Add or subtract a date unit to/from a date

You can add or subtract years, months, days, weekdays or business days from your date. Business days can take a holiday file as input. By default a business day and a weekday are the same thing.

DATEADD(date, ‘Y/M/D/WD/BD’, increment)

The field ‘date’ must have a format like YYMD, MDY or JUL. Increment must be an integer.

Figure 15-9 demonstrates adding 11 business days (‘BD’) to the order date to calculate the ship date.

In computational date comparisons IF MYDATE GT '25 APR 1999'

Situation Natural Date Literal

Appendix B. Date and Time functionality 325

Page 344: DB2 Web Query for System i

7214ax02.fm Draft Document for Review October 10, 2007 9:57 am

Figure 15-9 DATEADD

The DATEADD function is not required if you simply want to add months or days to a date. To add months your result field must be in a format similar to ‘YYM’ or ‘MY’. To add days your result field must contain days i.e. YYMD.

If we simply wanted to add 11 days to SHIPDATE in the above example and didn’t need to worry about business or weekdays we would replace the DATEADD with:

ORDERDATE + 11

This would create a SHIPDATE 11 days in the future.

DATEDIFF Calculate the difference between two dates

Similar to DATEADD this function allows you to find the difference between two dates in terms of years, months, days, weekdays and business days. If you only want to find the difference in months or days you do not need to use DATEDIFF you can simply code a statement like:

ORDERDATE - SHIPDATE

The resulting value will be based on the least significant component in the order and ship dates. For example if one of the dates was defined as YYM then your results would be in months. If both dates were defined down to the day level then your results would be in days.

The result field from DATEDIFF should be defined as an I8 field.

DATEDIFF(date1, date2, ‘Y/M/D/WD/BD’)

Date1 and/or date2 can be fields or constants i.e. ‘20070101’.

Figure 15-10 DATEDIFF

DATEMOV Move the date to a significant point

DATEMOV moves your date field to a significant point such as the end of the week or the beginning or the quarter.

DATEMOV(date, ‘move-point’)

The date field must be a full date i.e. MDYY or YYJUL.:

Move-point

EOM End of month

326 DB2 Web Query for System i

Page 345: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ax02.fm

BOM Beginning of month

EOQ End of quarter

BOQ Beginning of quarter

EOY End of year

BOY Beginning of year

EOW End of week

BOW Beginning of week

NWD Next weekday

NBD Next business day

PWD Prior weekday

PBD Prior business day

WD- Current weekday or prior weekday (if weekend)

BD- Current business day or prior business day if current is non business day

WD+ Current weekday or next weekday (if weekend)

BD+ Current business day or next business day if current is non business day

Move-point

Appendix B. Date and Time functionality 327

Page 346: DB2 Web Query for System i

7214ax02.fm Draft Document for Review October 10, 2007 9:57 am

328 DB2 Web Query for System i

Page 347: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ax02b.fm

Appendix C. Define and Compute fields processing differences

This section describes how Web Query processes a Define or Compute at different points in the reporting sequence.

C

© Copyright IBM Corp. 2007. All rights reserved. 329

Page 348: DB2 Web Query for System i

7214ax02b.fm Draft Document for Review October 10, 2007 9:57 am

Web Query calculation sequence

Let’s take a look at the reporting sequence to illustrate the differences between the Define and Compute, as shown in Figure 15-11.

Figure 15-11 DB2 Web Query Processing Sequence

Listed below are the differences:

� When Web Query begins to process a report request, it first locates the Master File Description(MFD) and the database. Web Query then processes the WHERE test on a database value to select a valid record for the report.

� After selecting a record, Web Query determines the value of each Define, in sequence. After determining the values of the Define, it executes any selection tests that use the value of a Define and potentially further limits the number of records per report.

� Web Query then sorts the data(according to the BY and ACROSS phrases) and performs the action indicated in the verb phrase(PRINT, SUM, COUNT). If the report uses SUM or COUNT, it aggregates the values in memory.

� Web Query then takes the processed data and determines the values of any Computes, in the sequence in which they appear in the request.

� After evaluating the Computes, Web Query performs the final selection test; Web Query performs any WHERE TOTAL tests against any aggregated results and the values of Computes, and thereby further limits the records for the report.

� Finally Web Query formats the report and routes it to your Web browser.

FOCUS ProcessingLocate the file description(s) and data files

Select records based on database values

Sort the Data

Prepare individual and/or aggregated values

Select records based on TOTAL tests

Format the report

Determine values ofDEFINEd fields

Resolve COMPUTEd fields

DEFINE workswith individual

database values

COMPUTE workswith aggregatedvalues

Select records basedon DEFINEd fields

Web Query Processing Sequence

330 DB2 Web Query for System i

Page 349: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ax02c.fm

Appendix D. Setting up DB2 Web Query to run in an IASP environment

In this section we will explain how to setup IBM DB2 Web Query in an IASP environment, thus meaning:

� storing the IBM DB2 Web Query IFS user objects in IASP directories, to be able to use the environment on the second system when the IASP gets allocated to that machine

� creating reports/graphs on data stored in the IASP Database, being able to execute them alternatively from the system to which the IASP is allocated.

We assume that the switchable IASP environment is already configured and fully operational, with a "switchable" common IP interface defined that will allow the end user to use the same URL to connect to DB2 Web Query, regardless of the system that has allocated the IASP at a given moment.

In this section IASP520 will be used as the IASP name and IASP520DB as the IASP Database name, we will be referring to IBM DB2 Web Query as QU2.

D

© Copyright IBM Corp. 2007. All rights reserved. 331

Page 350: DB2 Web Query for System i

7214ax02c.fm Draft Document for Review October 10, 2007 9:57 am

On the first System

With the IASP device varied on, perform the following tasks:

1. Restore the CENTURY sample library in the IASP:

RSTLIB SAVLIB(CENTURY) DEV(*SAVF) SAVF(QGPL/CENTURY) RSTASPDEV(IASP520)

2. Install DB2 Web Query following the instructions explained in Chapter 2, “Installation and Server Operations” on page 17, start it and verify it is working correctly.

3. End DB2 Web Query

4. Save the /qibm/UserData/webquery directory subsequently move it in IASP, using a save file:

CRTSAVF FILE(QGPL/WEBQRYIFS) TEXT('WebQuery IFS USERDATA Objects')

SAV DEV('/qsys.lib/qgpl.lib/WEBQRYIFS.file') OBJ(('/qibm/UserData/webquery')) DTACPR(*YES)

Note: received message 1450 objects saved in Beta3

5. Allocate IASP to your job:

SETASPGRP ASPGRP(IASP520)

6. Verify that you can get to the sample data library, Century:

DSPLIB LIB(CENTURY)

7. Restore the /qibm/UserData/webquery directory in IASP:

RST DEV('/qsys.lib/qgpl.lib/WEBQRYIFS.file')

OBJ(('/qibm/UserData/webquery' *INCLUDE '/IASP520/webquery'))

Note: received message 1450 objects restored in Beta3

8. Rename /qibm/UserData/webquery directory to "webqueryORI":

REN OBJ('/qibm/UserData/webquery') NEWOBJ(webqueryORI)

9. Add a symbolic link to map the newly restored IASP directory on the original path:

ADDLNK OBJ('/IASP520/webquery') NEWLNK('/qibm/UserData/webquery') LNKTYPE(*SYMBOLIC)

You should get the message "Link added".

10.Authorize user QTMHHTTP to path /qibm/UserData/WebQuery/ibi/webfocus76/*:

CHGAUT OBJ('/qibm/UserData/WebQuery/ibi/webfocus76/*') USER(QTMHHTTP) DTAAUT(*RWX) OBJAUT(*ALL) SUBTREE(*ALL) SYMLNK(*YES)

11.Signon as user QWEBQRYADM, allocate the IASP and start DB2 Web Query:

SETASPGRP IASP520

QWEBQRY76/STRWEBQRY

Now you are ready to proceed to configure of the IASP DB and metadata to the sample library tables in the browser interface of DB2 Web Query.

12.To do so you will first need to verify what is the IASP Database name defined in the Relational Database Directory of your system, using command

WRKRDBDIRE

332 DB2 Web Query for System i

Page 351: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ax02c.fm

whose output is shown in Figure 15-12. As you can notice, in this example the IASP DB name is set to IASP520DB, and this is the name we will have to reference when adding a new connection

Figure 15-12 WRKRDBDIRE Screen

13.Logon to the browser interface, select Your_Domain -> Reports. Right click on your_folder and select Metadata as shown in Figure 15-13.

Figure 15-13 DB2 Web Query Metadata

This choice will open up a second browser window, shown in Figure 15-14, where you will define a new database connection allowing IBM DB2 Web Query to connect to the IASP Database instance, beside the SYSBASE (*LOCAL) Database instance which already exists.

Appendix D. Setting up DB2 Web Query to run in an IASP environment 333

Page 352: DB2 Web Query for System i

7214ax02c.fm Draft Document for Review October 10, 2007 9:57 am

Figure 15-14 Configuring database instance window

14.To define the new connection right click on DB2 cli and select Add Connection.

The right hand pane will allow you to enter a connection name (whatever you like, the more representative the better) and the Database instance name.

15.In our example IASP520 will be used as the connection name and IASP520DB (as retrieved using the WRKRDBDIRE command) as the datasource name. Click Configure to confirm and add the connection as shown in Figure 15-15.

Figure 15-15 Connection Name and Datasource name

Now you can proceed to define a synonym to table CENTURY/ORDERS.

16.Right click on the newly defined connection, IASP520, and select Create synonym, as shown in Figure 15-16.

334 DB2 Web Query for System i

Page 353: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ax02c.fm

Figure 15-16 Creating Synonyms

Use Century, the sample data library, for your test, and add table Orders, as you would do for any other library and table stored on the system.

17.Create a report on Orders and test everything works as expected, save your report before logging off.

18.Logoff from the browser session.

19.Go back to the 5250 session, signon as QWEBQRYADM and end DB2 Web Query using command

QWEBQRY76/ENDWEBWRY

On the second system

In this section we are going to explain what is required to do on the second system. It is important that we propagate the user profile QWEBQRYADM from the first system, using iNav, to ensure it gets the same UID on both systems (having different UID can impact performance at IASP switch time).

1. On the first system select Users & Groups -> Users -> right click on QWEBQRYADM -> Send

On the panel that opens up add your second system in the list of selected systems, as shown in Figure 15-17:

Appendix D. Setting up DB2 Web Query to run in an IASP environment 335

Page 354: DB2 Web Query for System i

7214ax02c.fm Draft Document for Review October 10, 2007 9:57 am

Figure 15-17 Propagating users to a second system

Now we are going to check that the two QWEBQRYADM user profiles have the same UID on both systems using iNAV.

2. On both systems select Users & Groups -> Users -> right click on QWEBQRYADM -> Properties -> Capabilities, Unique Identifier:

336 DB2 Web Query for System i

Page 355: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214ax02c.fm

Figure 15-18

3. Install the DB2 Web Query as explained in Chapter 2, “Installation and Server Operations” on page 17

4. Signon as QWEBQRYADM, start DB2 Web Query and use it to test it's working correctly

5. End DB2 Web Query

6. Rename directory /qibm/UserData/webquery to webqueryORI by running the following command:

REN OBJ('/qibm/UserData/webquery') NEWOBJ(webqueryORI)

7. Switch IASP to second system, using iNav

8. Allocate the IASP by typing the following command:

SETASPGRP ASPGRP(IASP520)

9. Create a symbolic link to directory /IASP520/webquery

ADDLNK OBJ('/IASP520/webquery') NEWLNK('/qibm/UserData/webquery') LNKTYPE (*SYMBOLIC)

10.Signon as QWEBQRYADM, SETASPGRP, start DB2 Web Query

11.Verify that you get the reports/graphs created on the first system and that they are working correctly.

Appendix D. Setting up DB2 Web Query to run in an IASP environment 337

Page 356: DB2 Web Query for System i

7214ax02c.fm Draft Document for Review October 10, 2007 9:57 am

338 DB2 Web Query for System i

Page 357: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214addm.fm

Appendix E. Additional material

This book refers to additional material that can be downloaded from the Internet as described below.

Locating the Web material

The Web material associated with this book is available in softcopy on the Internet from the IBM Redbooks Web server. Point your Web browser at:

ftp://www.redbooks.ibm.com/redbooks/SG247214

Alternatively, you can go to the IBM Redbooks Web site at:

ibm.com/redbooks

Select the Additional materials and open the directory that corresponds with the IBM Redbook form number, SG247214.

Using the Web material

The additional Web material that accompanies this book includes the following files:

File name DescriptionQWQCENT.zip iSeries Library

System requirements for downloading the Web material

The following list contains the most important requirements:

� i5/OS V5R4� 5733-QU2 - DB2 Web Query for System i

E

© Copyright IBM Corp. 2007. All rights reserved. 339

Page 358: DB2 Web Query for System i

7214addm.fm Draft Document for Review October 10, 2007 9:57 am

How to use the Web material

Create a subdirectory (folder) on your workstation, and unzip the contents of the Web material zip file into this folder and upload the i5/OS save file to your System i.

340 DB2 Web Query for System i

Page 359: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214bibl.fm

Related publications

The publications listed in this section are considered particularly suitable for a more detailed discussion of the topics covered in this book.

IBM Redbooks

For information about ordering these publications, see “How to get IBM Redbooks” on page 341. Note that some of the documents referenced here may be available in softcopy only.

� Preparing for and Tuning the SQL Query Engine on DB2 for i5/OS, SG24-6598-01

� SQL Performance Diagnosis on IBM DB2 Universal Database for iSeries, SG24-6654

� OnDemand SQL Performance Analysis Simplified on DB2 for i5/OS in V5R4, SG24-7326

Online resources

These Web sites are also relevant as further information sources:

� Information Builders Corporate Website

http://www.ibi.com/

� DB2 for i5/OS Portal

http://www.ibm.com/systems/i/software/db2

� DB2 Web Query website

http://www-03.ibm.com/systems/i/software/db2/webquery/

How to get IBM Redbooks

You can search for, view, or download Redbooks, IBM Redpapers, Technotes, draft publications and Additional materials, as well as order hardcopy Redbooks, at this Web site:

ibm.com/redbooks

Help from IBM

IBM Support and downloads

ibm.com/support

IBM Global Services

ibm.com/services

© Copyright IBM Corp. 2007. All rights reserved. 341

Page 360: DB2 Web Query for System i

7214bibl.fm Draft Document for Review October 10, 2007 9:57 am

342 DB2 Web Query for System i

Page 361: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214IX.fm

Index

Symbols* 4

Numerics3020 record 280

AActive Report Styling 151Active Reports 8, 149

Creating 151filtered chart 156Highlights 150

Adding parameters 198ADDRDBDIRE 47–48Administration Console 12administrator 25adopted authority 308AJAX 6Application Server 10–11auditing 313

BBasic synonyms 226basic user 25, 54Business Views 237

Ccalendar controls 219Change Report 32CHGUSRPRF 28child table 41Classic Query Engine 36, 277Classic Query Engine (CQE) 5Cluster 65COLHDG 308column headings 308Common Domain 29, 59Compound Parameterized report 198Conditional styling 77CREATE ALIAS 40Create Domain 32Create Report 32Create sub-folder 32Create Synonym 38, 45Creating filters 231creating metadata

considerations 39cross system join 47cross system joining 275

© Copyright IBM Corp. 2007. All rights reserved.

Ddashboard 310Dashboards 15Data Adapters 13

DB2 for i5/OS 7Query/400 7System i Heritage files 7

Data adapters 7Data Profiling 8, 241Database monitor 286date decomposition 8Date formatting 70Date Manipulation 230DB2 for i5/OS Adapter 13DB2 for i5/OS adapter. 36DB2 for LUW 47DB2 Web Query 5

attributes 11Base features 6Graph Assistant 6Power Painter 6Product Positioning 14Report Assistant 6server jobs 23

DB2 Web Query Servlet 11detail reports 67developer 25Developer Workbench 7, 13, 63, 163

profiling 163synonym editor 163

dicing 7Domain

create 30rename 31

domains 27, 29, 310Drill downs 15DSPFFD 34

EENDWEBQRY 22ERP systems 8, 295Excel 6exception joins 303eXtensible Markup Language 6Extract Transformation and Load 295

FFederated DB2 7Foreign key option 65foreign key relationships 273

GGraph Assistant 99

343

Page 362: DB2 Web Query for System i

7214IX.fm Draft Document for Review October 10, 2007 9:57 am

Bar chart 100Conditional styling 126date range parameter 120drill down 104dual axis bar 106graph properties 111line graph 113pie charts 122traffic lighting a graph 126

Group ProfileMDUNTITLED 58

HHTML Layout Painter 163, 197HTML Layout Painter tool 8HTML page options 208Hypertext Transfer Protocol 10

IIBM DB2 Web Query for System i 5IBM Query for System i 4Impact Analysis 239Impact analysis 8imported report 310Index Advisor 280Index Only Access 286Inner Join 96input parameters 304Integrated Development Environment 13Integrated File System (IFS) 11

JJoin optimization 268Joining Tables 232Joining tables 94

KKerberos 312Key Constraints 43Key performance indicators (KPI) 15

LLDAP 312Left Outer Join 96licensing 313line chart 106Line graphs

date range filter 117

MManaged Reporting Drivers 12Materialized Query Tables 273, 286Metadata 5metadata

aliases 39create 34

materialized query tables 39stored procedures 39tables 39views 39

multi-dimensional 7multi-member 13multi-member files 39

Nnamed user 307named user licenses 8

OOffline reporting 8OLAP 169

Dicing 179Dimension 170Dimension Builder 173Drill down 170Drill Down Options 177enabled report 178Enabling 176Getting Started 170Grouping Data 194Hierarchies 170Hierarchy 170Hyperlinks 170Measure 171metadata 171Modeling View 172Pivot 171Slicing 179Synonym menu 173Terminology 170

OLAP Control Panel 188On Line Analytical Processing 295On-Line Analytical Processing 169Online Analytical Processing (OLAP) 7Operational reports 15OPNQRYF 36OPNQRYF command 13Optimization hierarchy 267Other Files 29

Ppalettes 133Parameter passing 255parent tables, 41Portable Document Format 6portlets 312PostScript 6Power Painter

Building a graph 134Building a report 141Clustered Bar chart 135Data Sources palette 133PDF report. 146Properties palette 133

344 DB2 Web Query for System i

Page 363: DB2 Web Query for System i

Draft Document for Review October 10, 2007 9:57 am 7214IX.fm

Prefix 37primary key 41

QQRYDFN objects 253QSQSRVR 23QSYSWRK subsystem 23Query/400 4, 253Query/400 5722-QU1 5Query/400 Adapter 13Query/400 adapter 36, 277

RRational tools 312Redbooks Web site 341

Contact us xvreferential integrity 40, 44

Benefits 41Refresh synonyms 299Relational Database Management System 10Report Assistant

Date formatting 70DB2 file output 87Drill-down reports 91footings 78Generating subtotals 80MS Excel output 86On-demand paging 84Parameterized reports 89PDF output 85Ranking Columns 83Report properties 93Selection criteria 71Sorting 81

Report Caster 312Reporting Server 10Reporting server 12Reports 29RSTLICPGM 17Run Report 32

SScorecards 15Server jobs

EDAPGWY 23EDAPLOG 23EDAPTH 23HLISNK 23JSCOM3 23QP0ZSPWP 23TSCOM3 23WQLWI7 23

slicing 7Software Maintenance Agreement 296Sorting Optimization 271spreadsheet 305SQE Plan Cache 280SQL catalog views 61

SQL CREATE TABLE 60SQL Performance Monitor 280SQL Plan Cache snapshot 280SQL Query Engine (SQE) 5SQL trace 281SQL Views 272SQL Wizard 8, 163, 243statistics 279STRWEBQRY 22sub-folders

creating 31Suffix 37summary report 64Synonym Editor 225, 299Synonyms 5System i Heritage File adapter 13System i heritage file adapter 36

Ttrace statements 281Traffic lighting 77TRCWEBQRY 22

UUsers

Administrator 28Displaying 26Registering 26Removing 26

VVisual Explain 280

WWeb Application Bundle 12Web Server 10Web server 11WebFOCUS 199WebFocus ReportCaster 8WebFOCUS reports 8WRKLICINF 19WRKRDBDIRE 47

Index 345

Page 364: DB2 Web Query for System i

7214IX.fm Draft Document for Review October 10, 2007 9:57 am

346 DB2 Web Query for System i

Page 365: DB2 Web Query for System i

To determine the spine w

idth of a book, you divide the paper PP

I into the number of pages in the book. A

n example is a 250 page book using P

lainfield opaque 50# smooth w

hich has a PP

I of 526. Divided

250 by 526 which equals a spine w

idth of .4752". In this case, you would use the .5” spine. N

ow select the S

pine width for the book and hide the others: S

pecial>C

on

ditio

nal

Text>Sh

ow/H

ide>S

pin

eSize(-->H

ide:)>S

et . Move the changed C

onditional text settings to all files in your book by opening the book file with the spine.fm

still open and File>Im

po

rt>Fo

rmats the

Conditional Text S

ettings (ON

LY!) to the book files.

Draft D

ocument for R

eview O

ctober 10, 2007 9:57 am7214sp

ine.fm

347

(0.1”spine)0.1”<

->0.169”

53<->

89 pages

(0.2”spine)0.17”<

->0.473”

90<->

249 pages

(1.5” spine)1.5”<

-> 1.998”

789 <->

1051 pages

(1.0” spine)0.875”<

->1.498”

460 <->

788 pages

(0.5” spine)0.475”<

->0.873”

250 <->

459 pages

DB2 Web Query for System

i

DB2 Web Query for System

i

DB2 Web Query for System

i

DB2 Web Query for System

i

Page 366: DB2 Web Query for System i

(2.0” spine)2.0” <

-> 2.498”

1052 <->

1314 pages

(2.5” spine) 2.5”<

->nnn.n”

1315<->

nnnn pages

To determine the spine w

idth of a book, you divide the paper PP

I into the number of pages in the book. A

n example is a 250 page book using P

lainfield opaque 50# smooth w

hich has a PP

I of 526. Divided

250 by 526 which equals a spine w

idth of .4752". In this case, you would use the .5” spine. N

ow select the S

pine width for the book and hide the others: S

pecial>C

on

ditio

nal

Text>Sh

ow/H

ide>S

pin

eSize(-->H

ide:)>S

et . Move the changed C

onditional text settings to all files in your book by opening the book file with the spine.fm

still open and File>Im

po

rt>Fo

rmats the

Conditional Text S

ettings (ON

LY!) to the book files.

Draft D

ocument for R

eview O

ctober 10, 2007 9:57 am7214sp

ine.fm

348

DB2 Web Query for System

i

DB2 Web Query for System

i

Page 367: DB2 Web Query for System i
Page 368: DB2 Web Query for System i

®

SG24-7214-00 ISBN

Draft Document for Review October 10, 2007 9:57 am

INTERNATIONAL TECHNICALSUPPORTORGANIZATION

BUILDING TECHNICAL INFORMATION BASED ON PRACTICAL EXPERIENCE

IBM Redbooks are developed by the IBM International Technical Support Organization. Experts from IBM, Customers and Partners from around the world create timely technical information based on realistic scenarios. Specific recommendations are provided to help you implement IT solutions more effectively in your environment.

For more information:ibm.com/redbooks

DB2 Web Queryfor System i

Learn DB2 Web Query by using the easy to follow tutorials

Follow the installation and best practices guides

Take your Query/400 reports to the next level

DB2® Web Query for System i™ is a Web-based query and report writing product that offers enhanced capabilities over the IBM® Query for iSeries™ (also commonly known as Query/400) product. IBM DB2 Web Query for System i will include the Query for iSeries technology to assist customers in their transition to DB2 Web Query, while offering a more modernized, Java™ based solution for a more robust, extensible, and productive reporting solution. DB2 Web Query will provide reporting and graphing assistants and a WYSIWYG report "painter." Customers will be able to modernize existing Query for iSeries reports while providing a foundation for building more complex business intelligence applications such as OLAP, data mining, dash boarding, or data warehouse implementations.

This IBM Redbook gives a broad understanding of this new product and it is explained with a group of self explanatory tutorials that will help you get up to speed quickly.

Back cover