IBM I DB2 Web Query For I Version 2.1 Implementation Guide

Download as pdf or txt
Download as pdf or txt
You are on page 1of 880

Front cover

Draft Document for Review August 30, 2013 2:38 pm

SG24-8063-00

IBM DB2 Web Query for i


Version 2.1
Implementation Guide
Follow the best practice guides to
simplify report development
Take your reporting to the next
level of Business Intelligence
Learn DB2 Web Query by using
the easy-to-follow tutorials

Robert Andrews
Theo Br
Gene Cobb
Rick Flagler
Kei Fujii
Hector Gongora
Doug Mack
Simona Pacchiarini
Septia Sukariningrum
Yu Yu Wang

ibm.com/redbooks

Draft Document for Review August 30, 2013 2:37 pm

8063edno.fm

International Technical Support Organization


DB2 Web Query for i Implementation Guide
January 2013

SG24-8063-00

8063edno.fm

Draft Document for Review August 30, 2013 2:37 pm

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

First Edition (DB2 Web Query for i Implementation Guide)


This edition applies to IBM i 7.1 (product number 5770-SS1).
This document was created or updated on August 30, 2013.

Copyright International Business Machines Corporation 2012. All rights reserved.


Note to U.S. Government Users Restricted Rights -- Use, duplication or disclosure restricted by GSA ADP Schedule
Contract with IBM Corp.

Draft Document for Review August 30, 2013 2:37 pm

8063TOC.fm

Contents
Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
The team who wrote this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Now you can become a published author, too! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Comments welcome. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Stay connected to IBM Redbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii
Part 1. Background, installation, and setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 1. Product overview and architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1 Product background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.1 Take Advantage of DB2 for i Analytics Processing Power . . . . . . . . . . . . . . . . . . . 5
1.1.2 Optimize the Analytics with a Dedicated, Optimized Server Environment . . . . . . . 6
1.2 Product structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4.1 Web browser clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.4.2 Web server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.4.3 Application server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.4.4 Reporting Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.4.5 Data adapters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.5 Request for changes on Web Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Chapter 2. Installation and server operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1 Installation and setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.1 Installing DB2 Web Query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.2 Authorizing and verifying users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.3 License keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.4 Dynamic Language Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.5 Sample database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.1 PC requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.2 IBM i requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.3 Developer Workbench requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3 Web Query administrative commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.4 DB2 Web Query server jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5 Running QU2 and WQX concurrently . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

13
14
14
15
15
16
16
16
16
16
16
17
18
19

Chapter 3. Defining metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


3.1 What is metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1.1 Benefits of metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2 Creating metadata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.1 Creating metadata with the web interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.2 Creating metadata with Developer Workbench. . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.3 Creating metadata with CL command CRTWQSYN. . . . . . . . . . . . . . . . . . . . . . .
3.3 Deleting Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3.1 Delete metadata via the web interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

21
22
24
25
26
30
34
35
36

Copyright IBM Corp. 2012. All rights reserved.

iii

8063TOC.fm

Draft Document for Review August 30, 2013 2:37 pm

3.3.2 Delete metadata via the Developer Workbench tool. . . . . . . . . . . . . . . . . . . . . . . 37


3.3.3 Deleting files in the IFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.4 Refreshing metadata (when IBM i database object structure changes) . . . . . . . . . . . . 39
3.4.1 Refreshing metadata via the browser interface. . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.4.2 Refreshing metadata with Developer Workbench. . . . . . . . . . . . . . . . . . . . . . . . . 41
3.4.3 Refreshing metadata with command CRTWQSYN. . . . . . . . . . . . . . . . . . . . . . . . 42
3.4.4 What happens to the metadata if the IBM i database object is deleted . . . . . . . . 44
3.5 Miscellaneous considerations about creating metadata . . . . . . . . . . . . . . . . . . . . . . . . 45
3.5.1 Stored procedure synonyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.5.2 Considerations with multimember files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.6 Joining database objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.6.1 Referential integrity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.6.2 Creating metadata on tables with referential integrity . . . . . . . . . . . . . . . . . . . . . . 56
3.6.3 Creating metadata over tables without referential integrity . . . . . . . . . . . . . . . . . . 57
3.6.4 Defining joins in SQL views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.6.5 Defining joins in DB2 Web Query synonyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.7 Date decomposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
3.7.1 Date decomposition with web interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
3.7.2 Date decomposition using Developer Workbench . . . . . . . . . . . . . . . . . . . . . . . . 81
3.8 Understanding your data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.9 Field formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
3.9.1 Field formatting with the web interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
3.9.2 Field formatting with Developer Workbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
3.10 New fields - Define vs Compute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
3.10.1 Define field - web interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
3.10.2 Define field - Developer Workbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
3.10.3 Compute field - web interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
3.10.4 Compute field - Developer Workbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
3.11 Creating filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
3.11.1 Creating filters with the web interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
3.11.2 Creating filters with Developer Workbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
3.12 Defining dimensions - InfoMini & OLAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
3.13 Segmenting and securing Metadata - DBA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
3.13.1 Field level security, No Print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
3.13.2 Row level security, Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
3.14 Business Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Chapter 4. Security Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.1 Security Architecture and Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.1.1 Security Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.1.2 Security Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 System i Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.3 Groups and their capabilities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4 Top Level folders and Subfolders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4.1 Top Level folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4.2 Subfolders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4.3 Controlling accessiblity to subfolders and reporting objects . . . . . . . . . . . . . . . .
4.4.4 Controlling order of elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

147
148
148
148
149
149
150
150
152
152
157

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


Chapter 5. Getting started with the tutorials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
5.1 The Century Challenge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
5.2 The Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
iv

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063TOC.fm

5.3 The QWQCENT Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164


5.3.1 Restoring QWQCENT on your system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
5.3.2 Downloading completed tutorials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Chapter 6. Security Center - Setting up users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.1 How to open the Security Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2 Registering user profiles to DB2 Web Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3 How to designate a Web Query Administrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.4 Remove a user from a Web Query group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.5 Adding a developer to a Top Level Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.6 Give Run-Only authority to existing IBM i group profile. . . . . . . . . . . . . . . . . . . . . . . .
6.7 How to manage users and their attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.8 Change the owner of a report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.9 Preparing steps for the tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

169
170
171
173
175
177
179
185
186
189

Chapter 7. Creating and editing metadata - Century Database . . . . . . . . . . . . . . . . .


7.1 Creating metadata using the metadata creation wizard . . . . . . . . . . . . . . . . . . . . . . .
7.2 Enhancing metadata - join . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.3 Date decomposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

191
192
195
201

Chapter 8. Assignment #1: Summary Reports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


8.1 Revenue Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.1 Create Revenue Summary Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.2 Add Gross Profit Define Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.3 Add Header and Footer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.4 Change Theme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.5 Add Traffic Lighting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.6 Publish the report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.2 Top 10 (Ten) Products by Margin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.2.1 Open and save a new copy of the report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.2.2 Add By Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.2.3 Create Define and Compute Field. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.2.4 Add Rank to Profit Margin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.2.5 Add Data Visualization Bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.3 Revenue Summary with Subtotals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.4 Simple Revenue Report Group by Year . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.5 Creating Define and Compute fields in the Synonym . . . . . . . . . . . . . . . . . . . . . . . . .
8.5.1 Create Profit Field Using Define Field. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.5.2 Create Margin Field Using Compute Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

205
206
206
211
216
218
219
223
224
225
225
226
229
231
232
238
241
241
245

Chapter 9. Assignment # 2: Implementing Various Date Functions in Reports . . . .


9.1 Dates Using DB2 Web Query Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.1.1 Change Report Theme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.1.2 Using Aggregation Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.1.3 Add Month Name as Define Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.2 Dates Using SQL Prefix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.3 Dates Using Date Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

247
248
248
252
255
258
261

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats . .


10.1 Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.2 Accordion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.3 Pages on Demand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.4 Stack Measures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.5 PDF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

269
270
276
278
279
283

Contents

8063TOC.fm

vi

Draft Document for Review August 30, 2013 2:37 pm

10.6 Excel Formula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


10.7 Active Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.7.1 Sorting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.7.2 Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.7.3 Charting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.7.4 Calculate: % of Total . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.7.5 Rollup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.7.6 Rollup Result Converted to Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.7.7 Chart Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.7.8 Export Chart to Excel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.7.9 Pivot Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.7.10 Add Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.7.11 Note for Active Report. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.8 Active Flash. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

285
287
294
296
297
298
299
300
301
303
305
307
309
309

Chapter 11. Assignment # 4: Charting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


11.1 The Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.2 Pie chart: Revenue & Gross Profit by Product Type . . . . . . . . . . . . . . . . . . . . . . . . .
11.3 Bar chart: OTD by Product Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.4 Vertical Stacked Area: Orders Backlog by Period. . . . . . . . . . . . . . . . . . . . . . . . . . .
11.5 Gauge chart: OTD overall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

311
312
312
316
324
331

Chapter 12. Assignment #5: Adding filters to reports and charts . . . . . . . . . . . . . . .


12.1 Simple filters - Revenue Simple Filter report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12.2 Advanced Filters - Revenue Advanced Filter report . . . . . . . . . . . . . . . . . . . . . . . . .
12.3 Filter in chart: : revenue trend graph with a variable date range . . . . . . . . . . . . . . . .
12.3.1 Creating a line graph. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12.3.2 Adding a user-specified date range parameter . . . . . . . . . . . . . . . . . . . . . . . . .
12.4 Filter in metadata - Europe Revenue and Profit report . . . . . . . . . . . . . . . . . . . . . . .
12.4.1 Define filter in synonym. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12.4.2 Using predefined filters in a report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12.5 InfoMini - Slicers - InfoMini Rev & Cost report . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12.5.1 Defining dimensions in synonym. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12.5.2 InfoMini Slicers report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12.6 Info Mini - Formats - InfoMini Rev & Cost Format report. . . . . . . . . . . . . . . . . . . . . .
12.7 Publish your folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

341
342
352
358
358
363
366
366
371
374
374
381
390
392

Chapter 13. Assignment #6 : Detail/print reports. . . . . . . . . . . . . . . . . . . . . . . . . . . . .


13.1 A graphical structure of the application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.2 Creating the basic Summary report with InfoAssist
(6a - Basic Summary Report) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.2.1 Create an Initial Summary Report. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.3 Creating a summary report with parameter
(6b - Summary Report Product Category) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.4 Creating a detail report with parameter
(6c - Detail Report Product Number) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.5 Converting a report to a chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.6 Creating a chart
(6d - Chart Good Profit) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.7 Creating drill downs and putting it all together . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.7.1 Conditional drill downs from the Basic report . . . . . . . . . . . . . . . . . . . . . . . . . .
13.7.2 Non-conditional drill down from the second to the third report . . . . . . . . . . . . .
13.7.3 Publish the reports/chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

393
394

IBM i DB2 Web Query for i Implementation Guide

394
394
396
398
402
404
411
411
416
419

Draft Document for Review August 30, 2013 2:37 pm

8063TOC.fm

Chapter 14. Assignment #7: Implementing OLAP . . . . . . . . . . . . . . . . . . . . . . . . . . . .


14.1 Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14.2 OLAP terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14.3 Tuning on OLAP option in InfoAssist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14.3.1 Creating an Initial Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14.3.2 To enable an OLAP report (How to Use Auto Drill & Analysis). . . . . . . . . . . . .
14.4 Working with an OLAP enabled report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14.4.1 Slicing, dicing, and drilling down for more details . . . . . . . . . . . . . . . . . . . . . . .
14.4.2 Manipulating the data using the OLAP Control Panel. . . . . . . . . . . . . . . . . . . .

423
424
425
426
426
429
432
433
445

Chapter 15. Assignment # 8: Building Documents/Dashboards . . . . . . . . . . . . . . . .


15.1 Documents and Dashboards. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.1.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.1.2 What is a Dashboard? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.1.3 Developing KPIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.1.4 Business leader requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.1.5 Creating a dashboard document with InfoAssist. . . . . . . . . . . . . . . . . . . . . . . .
15.1.6 Viewing business data on popular devices . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.2 Creating a document, adding an internally defined chart . . . . . . . . . . . . . . . . . . . . .
15.2.1 Starting a new document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.2.2 Adding a chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.2.3 Manipulating fields for the chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.2.4 Making layout changes to improve the look of the chart . . . . . . . . . . . . . . . . . .
15.3 Adding existing reports and charts to a document . . . . . . . . . . . . . . . . . . . . . . . . . .
15.3.1 Opening the existing document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.3.2 Inserting an existing report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.3.3 Inserting more charts or reports into an existing document . . . . . . . . . . . . . . .

455
456
456
456
456
456
457
457
458
458
459
460
462
466
466
466
471

Chapter 16. Assignment #9: Exploring/comparing other dashboard options. . . . . .


16.1 Additional features of Web Query for documents . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.1.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.2 What is a coordinated document?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.3 Creating documents with Form Control fields. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.4 Self-service Dashboards using the BI Portal. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.4.1 Favorites and Mobile Favorites. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.4.2 Creating a Personal BI Portal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.5 DB2 Web Query Developer Workbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.5.1 Why would you use developer workbench? . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.6 Dashboard using HTML composer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.6.1 Comparison between InfoAssist and HTML Composer . . . . . . . . . . . . . . . . . .
16.6.2 Compound parameterized report (HTML1_KPI) . . . . . . . . . . . . . . . . . . . . . . . .
16.6.3 Preparing the charts for the HTML composer . . . . . . . . . . . . . . . . . . . . . . . . . .
16.6.4 Adding controls to the HTML Composer canvas. . . . . . . . . . . . . . . . . . . . . . . .
16.6.5 Referencing external Procedures in the HTML composer . . . . . . . . . . . . . . . .
16.7 DB2 Web Query Spreadsheet client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.7.1 Creating a Dashboard in Excel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

477
478
478
478
482
488
488
490
494
495
495
496
496
497
501
506
512
513

Chapter 17. Assignment #10: Scheduling and Distribution of reports . . . . . . . . . . .


17.1 Report Broker Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17.2 The Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17.3 Configuring Report Broker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17.4 Schedule a simple report and distribute via Email . . . . . . . . . . . . . . . . . . . . . . . . . .
17.5 Schedule a report with parameters and distribute via Email . . . . . . . . . . . . . . . . . . .
17.5.1 Create an Email Distribution List. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

541
542
542
542
545
553
553

Contents

vii

8063TOC.fm

viii

Draft Document for Review August 30, 2013 2:37 pm

17.5.2 Schedule the report. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


17.6 Schedule a report and distribute via DB2 Web Query . . . . . . . . . . . . . . . . . . . . . . .
17.7 Schedule a report and distribute via FTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17.8 Schedule a report and distribute via Printer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17.9 RUNBRSCHED command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17.10 Report Broker Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

556
561
566
576
577
581

Chapter 18. Assignment #11: Going mobile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


18.1 Mobile Access Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18.2 Preparing Reports for Mobile Access.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18.3 Accessing Mobile Content using the Web Browser . . . . . . . . . . . . . . . . . . . . . . . . .
18.4 Using Mobile Faves. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18.4.1 Installing Mobile Faves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18.4.2 Connecting to Reporting Server and running reports . . . . . . . . . . . . . . . . . . . .
18.4.3 Adding Aditional Reports to Mobile Favorites. . . . . . . . . . . . . . . . . . . . . . . . . .
18.4.4 Saving Reports for Offline View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18.5 Openning Reports Recevied via E-Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18.6 How to use Active Technologies on Mobile Devices. . . . . . . . . . . . . . . . . . . . . . . . .

583
584
584
586
588
588
589
590
594
596
598

Chapter 19. Assignment #14: Stored procedures in action . . . . . . . . . . . . . . . . . . . .


19.1 Getting the most from your data with Stored Procedures. . . . . . . . . . . . . . . . . . . . .
19.1.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19.2 Creating a stored procedure synonym . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19.2.1 Reasons you might use a stored procedure . . . . . . . . . . . . . . . . . . . . . . . . . . .
19.3 Example of an HR-related stored procedure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19.3.1 Creating the synonym for the stored procedure example . . . . . . . . . . . . . . . . .
19.4 Creating a report using the stored procedure synonym . . . . . . . . . . . . . . . . . . . . . .
19.4.1 Starting Info Assist to create the report. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19.4.2 Establishing the join between Plant table and stored procedure. . . . . . . . . . . .
19.4.3 Formatting the report. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19.4.4 Saving your report based on a stored procedure.. . . . . . . . . . . . . . . . . . . . . . .
19.5 An example of a Input parameter stored procedure in RPG . . . . . . . . . . . . . . . . . . .
19.5.1 Creating the synonym for the MULTINPARM stored procedure . . . . . . . . . . . .
19.5.2 Creating the report from the MULTINPARM stored procedure synonym . . . . .
19.5.3 Using Info Assist to create the report. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19.5.4 Formatting the report. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

605
606
606
606
606
607
608
611
612
614
616
621
622
624
624
624
626

Chapter 20. Assignment #14: Query/400 Modernization . . . . . . . . . . . . . . . . . . . . . . .


20.1 Query/400: a reliable reporting tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.2 DB2 Web Query versus Query/400: function similarities . . . . . . . . . . . . . . . . . . . . .
20.3 DB2 Web Query versus Query/400: function differences . . . . . . . . . . . . . . . . . . . . .
20.3.1 Parameter passing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.3.2 Using output files for the next query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.4 The Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.5 Creating metadata over Query/400 objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.6 Using DB2 Web Query to edit a QRYDFN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.7 Modernizing Query/400 definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.7.1 Building the initial report.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.8 The Migration dilemma for Query/400 reporting . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.9 Modernizing your reporting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.9.1 IBM offering for Query Modernization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.10 Replacing Query/400 objects with Active reports . . . . . . . . . . . . . . . . . . . . . . . . . .
20.10.1 Highly parameterized report development . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.10.2 Creating the report in HTML Composer . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

631
632
632
632
632
633
634
634
639
640
641
647
647
647
647
648
653

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063TOC.fm

20.10.3 Parameter controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


20.10.4 Chaining the controls together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.10.5 Using calendar controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.10.6 Providing multiple report output format options for users . . . . . . . . . . . . . . . .
20.11 Additional parameter tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.11.1 Displaying the values of one column while passing another. . . . . . . . . . . . . .
20.11.2 Using another report to control parameter sorting and filtering. . . . . . . . . . . .

658
661
662
669
672
672
679

Chapter 21. Assignment 15: Creating JD Edwards reports . . . . . . . . . . . . . . . . . . . .


21.1 Connecting to a Remote JD Edwards Database Using Adapters for JD Edwards . .
21.1.1 Areas to Consider When Connecting to a Remote JD Edwards Database . . .
21.1.2 Using JD Edwards Adapter to Connect to a Remote JD Edwards Database . .
21.1.3 JD Edwards Dictionary Files Needed on Local System to Access Remote JD
Edwards Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.2 Using the Adapter for JD Edwards World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.2.1 Preparing the JD Edwards World Environment. . . . . . . . . . . . . . . . . . . . . . . . .
21.2.2 Overview of the Set Up Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.2.3 Configuring the Adapter for JD Edwards World . . . . . . . . . . . . . . . . . . . . . . . .
21.2.4 Refreshing the Metadata Repository. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.2.5 Creating the JD Edwards World Synonyms . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3 Using the Adapter for JD Edwards EnterpriseOne . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.1 Preparing the JD Edwards EnterpriseOne Environment. . . . . . . . . . . . . . . . . .
21.3.2 Overview of the Setup Process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.3 Configuring the Adapter for JD Edwards EnterpriseOne . . . . . . . . . . . . . . . . .
21.3.4 Refreshing the Metadata Repository. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.5 Refreshing the Security Extract. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.6 Creating the JD Edwards EnterpriseOne Synonyms . . . . . . . . . . . . . . . . . . . .
21.4 Developing a JD Edwards Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

685
686
686
686
686
687
687
687
688
691
692
693
693
693
693
696
697
698
699

Chapter 22. The Century BI Solution Challenge: Postmortem . . . . . . . . . . . . . . . . . . 711


22.1 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712
Part 3. Miscellaneous topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
Chapter 23. Performance Case study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.1 Performance basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2 DB2 CLI adapter performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.1 Report request process flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2 Adapter processing and optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.3 Remote database access considerations (including cross-system joining) . . .
23.3 Query/400 adapter performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.4 DB2 for i optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.4.1 Database design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.4.2 Query Engine used . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.4.3 Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.4.4 Available hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.4.5 Concurrent users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.5 Performance case study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.5.1 Identifying a long-running report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.5.2 Performing analysis and looking for optimization disablers . . . . . . . . . . . . . . .
23.5.3 Determining report-tuning options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.5.4 Creating an SQL view and synonym. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.5.5 Creating a new report based on the SQL view . . . . . . . . . . . . . . . . . . . . . . . . .
23.5.6 Performing additional database analysis and tuning. . . . . . . . . . . . . . . . . . . . .

715
716
716
716
718
727
729
730
730
731
740
741
745
745
745
746
747
747
749
751

Contents

ix

8063TOC.fm

Draft Document for Review August 30, 2013 2:37 pm

23.6 Performance benchmark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


23.6.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.6.2 Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.6.3 Database and system configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.6.4 Matrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.6.5 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

753
753
753
754
754
757

Chapter 24. Migration Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


24.1 New concepts and terms in Web Query 2.1.0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
24.1.1 Business Intelligence Portal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
24.1.2 New Web Query Administration User ID. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
24.1.3 Web Query Folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
24.2 Migrating from Release 1.1.x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
24.2.1 Migrating Web Query Users, Group Profile License Information and Metadata
24.2.2 Migrating Web Query Content. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
24.3 Other Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

759
760
760
760
760
763
763
764
764

Chapter 25. IBM i Business Intelligence Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . .


25.1 Operational Data Stores, Data Marts, and Data Warehouses . . . . . . . . . . . . . . . . .
25.2 Introducing the new IBM i for Business Intelligence Solution . . . . . . . . . . . . . . . . . .
25.2.1 DB2 Web Query for i Standard Edition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

767
768
768
768

Chapter 26. Adapter for Microsoft SQL Server. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


26.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
26.2 Establishing a connection to your MS SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . .
26.3 Creating Metadata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
26.4 Additional SQL Server Adapter information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

771
772
772
775
778

Part 4. Appendixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 779


Appendix A. Date and time functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Date and time system variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Date format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Date format display options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Controlling the date separator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using date fields. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Date fields in arithmetic expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Converting date fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Changing the usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using DB2 Web Query functions to convert to dates . . . . . . . . . . . . . . . . . . . . . . . . . .
Using date conversion table to convert to dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using SQL Views and functions to convert to dates . . . . . . . . . . . . . . . . . . . . . . . . . . .
Comparing the date conversion techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Converting date fields in Oracles JD Edwards World application . . . . . . . . . . . . . . . .
Converting other common legacy date formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DB2 Web Query date built-in functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DPART: Extracting a date component from a date field . . . . . . . . . . . . . . . . . . . . . . . .
DATEADD: adding or subtracting a date unit to or from a date . . . . . . . . . . . . . . . . . .
DATEDIF: calculating the difference between two dates . . . . . . . . . . . . . . . . . . . . . . .
DATEMOV: moving the date to a significant point . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Example: Dynamic Date Range report. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

781
782
782
783
784
785
785
785
786
789
794
811
814
815
818
821
821
821
823
824
825

Appendix B. DB2 Web Query System Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831


Appendix C. Change management considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . 833
x

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063TOC.fm

Change Management overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


Change Management Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Exporting Change Management Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Importing Change Management Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

834
834
835
839

Appendix D. Configuring Developer Workbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 843


Configuring Developer Workbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 844
Setting Developer Workbench default options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 850

Contents

xi

8063TOC.fm

xii

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063spec.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 grant 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 websites are provided for convenience only and do not in any
manner serve as an endorsement of those websites. The materials at those websites are not part of the
materials for this IBM product and use of those websites 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.
Any performance data contained herein was determined in a controlled environment. Therefore, the results
obtained in other operating environments may vary significantly. Some measurements may have been made
on development-level systems and there is no guarantee that these measurements will be the same on
generally available systems. Furthermore, some measurements may have been estimated through
extrapolation. Actual results may vary. Users of this document should verify the applicable data for their
specific environment.
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. 2012. All rights reserved.

xiii

8063spec.fm

Draft Document for Review August 30, 2013 2:37 pm

Disclaimer: The company, Century Electronics, used in this publication was chosen as a
fictitious name. It is used for instructional purposes only. This name is part of the toolkit
supplied by Information Builders and was selected to assist readers wanting to explore
DB2 Web Query for IBM i powered by Information Builders .

xiv

IBM i DB2 Web Query for i Implementation Guide

8063spec.fm

Draft Document for Review August 30, 2013 2:37 pm

Trademarks
IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of International Business Machines
Corporation in the United States, other countries, or both. These and other IBM trademarked terms are
marked on their first occurrence in this information with the appropriate symbol ( or ), indicating US
registered or common law trademarks owned by IBM at the time this information was published. Such
trademarks may also be registered or common law trademarks in other countries. A current list of IBM
trademarks is available on the Web at http://www.ibm.com/legal/copytrade.shtml
The following terms are trademarks of the International Business Machines Corporation in the United States,
other countries, or both:
AIX
AS/400
DB2
developerWorks
i5/OS
IA

IBM
iSeries
OmniFind
Power Systems
POWER7
PowerVM

Redbooks
Redbooks (logo)
System i5
System i
WebSphere

The following terms are trademarks of other companies:


Adobe, the Adobe logo, and the PostScript logo are either registered trademarks or trademarks of Adobe
Systems Incorporated in the United States, and/or other countries.
Intel, Intel logo, Intel Inside logo, and Intel Centrino logo are trademarks or registered trademarks of Intel
Corporation or its subsidiaries in the United States and other countries.
Linux is a trademark of Linus Torvalds in the United States, other countries, or both.
Microsoft, Windows, and the Windows logo are trademarks of Microsoft Corporation in the United States,
other countries, or both.
Java, and all Java-based trademarks and logos are trademarks or registered trademarks of Oracle and/or its
affiliates.
UNIX is a registered trademark of The Open Group in the United States and other countries.
Other company, product, or service names may be trademarks or service marks of others.

Notices

xv

8063spec.fm

xvi

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063pref.fm

Preface
Business Intelligence (BI) is a broad term relating to applications designed to analyze data for
purposes of understanding and acting on the key metrics that drive profitability in an
enterprise. Key to analyzing that data is providing fast, easy access to it while delivering it in
formats or tools that best fit the needs of the end user.
At the core of any business intelligence solution are end user query and reporting tools that
provide intuitive access to data supporting a spectrum of end users from executives to power
users, from spreadsheet aficionados to the external Internet consumer.
IBM DB2 Web Query for i offers a set of modernized tools for a more robust, extensible
and productive reporting solution than the popular Query for System i (also known as
Query/400) tool. DB2 Web Query for i preserves investments in the reports developed with
Query/400 by offering a choice of importing definitions into the new technology or continuing
to run existing Query/400 reports as is. But it also offer significant productivity and
performance enhancements by leveraging the latest in DB2 for i query optimization
technology.
The DB2 Web Query for i product is a Web-based query and report writing product that offers
enhanced capabilities over the IBM Query for iSeries product (also commonly known as
Query/400). IBM DB2 Web Query for i includes Query for iSeries technology to assist
customers in their transition to DB2 Web Query. It offers a more modernized, Java-based
solution for a more robust, extensible, and productive reporting solution.
DB2 Web Query provides the ability to query or build reports against data stored in DB2 for i
(or Microsoft SQL Server) databases through browser-based user interface technologies.
Build new reports with ease through the web based, ribbon-like InfoAssist tool that leverages
a common look and feel that can extend the number of personnel that can generate their own
reports.
Simplify the management of reports by significantly reducing the number of report definitions
required through the use of parameter driven reports. Deliver data to end users in many
different formats, including directly into spreadsheets, or in boardroom-quality PDF format, or
viewed from the browser in HTML. Leverage advanced reporting functions such as matrix
reporting, ranking, color coding, drill-down and font customization to enhance the
visualization of DB2 data.
DB2 Web Query offers features to import Query/400 definitions and enhance their look and
functionality. It enables you to add OLAP-like slicing and dicing to the reports or to view
reports in disconnected mode for users on the go.
This IBM Redbooks publication provides a broad understanding of the new DB2 Web Query
product. It entails a group of self-explanatory tutorials to help you get up to speed quickly.
Overall, this book is designed for IT users. You can use Part 2, Tutorials for DB2 Web Query
on page 159, as stand-alone tutorials for anyone who is developing their own queries.

The team who wrote this book


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

Copyright IBM Corp. 2012. All rights reserved.

xvii

8063pref.fm

Draft Document for Review August 30, 2013 2:37 pm

Robert Andrews is an Advisory Software Engineer working for


the STG Lab Services team in the DB2 for i Center of
Excellence. He was the technical head for support for the DB2
Web Query product and currently provides custom consulting
services helping clients make the most of DB2 Web Query and
DB2 for i. Since joining IBM in 2001, Robert has co-authored
many IBM Redbooks publications and his work has been
published in trade publications with a focus on SQL, journaling,
and communications. Robert can be reached at
[email protected].
Theo Br is an IBM Business Partner and Consultant. He
teaches classes to IBM i clients. He has been consulting and
writing extensively on DB2 Web Query for i. He is the author of
a German book on DB2 Web Query. He is the author of
multiple articles for the German Midrange Magazin. He used
to work for IBM Germany as an Systems Engineer from 1977
to 1982. He can be contacted at [email protected].
He is a specialist in IBM i, SQL, RPG, EGL, Profound Logic
(PUI).
Theo holds a diploma in economical engineering and
mathematics from the universities of Karlsruhe and Heidelberg.
Gene Cobb is a DB2 for i Technology Specialist in the IBM
Systems Software DB2 for i Development team. He joined IBM
in 1988 and spent over 10 years as an application consultant in
the IBM STG Lab Services group, formerly the Client
Technology Center (CTC) in Rochester, Minnesota. His current
responsibilities include the promotion, education, enablement,
and technical support of IBM DB2 Web Query, the strategic
query and reporting solution for the IBM i platform. He speaks
and writes regularly about DB2 for i and DB2 Web Query topics
and is a co-author of the IBM Redbooks publication Getting
Started with DB2 Web Query for IBM i. He can be reached at
[email protected].

xviii

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063pref.fm

Rick Flagler is an Information Technology Consultant and


Adjunct Professor at Keene State College in Keene NH. He has
been working on IBMi and predecessors for 30+ years. He held
senior IT positions with The Timken Company and MPB
Corporation, leading teams of developers and business
analysts, installing ERP systems from major vendors such as
SAP and Oracle/JD Edwards. His experience includes project
management, database and user interface development. He
specializes in transforming data to knowledge and developing
business metrics using DB2, SQL, IBMi, DB2 Web Query,
Profound Logic (UI), ROBOT, SEQUEL, Microsoft Access and
Office.
Rick launched a grant-funded program to teach midrange
development at Keene State College, a division of the
University System of New Hampshire, where he's been an
Adjunct Professor of Computer Science for 10 years. He
lectures on database, user interface and programming topics
related to IBMi. He has held developer positions in the
Insurance and Manufacturing industrys as well as doing
system integration and consulting. Rick holds a B.S. in
Business Administration with emphasis on Computer Science
from Nichols College. Rick can be contacted at
[email protected].
Kei Fujii is an Advisory IT Specialist for IBM i and working in
the Systems Technical Sales division in IBM Japan. He has
seven years of experience with IBM i systems in pre-sales and
post sales support activities for clients as a technical expert.
His areas of expertise are IBM DB2 Web Query for i, Business
Intelligence, Hardware Configuration and Capacity Planning.
Kei has recently joined Power Systems Technical Sales is
responsible for ATS and FTSS.
Hector Gongora is a System I and Database Administrator at
Banco LAFISE in Nicaragua. His current responsibilities
includes database performance and administration as well as
System I high availability administration. Before joining Banco
LAFISE he worked for an IBM business partner as a System i
technical support Engineer. Hector can be reached at
[email protected].

Doug Mack is a DB2 for i and Business Intelligence Consultant


in IBMs Power Systems Lab Services organization. Doug's
thirty plus year career with IBM spans many roles, including
product development, technical sales support, Business
Intelligence Sales Specialist and DB2 for i Product Marketing
Manager.
Doug is a featured speaker at User Group conferences and
meetings, IBM Technical Conferences and Executive Briefings.

Preface

xix

8063pref.fm

Draft Document for Review August 30, 2013 2:37 pm

Simona Pacchiarini has been working for IBM Italy since


1989. Over the years she has participated in redbooks projects
on client connectivity, Windows cooperation and database, first
on the AS/400 and now on IBM i. She is currently working in
STG LAb Services in Italy, assisting customers on DB2 Web
Query for i projects, DB2 for i performance and IBM i system
performance studies.
She can be contacted at [email protected].
Septia Sukariningrum is an Advisory Technical Sales
Specialist - Power Systems in IBM Indonesia. She has 6 years
experience in the IT field, and started her career with IBM in
April 2007. She has worked extensively in IBM i Capacity
Planning, IBM i Performance Analysis, IBM i Availability, and
IBM PowerVM. She is now an IBM Certified Technical Sales
Specialist for Power Systems with Power7 and IBM i. Septia
holds a degree in Informatics Engineering from Bandung
Institute of Technology.
Yu Yu Wang is a software engineer in IBM China Systems &
Technology Lab. She joined IBM in 2007 and spent 3 years in
IBM DB2 for i test work. Now she is responsible for Web Query
development. She has experiences both on DB2 for IBM i and
Web Query product. She can be reached at
[email protected].

Yu Zhe Zhi is a Software Engineer in IBM China Systems &


Technology Lab. His current responsibilities include the DB2 for
IBM i test and DB2 Web Query for IBM i test. He has spent the
past year working with DB2 Web Query for IBM i HotFix testing
and the GA testing of this new 2.1.0 release.
He can be reached at [email protected].

Yu Zhu is a Software Engineer working for IBM China Systems


and Technology Lab. He joined IBM in 2010 and is mainly focus
on DB2 Web Query development. He also has some
experiences on DB2 for IBM i test and DB2 Web Query test. He
is involved in the DB2 Web Query 2.1.0 development as well.
He can be reached at [email protected].

xx

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063pref.fm

Hernando Bedoya is a Senior IT Specialist at STG Lab


Services and Training in Rochester, Minnesota. He writes
extensively and teaches IBM classes worldwide in all areas of
DB2 for i. Before joining STG Lab Services he worked in the
ITSO for nine years writing multiple IBM Redbooks
publications. He also worked for IBM Colombia as an IBM
AS/400 IT Specialist doing presales support for the Andean
countries. He has 28 years of experience in the computing field
and has taught database classes in Colombian universities. He
holds a masters degree in computer science from EAFIT,
Colombia. His areas of expertise are database technology,
performance, and data warehousing. Hernando can be
contacted at [email protected].
Thanks to the following people for their contributions to this project:
Linda Robinson
Ann Lund
International Technical Support Organization, Rochester Center
Jerry Evans
Charles Farrell
Cindy Mestad
Steven Ransom
Jim Bainbridge
Robert Bestgen
IBM STG Lab Services Rochester
Kathryn Steinbrink
IBM Development Rochester

Now you can become a published author, too!


Heres an opportunity to spotlight your skills, grow your career, and become a published
authorall at the same time! Join an ITSO residency project and help write a book in your
area of expertise, while honing your experience using leading-edge technologies. Your efforts
will help to increase product acceptance and customer satisfaction, as you expand your
network of technical contacts and relationships. Residencies run from two to six weeks in
length, and you can participate either in person or as a remote resident working from your
home base.
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 books to be as helpful as possible. Send us your comments about this book or
other IBM Redbooks publications in one of the following ways:
 Use the online Contact us review Redbooks form found at:
Preface

xxi

8063pref.fm

Draft Document for Review August 30, 2013 2:37 pm

ibm.com/redbooks
 Send your comments in an email to:
[email protected]
 Mail your comments to:
IBM Corporation, International Technical Support Organization
Dept. HYTD Mail Station P099
2455 South Road
Poughkeepsie, NY 12601-5400

Stay connected to IBM Redbooks


 Find us on Facebook:
http://www.facebook.com/IBMRedbooks
 Follow us on Twitter:
http://twitter.com/ibmredbooks
 Look for us on LinkedIn:
http://www.linkedin.com/groups?home=&gid=2130806
 Explore new Redbooks publications, residencies, and workshops with the IBM Redbooks
weekly newsletter:
https://www.redbooks.ibm.com/Redbooks.nsf/subscribe?OpenForm
 Stay current on recent Redbooks publications with RSS Feeds:
http://www.redbooks.ibm.com/rss.html

xxii

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063p01.fm

Part 1

Part

Background,
installation, and setup
In this part, we introduce DB2 Web Query for i and provide guidance on how to install it. We
also introduce and provide background information about IBM DB2 Web Query for i, along
with installation and setup instructions for the product.
This part includes the following chapters:





Chapter 1, Product overview and architecture on page 3


Chapter 2, Installation and server operations on page 13
Chapter 3, Defining metadata on page 21
Chapter 4, Security Center on page 147

Copyright IBM Corp. 2012. All rights reserved.

8063p01.fm

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ch01.fm

Chapter 1.

Product overview and


architecture
Todays 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
key performance indicators. Financial analysts want to analyze corporate performance to
evaluate profitability or meet compliance guidelines. Business managers require
up-to-the-minute sales and inventory information to ensure that customer demand and sales
quotas can be met. The information must 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 (LOB) applications.
In this chapter, we introduce IBM DB2 Web Query for i (DB2 Web Query). This
comprehensive Java-based business intelligence tool provides graphical, Web-based query
and report-writing functions.
We include the following key topics in this chapter:
 An overview of DB2 Web Query
 DB2 Web Query product structure
 DB2 Web Query architecture

Copyright IBM Corp. 2012. All rights reserved.

8063ch01.fm

Draft Document for Review August 30, 2013 2:37 pm

1.1 Product background


Companies worldwide invest millions of dollars in operational applications to improve the way
they conduct business. While these systems provide significant benefits, clients often
struggle to meet the needs of various users with analysis of the data collected and stored in
those systems.
Back in the 80's, IBM provided a utility to view data stored in S/36, S/38, and AS/400
databases. Now commonly referred to as Query/400, this product continues to this day to be
a heavily utilized utility for viewing data, creating printed reports, or extracting data for
purposes of moving the data into a more modern visualization or analysis tool (like
spreadsheets). Many of the above mentioned operational applications still embed this
decades old technology into their applications for reporting purposes. It is truly amazing that
after more than 25 years this utility is still so heavily used today by I/T shops running IBM i on
Power Systems to access data in DB2 for i.
Meanwhile, over those same decades, DB2 technology for processing data analysis requests
has evolved FAR beyond what was available back then. And unfortunately, Query/400 has
not stayed up on a par with the numerous inventions within DB2 for i to improve performance
and management of the query environment. So while still heavily used, its not just the archaic
front end reporting writing interface that has fallen behind but also the back end processing by
DB2 of queries submitted through the Query/400 tool.
On top of that, in today's highly competitive economic environment, the company that can
analyze data in operational system databases in a more fluid and understandable way can
make more intelligent and timely decisions. The net result is business intelligence - applying
analytics to the data to provide insight for better business decisions.
Improved data analysis can provide many benefits including:
 Ability for end users to get the data when they need it and in the forms they need it in
through a self service model.
 Executives can monitor the state of the business through Key Performance Indicator
dashboards
 Spot trends and exceptions in the data with real time analytical processing
 Automate the creation and delivery of static reports in PDF, spreadsheet, or formats that
allow data to be further analyzed in smart mobile devices.
While most companies have the need for better analytics, not all companies have business
analytics skills, large IT staffs, or a budget to pursue a large scale, enterprise analytics
solution. This may apply to some of the companies who use IBM i today; the majority of which
are in the category of "small and medium" businesses.
A few years ago IBM introduced the IBM DB2 Web Query for i analytics solution to match the
unique requirements of small and midsized companies. The solution is very affordable for
companies with smaller analytics budgets. In addition, the solution is easy to configure,
deploy and use making it easier to leverage existing skills, hardware and fit within operational
processes.
IBM DB2 WebQuery for i provides core analytics and BI platform capabilities including
queries, reporting, OLAP support, and dashboards. Application integration interfaces are
available to develop customized reporting applications or integrate the analytics into day to
day operational applications. Mobile support enables end-users to view reports and
information from their mobile devices.

IBM i DB2 Web Query for i Implementation Guide

8063ch01.fm

Draft Document for Review August 30, 2013 2:37 pm

IBM DB2 WebQuery for i has incorporated a significant number of integration points to
leverage existing IBM i environments and to simplify the management of deployments. For
example, operating system (CL) commands are provided to start, stop, and work with the
reporting environment, create and refresh meta data, and invoke reports automatically
through an existing IBM i based job scheduler. DB2 WebQuery for i integrates with IBM i
security, work management, and software fix and license upgrade processes. This enables
the BI software to become part of the normal IBM i management processes and policies.
capability) can provide some interesting ways to allow reports to incorporate a fuzzy text
search function for XML, Microsoft Word, or other document formats stored in an IBM Power
System running IBM i.
Integration with DB2 for i provides an extensive array of capabilities to build more complex
reports. The ability to define DB2 for i programs (called Stored Procedures), SQL Views, and
DB2 User Defined Functions extends DB2 Web Query's capabilities. Combine the no charge
OmniFind product (5733-OMF) to create a search engine function for end users through
DB2 Web Query. Add images to your reports representing documents such as a product
catalog, and add links to allow an end user to drill down on the image to open that catalog.
Many IBM i companies store the majority of their operational data in DB2 for i, in some cases
in multiple databases the span multiple servers or system partitions. A fundamental design
point of DB2 Web Query is to leverage DB2 for i without having to move data around the
enterprise. However, it is often a requirement to merge data from multiple databases into a
single report, including data from non DB2 for i data sources.
Query/400 was very limited in that it only allowed you to build reports against a single DB2 for
i database. DB2 Web Query expands that substantially by allowing you not only access data
in multiple DB2 for i databases, but also data in remote Microsoft SQLServer databases in the
enterprise (all seamlessly to the end user). With the latest version of DB2 Web Query covered
here, you can also integrate spreadsheets into the reporting environment and combine data
from multiple sources into a single report. IBM continues to look at additional data sources to
add to the DB2 Web Query family to meet the requirements of a single reporting tool for the
IBM i centric company!
And that evolution of DB2 Web Query continues. In April 2012, IBM announced a
restructuring of the product to simplify packaging and pricing, and to provide more flexibility
for those wanting to support BI in the cloud. New "Express" and "Standard" editions simplify
the ala-carte choices of features and products prior to this. New core-based pricing should be
very attractive for those customers on larger systems that are leveraging IBM PowerVM
virtualization capabilities. Additional enhancements include new role-based security,
enhanced smart-phone device support including iPad and Android applications, and an
enhanced user interface for DB2 Web Query authors and end users.

1.1.1 Take Advantage of DB2 for i Analytics Processing Power


High-performance analytics processing is a key requirement for small and midsize
companies, just as it is with large enterprises. Processing the data and gleaning new insight
in an expedient manner maximizes the ability to make better business decisions sooner. A
fundamental step in processing analytical workloads is the database's ability to process the
query requests that the DB2 Web Query tools generate. IBM DB2 Web Query takes
advantage of the advanced query indexing and optimization technologies , and self adapting
self learning faculties within DB2 for i. These advanced features of DB2 for i can significantly
improve performance, in many cases without any administrative intervention!

Chapter 1. Product overview and architecture

8063ch01.fm

Draft Document for Review August 30, 2013 2:37 pm

New with IBM i 7.1 is the DB2 for i Adaptive Query Processing, or AQP. AQP builds on top of
the leading edge SQL Query Engine (SQE) to improve performance without requiring
database administration.
Built into DB2, AQP enables the DB2 for i query optimizer to make real-time adjustments to
its execution plan of a query, such as changing the join order or utilizing a new index,
real-time while the query is running. This is a great example of an underlying performance
enhancement that DB2 Web Query can leverage and Query/400 cannot.
Many analytical queries result in the summarization of transaction or other detail level data. A
common technique to support these types of queries might be to programmatically build
summary tables ahead of time and then have the reports access only the pre-aggregated
summary tables. DB2 for i supports multiple aggregation techniques that provide a level of
automation. Materialized Query Tables are summary tables that can be automatically
recognized and available to a query being processed by DB2. New with DB2 for i 7.1 is the
ability to include aggregate data directly within an Encoded Vector Index (a unique DB2 for i
query acceleration indexing technology).

1.1.2 Optimize the Analytics with a Dedicated, Optimized Server Environment


For some companies, even small and medium businesses, it might be advantageous to
isolate the analytics and reporting environment from the database production environment.
These two run-time environments have very different workload characteristics, and the
isolation of them can provide better system resource management and ultimately lead to
better run-time performance. IBM Power Systems offers PowerVM virtualization capabilities
to create multiple logical partitions on the same system. This feature allows the analytics
environment to run in a separate partition on the same system where the database
environment exists. A second option is to create the analytics environment on a second IBM
Power System. That second system could be partitioned and used for other related or
unrelated workloads. The second system could be leveraged for performing backups,
recovering from disasters, or for development and test.
IBM recently introduced a new solution specifically to address this latter approach. The new
IBM i for Business Intelligence (BI) solution provides several critical capabilities. First, it
provides the data analytics environment on IBM i by including DB2 for i 7.1 and DB2 Web
Query Standard Edition. Secondly, the solution includes a POWER7 based system
intended for housing data sourced from the database production system for use within the
analytics environment. Thirdly, data transportation software is included to simplify the
creation of an Operational Data Store for analytics. Lastly, installation services included in the
package allow you to be up and running in a matter of days!
As opposed to a single-purpose appliance, The IBM i for BI solution can also be used for
more than just the analytics. Extend the solution to provide the ability to do backups, disaster
recovery or provide a development and test environment. The offering is available in several
pre-configured sizes that can be expanded over time. The benefits of the IBM i for BI solution
are reduced pricing, a second server for multiple purposes, quick implementation, and an
optimized (tuned) environment for analytics, all of which meet the needs of small and
midsized businesses.

1.2 Product structure


With the new V2.1 version of DB2 Web Query for i, IBM introduced a significantly more
simplified product structure. Now a customer has a choice of one of two packages, referred

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch01.fm

to as "editions." DB2 Web Query Editions are simple to order bundles that provide a
foundation for core DB2 Web Query functions for either getting started (Express) or rolling out
the business intelligence application across your enterprise (Standard).
DB2 Web Query Express Edition provides an entry level software bundle that includes report
authoring tools, Query/400 import function, and analytic reporting options for a small number
of users. With the Express Edition you can generate high quality PDF reports for external
consumption, or provide OLAP reports for analysts interested in understanding trends or
finding exceptions in the data to uncover what's driving results. In addition, you can leverage
the spreadsheet pivot table support and ability to integrate ad-hoc reporting directly into
Microsoft Excel spreadsheets. For those with mobile devices who need to analyze data while
on the road, the Active Technologies provide analytics for the users disconnected from the
server.
DB2 Web Query Standard Edition combines all of the Express features plus more, providing
a robust offering that can support up to thousands of users running reports. With Standard
Edition, ample user licenses are included to support a typical roll out of developers and
administrators, report authors, and a virtually unlimited number of run-time users and report
consumers.
With Standard Edition, you can build more sophisticated dashboards for executives
monitoring key performance indicators. Use Standard Edition to create an enterprise report
distribution model with abilities to schedule report execution and distribution through e-mail or
save the reports for later viewing. Optionally leverage the data adapter for Microsoft
SQLServer included in Standard Edition to be able to build reports including data from any of
those databases in your network.
Business Intelligence is becoming part of many end user's daily activities. Integrating
analytical function into line of business applications provides the end user with the experience
that makes it simpler for them to turn data into information as part of their normal activities
allowing for real time decision making. The facilities required to execute DB2 Web Query
functions from a customized application are included in Standard Edition. Many clients will
value the ability to create a URL interface to execute parameterized reports and surface that
URL in an existing or new web-based application..
The new packaging also defines three types of user licences. An individual (named)
"Licensed User" is required for anyone with administrative or report authoring or scheduling
authorization. A "Workbench User" license is required for any Licensed User who also
requires advanced meta data enhancement capabilities or the ability to build dashboards with
the HTML layout tool. A new license type is the Run Time Group License. Similar in concept
to the previous version's use of Run Time groups, this new license type is dedicated to
supporting a group of run time users, with each group supporting literally 100's of 1000's of
users (but they can only RUN reports). How many Run Time Group licenses may be required
probably depends less on how many users you want to have the ability to run reports, and
more on how you want to organize your users into groups and associate them with a certain
set of reports/folders they can work with.
Licensed Users and Workbench User Licenses can be added to both Express and Standard
Edition. Run Time Group licenses can be added only to Standard Edition. At some point in
the future, these editions could be extended or modified based on continual evolution of the
product.
Two new product IDs are created to support the new structure. Express Edition is
represented in IBM's ordering system as 5733-WQE, and Standard Edition is 5733-WQS.
However, the Product ID that is actually installed on the system is 5733-WQX (and control of

Chapter 1. Product overview and architecture

8063ch01.fm

Draft Document for Review August 30, 2013 2:37 pm

whether you are able to use Express or Standard Edition is done through License
Management.

1.3 Metadata
One of the most important features of DB2 Web Query is the ability to define in one central
place the particular meaning of data such that you do not have to define rules of data
processing in each and every report. The concept of meta data is one that is considered a
best practice by all the enterprise Business Intelligence tool providers. Why shouldn't a
product targeted for small and medium businesses not adhere to this same best practice?
Through DB2 Web Query's meta data layer, authors don't have to worry about how to join
files, or decompose dates through complex date conversion functions. Multi-dimensional
relationships can be built into the meta data so OLAP reports can easily drill down based on
how the business views its dimensions. Calculated fields can also be defined once into the
meta data, rather than having to do this in every single report, assuring consistency and a
"single version of the truth" for those definitions agreed to by the business.
The benefits of a meta data layer are many, including extending the community of report
authors to more than just the I/T database experts. Tools provided to understand impact
analysis of database changes, and automatic update of that meta data eliminate much of the
inherent challenges that were associated with a heavy Query/400 reporting environment.
Misinterpretations of data and inconsistent standards of the meaning of data can be
catastrophic to businesses.
Metadata and synonyms: The terms metadata and synonyms are used interchangeably
throughout this book. They both refer to the DB2 Web Query data abstraction layer.

1.4 Architecture
Although DB2 Web Query runs natively on the IBM i platform, it comprises multiple
application tiers that service different components. The overall architecture contains each of
the following components:
 HTTP clients
 Web tier
Application server
Web server
 Reporting Server
 Data adapters
 Relational Database Management System (RDBMS) data
DB2 for i is the integrated database for the IBM i platform. Other source databases can be
used with the installation of the appropriate add-on adapters that are discussed earlier in
this chapter.
Figure 1-1 shows the overall architecture of the DB2 Web Query system.

IBM i DB2 Web Query for i Implementation Guide

8063ch01.fm

Draft Document for Review August 30, 2013 2:37 pm

Browser client

IBM i

Version 2.1
HTTP

Applet

Reporting server

IBM HTTP server


powered by Apache
Synonyms
(IFS)

TCP
IBM i Integrated Web Application Server

Data adapters

Servlet container
HTTP
JSP

Servlet

TCP

Developer
Workbench client

DB2
CLI

DB
Heritage
files

Query/400

Microsoft
SQL
Server

QSQSRVR
jobs

Application
client

Report Broker
Distribution server

HTTP

Microsoft Excel
as a client

SOAP /
XML

DB2 Web Query


repository
(folders, procedures,
bitmaps, etc.)

DB2 for i
Report Broker
repository

Windows Server

Prepackaged
WSDL files

Microsoft
SQL
Server

Excel add-in

Application
developed using
web service
language:
C++, C#, VB.NET,
JAVA, RPG, COBOL
Web based applications containing DB2
Web Query content

Figure 1-1 DB2 Web Query base archtecture

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 actions 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 passes it to the appropriate data
adapter.
4. The data adapter generates the appropriate database request and submits the request to
the DB2 for i database engine.
5. The 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 users Web browser for display.

Chapter 1. Product overview and architecture

8063ch01.fm

Draft Document for Review August 30, 2013 2:37 pm

1.4.1 Web browser clients


Both DB2 Web Query developers and users use a Web browser as the interface to the
product. The browser clients communicate via HTTP to the application server. At the time that
this version of the Redbook was published, the following Web browsers were generally
supported:








Internet Explorer v9 (32-bit)


Internet Explorer v8
Firefox v17, v16, v15, v14
Safari v5.1.5
iOS v5
Chrome v21
Opera v12.02

Specific browser and version support is dynamic and varies across the assorted DB2 Web
Query components. Because this information is constantly changing and must be kept
updated, specific support matrices are not provided in this publication. This infomation is
provided in the DB2 Web Query Summary of New Features (SNF) document that is updated
for every release and group PTF. This document is stored on the DB2 Web Query
developerWorks WIKI. The SNF documents can be directly accessed by opening the
following URL:
http://ibm.co/db2wqnewfeatures
Locate and download the SNF document titled R210 New Features. Browser support
matrices are located in the Web Browser Support section of this document.

1.4.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). This
information is stored in the both the IBM i integrated file system (in the
/qibm/proddata/qwebqry/base80/ibi_html directory) and the DB2 Web Query database
repository. Within these two data sources are the following items:
 Common templates and forms
 Common images, scripts, and style sheets
 Published forms and launch pages

1.4.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 IBM i Integrated Web Application Server and
uses the servlet container component to process these client requests. Servlet containers are
also referred to as servlet engines.
The DB2 Web Query application server has the following attributes:
 Is a J2EE-compliant Web application

10

IBM i DB2 Web Query for i Implementation Guide

8063ch01.fm

Draft Document for Review August 30, 2013 2:37 pm

 Runs on a servlet container, a Java-based container that serves servlets, JavaServer


Pages (JSPs), and connectors
 Does not require a full J2EE application server
 Supports servlets
 Standardizes deployment schemes using archives or packages
 In some cases, groups multiple applications into Web Application Bundle (WAB) files
Applications are grouped into a WAB file that 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 the DB2 Web Query Repository

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)

1.4.4 Reporting Server


The DB2 Web Query Reporting Server is a C-based application that resides on the IBM i
platform and is responsible for managing data access, processing the business logic, and
generating the fully styled output. It comprises the following components:
 Reporting Engine of DB2 Web Query product
 Data adapters repository
 Metadata or synonym repository

1.4.5 Data adapters


An adapter is a program that enables DB2 Web Query to access a data source. Data
adapters are responsible for generating the appropriate request to submit to the database
engine. DB2 Web Query comes with three different adapters. The adapter that you choose to
create your metadata or synonym is transparent to the users who will create reports. The
format of the request depends on the adapter that is used:
 The DB2 CLI adapter generates appropriate SQL statements to submit to the DB2 for i
database engine.
We recommend this adapter for use by DB2 Web Query. Select this adapter if you want to
write a report on a single member physical file. The report can include an SQL table or a
data description specifications (DDS)-created physical file. This adapter is also used for
object types of alias, stored procedures, and materialized query tables (MQTs). The DB2
CLI adapter generates SQL that takes full advantage of the latest DB2 enhancements that
are found in the SQL Query Engine (SQE).
 The DB2 Heritage File adapter generates the appropriate OPNQRYF command to
handle reports that are based on data in a file that has multiple members or multiple
record formats.
This command does not take advantage of the new enhancements to the DB2 optimizer
and uses the Classic Query Engine (CQE) under the covers.
Chapter 1. Product overview and architecture

11

8063ch01.fm

Draft Document for Review August 30, 2013 2:37 pm

 The Query/400 adapter retrieves the associated Query/400 query.


Choose this adapter when you want to create metadata on an already existing Query/400
query. The QRYDFN object must exist on the IBM i platform. This adapter sends the
RUNQRY command to the server, which also uses the older CQE.
Table 1-1 summarizes the adapters and how they correspond to the data types.
Table 1-1 Data adapters
Adapter

Data type

Command sent to IBM i machine

DB2 CLI

Single member physical file; alias,


stored procedure, or MQT

CLI API

DB2 Heritage
File

Multiple member file, multi-record


format files

OPNQRYF

Query/400

QRYDFN object

RUNQRY

These three adapters allow you to query DB2 for i data sources and are included in the DB2
Web Query Express Edition. An additional data adapter is bundled in the DB2 Web Query
Standard Edition: the SQL Server adatper allows you to connect to Microsoft SQL 2000,
2005, and 2008 servers. Metadata is created the same way as in DB2. Once created, you
can create reports solely against the SQL Server data or even join tables between an SQL
Server and DB2 on i. Learn one set of tools and use them for all of your reporting needs!
In addition, a JD Edwards application adapter can be purchased as a seperate option from
the Standard Edition package. This adapter will automate some of the transformations
necessary to display JD Edwards information in a meaningful way.

1.5 Request for changes on Web Query


The IBM DB2 Web Query team is always looking for ways to improve the product. If you have
a suggestion for a new feature or would like a change to an existing feature, let us know. You
can voice your opinion and ideas to us via the Web. You can use the standard Request for
Design change form. This form can be used to requests changes to all IBM products around
IBM i. For Web Query, be sure to select the DB2 Web Query option from the problem area
drop-down menu. The address to get to the Web form is:
https://www-912.ibm.com/r_dir/ReqDesChange.nsf/Request_for_Design_Change?OpenForm

12

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch02.fm

Chapter 2.

Installation and server


operations
In this chapter, we explain the installation of DB2 Web Query, 5733-WQX, using the
RSTLICPGM command. We outline the PC and IBM i prerequisites for installing DB2 Web
Query. We also describe which IBM i system jobs will run and their functions in DB2 Web
Query. In addition, we discuss other system objects that are created upon installation of DB2
Web Query.
Note: For the most current and complete information about the installation instructions,
see the IBM DB2 Web Query for i Install Instructions on the Web at:
http://ibm.co/db2wqinstallation

Copyright IBM Corp. 2010. All rights reserved.

13

8063ch02.fm

Draft Document for Review August 30, 2013 2:37 pm

2.1 Installation and setup


The licensed program product number for DB2 Web Query for i is 5733-WQX, which replaces
5733-QU2 . The 5733-QU2 and 5733-WQX products can coexist and run concurrently, as
long as 5733-WQX is in the trial period. After 5733-WQX is licensed, you can run either
product but not both at once.

2.1.1 Installing DB2 Web Query


Important: Before you start the installation, you must obtain the most current information
about the prerequisites and required program temporary fixes (PTFs). You can find this
information in Informational APAR, which is available on the Web at:
http://ibm.co/db2wqinstallation
To install DB2 Web Query, you must follow the up-to-date instructions on the web site listed
above. You will find links to the install instructions, upgrade instructions, and Info APARS.
While the exact steps are documented on the web, the basic flow of the process consists of:
1.
2.
3.
4.
5.

Install prerequisite programs, if missing.


Install prerequisite PTFs and PTF Groups, if missing.
Install the DB2 Web Query product and any options purchased.
Install the PTF Group for DB2 Web Query.
Configure a language if not running in English.

It is important that you follow all the steps as documented in the Installation Instructions and
Info APARs. As noted, a new Group PTF for Web Query will be released about every three
months. Refer to the Info APARs about updated Group PTFs and try to stay as current as
possible. If you run into a problem and call support, you will be asked whether you are at the
most current Group PTF for Web Query.

IBM i system objects


Upon installing 5733-WQX, the following integrated file system directories are created:
 /QIBM/PRODDATA/QWEBQRY
 /QIBM/USERDATA/QWEBQRY

14

Getting Started with DB2 Web Query for i

8063ch02.fm

Draft Document for Review August 30, 2013 2:37 pm

Table 2-1 lists the system objects that are created.


Table 2-1 System objects
Object name

Object type

QWEBQRYX

*LIB

QWEBQRY

*LIB

QWQREPOS

*LIB

QWQCENT

*LIB

QSYS/QWQADMIN

*USRPRF

QSYS/QWQ0000000

*AUTL

QWEBQRY/QWEBQRYJOB

*JOBD

QUSRSYS/QWQADMIN

*MSGQ

DB2 Web Query-related user profile:


 QWQADMIN: This profile has functionality on the server side and has authority to start
and stop the Reporting Server. The profile is automatically created.

2.1.2 Authorizing and verifying users


The users must be licensed to use DB2 Web Query. For each user that will use the product,
you must allocate a license. There are multiple types of licenses available including Web
Query Developer Users, Web Query Developer Workbench Users and Web Query Runtime
Groups. However, every user must be pre-authorized. In order to add or remove licenses
from user profiles, use the Security Center. For details on the various licenses and the use of
the Security Center see Chapter 6, Security Center - Setting up users on page 169.
You can view the currently licensed users by running:
WRKLICINF PRDID(5733WQX)
Then take option 8 next to the feature 5104, 5105 and 5106.

2.1.3 License keys


After you install DB2 Web Query, you are allowed a grace period in which to try the product.
During this grace period, you have access to all the features that are provided in the base
product as well as all of the IBM add-on components. However, after the grace period
expires, license keys are required to continue using both the base product and the add-on
components.
To obtain your DB2 Web Query license keys, you must 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.
Each license key is used to activate either the base product feature (5050), the Express
Edition feature, the Standard Edition feature, or one of the add-on features. To enter your
license keys and activate the specific features, use the ADDLICKEY command.

Chapter 2. Installation and server operations

15

8063ch02.fm

Draft Document for Review August 30, 2013 2:37 pm

Note: You do not have to wait for the grace period to expire before you enter your license
keys. You can do this at any time.

2.1.4 Dynamic Language Switch


If you are running a system that may need to be viewed in multiple languages, the Dynamic
Language Switching option is for you. This is included in the base product. It allows you to set
a list of languages that a user can select from at login time. This feature will, by default,
update the interface of the program to match the language selected.
To use this feature, follow the instructions in the installation document on the DB2 Web Query
wiki at:
http://ibm.co/db2wqinstallation

2.1.5 Sample database


Throughout this book, we use a sample database called the Century database. This database
will be available after installing DB2 Web Query on IBM i. The library is named QWQCENT.
This allows you to follow along figure by figure to see exactly what you get in the book. You
can use your own data if you like, but we make this sample database available to you.

2.2 Requirements
In this section, we cover the PC and IBM i minimum requirements to install and run DB2 Web
Query.

2.2.1 PC requirements
No client is required to be installed on your PC to enable DB2 Web Query. You only need a
browser. For more information on the supported browsers, please see Web browser clients
on page 10.

In regard to PC memory requirements, in general, queries usually run best on PCs that have
1 GB of RAM or more.

2.2.2 IBM i requirements


Your IBM i environment must have 6.1 of IBM i or later.

2.2.3 Developer Workbench requirements


Although the Developer Workbench client is not required for DB2 Web Query report
development and execution, you might still find that it provides additional development
features that make it worthwhile. If you choose to install it on your PC, use the hardware and
software requirements listed on wiki at:

16

Getting Started with DB2 Web Query for i

8063ch02.fm

Draft Document for Review August 30, 2013 2:37 pm

https://www.ibm.com/developerworks/mydeveloperworks/wikis/home?lang=en#/wiki/W516d
8b60d32c_4fc5_a811_5f3d840bf524/page/DB2%20Web%20Query%20for%20i%20Wiki
Note: You must be an administrator to the Windows machine to run the Developer
Workbench installation.

Provided third-party component


The third-party component Java 2 SDK is provided for use with Developer Workbench. A
Java SDK is required for WebFOCUS features such as servlet connectivity, graph
generation, and online analytical processing (OLAP). If it is not present on your machine, you
have the option to install it with Developer Workbench.
If Java SDK 1.4.1 or later is not installed on your machine, you must allow Developer
Workbench to install the SDK.

2.3 Web Query administrative commands


The base component of the licensed program provides multiple IBM i commands to help with
DB2 Web Query administrative tasks. By default, some of the commands to work with Web
Query are shipped as *PUBLIC *EXCLUDE. However, any user that is a DB2 Web Query
administrator (a member of the QWQADMIN group profile) or isauthorized to use the
commands via *ALLOBJ special authority or explicit authority can use these commands.
When DB2 Web Query is started, a prerequisite check is performed. If required products or
PTFs are missing, DB2 Web Query will not start. The job log will provide complete details on
what was missing to allow you to correct this issue.
 STRWEBQRY
Use the STRWEBQRY command to start all the jobs that are required to run Web Query.
 ENDWEBQRY
Use the ENDWEBQRY command to end the Reporting Server.
 WRKWEBQRY
Use the WRKWEBQRY command to start, stop, and display the status of DB2 Web
Query. Each Web Query port and its status is displayed, as well as installed product and
prerequisite information.
 CRTWQSYN
Use the CRTWQSYN command to create and refresh DB2 Web Query synonyms. You
can also use the metadata console from the browser as well as Developer Workbench to
create synonyms.
 WRKWQRTE
Use the WRKWQRTE command to create dynamic Runtime Environments and assign
users to them. The feature allows users to dynamically change their library list in a quick
and easy manner. For more informatin on dynamic Runtime Environments, see the
following document on the DB2 Web Query Wiki:
https://www.ibm.com/developerworks/mydeveloperworks/wikis/home?lang=en#/wiki/W5
16d8b60d32c_4fc5_a811_5f3d840bf524/page/Dynamic%20Runtime%20Environments

Chapter 2. Installation and server operations

17

8063ch02.fm

Draft Document for Review August 30, 2013 2:37 pm

2.4 DB2 Web Query server jobs


Typically, the interface that DB2 Web Query uses to access the DB2 for i database is the SQL
call-level interface (CLI). CLI is a callable SQL programming interface that is available in
DB2 on the IBM i operating system. CLI consists of application programming interfaces
(APIs) that are used to connect to the server and start dynamic SQL statements. The CLI is a
subset of Open Database Connectivity (ODBC). The system job that processes CLI is
QSQSRVR. For more information about CLI, refer to System i Database DB2 UDB SQL call
level interface (ODBC) on the Web at:
http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/topic/cli/rzadp.pdf
When DB2 Web Query is active, the following jobs run on the IBM i server in the
QWEBQRY21 subsystem.
 EDAPTH: one job that helps with the workspace process and runs under the user profile
QWQADMIN.
 EDAPLOG: one job that contains startup information and runs under the user profile
QWQADMIN.
 EDAPGWY: three listener jobs, one each for HTTP, TCP, and Java. These jobs receive
incoming requests and hand off work to the TSCOM3 jobs. All run under the user profile
QWQADMIN.
 TSCOM3: By default, four of these jobs are 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
reason, the design of these jobs contributes to the scalability of the product. They are
referred to as agents. and all run under the the current users user profile.
 JSCOM3C: one job that services Java processes and runs under the user profile
QWQADMIN.
 WQLWI80: This job is for integrated application server jobs. Four of these jobs should be
running whenever DB2 Web Query is active (three run under the user profile QTMHHTTP,
the other under profile QWQADMIN).
 QSQSRVR: This IBM i native prestart job handles SQL requests that are made over CLI.
This job does the actual database work of optimization, execution, and returning the
result. By default these jobs run under the user profile QUSER, but when DB2 Web Query
report (based on a DB2 CLI synonym) is run, a CLI connect event occurs with one of these
jobs. At this point, the user profile running the job is swapped to the user profile that
initiated the DB2 Web Query report request.
In addition, the following jobs are started to support the DB2 Web Query report scheduling
and distribtuion feature (known as Report Broker):
 STRBROKER: one job that runs under QWQADMIN and invokes QSHELL to run a script
to start the Distribution Server.
 QP0ZSPWP: two jobs that run under user profile QWQADMIN. One job is the JVM and
the other is the console window that the Distribution Server starts up.
Another way to look at the jobs is via their ports. When running, DB2 Web Query will be active
on ports 12331 to 12339. Port 12339 is used for DB2 Web Query Report Broker. Therefore, if
you do not have that product installed, this port will not be active. At the time of publication,
port 12337 is not used. The WRKWEBQRY command can be used to display the status of
these ports. Alternatively, you can look at active ports by using the NETSTAT command and
taking option 3. Once the display is up, use F14 to display port numbers. As you scroll down,

18

Getting Started with DB2 Web Query for i

8063ch02.fm

Draft Document for Review August 30, 2013 2:37 pm

you will see that the local port column is ordered descending. Scroll down until you reach a
local port of 12331 to see these connections.

2.5 Running QU2 and WQX concurrently


Customers that migrate from Web Query 1.1.x (product id 5733QU2 or QU2) to version 2.1
(5733WQX - WQX) will be able to run both versions concurrently under the following
conditions:
"A permament WQX license key is NOT applied
"The trial period for WQX has not ended. The trial period initiates the first time WQX is started
using STRWEBQRY command. It ends 70 days after it is initiated.
When the WQX trial period is over, permanent license keys must be entered to continue
usage of the product. At this point the customer will not be able to start both QU2 and WQX
at the same time. They can however start one or the other - just not both at the same time.
Here are the scenarios when trying to start both:
 "If both QU2 and WQX are down, QU2 is started, and attempt is made to start WQX then
the request to start WQX fails.
 "If both QU2 and WQX are down, WQX is started, and attempt is made to start QU2 then
the request to startQU2 fails.
When the trial period has expired and permanent 5733WQX license keys have been applied,
administrators will notice that version 2.1 allocates port 11331 (instead of port 12334 as
described above). This port allocation is what prevents both versions from running
concurrently.
The following table summarizes the ports used by the two products:
Table 2-2
5733QU2 (version 1.1.x)

5733WQX (version 2.1.x

11331

12331

11332

12332

11333

12333

11334

12334 (during trial period)


11331 (after trial period)

11335

12335

11336

12336

11338

12338

11339

12339

Chapter 2. Installation and server operations

19

8063ch02.fm

20

Getting Started with DB2 Web Query for i

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Chapter 3.

Defining metadata
This section explains what metadata is and why you should consider it as an advantageous
feature, something that can reduce the complexity of your query and reporting environment
and make life easier for your report developers.
Before you can create a single report or graph in DB2 Web Query, you must create metadata
(also known as synonyms) over the data source. The metadata requirement of the DB2 Web
Query product may be foreign to you. Many IBM i customers are simply not accustomed to
working with a product that requires metadata and consequently view it as an unnecessary
burdenan extra layer of complexity that they have to create and maintain. Typical questions
include the following:





What exactly is metadata?


Why do I need it?
Can't I just query my files directly?
What happens if the structure of my underlying files changes?

In this chapter we will cover the details of the metadata and how it relates to DB2 Web Query
for i.

Copyright IBM Corp. 2012. All rights reserved.

21

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

3.1 What is metadata


Metadata is simply data about data. Whenever you issue the DSPFD or DSPFFD commands,
what is generated and displayed on your screen is in fact metadatainformation such as
record lengths, record formats, field names, data types, field attributes, and field lengths. DB2
for i also maintains system catalogs, which are files that store information about each of the
objects in your database. They are effectively a materialized metadata repository that is kept
up to date and can be queried to collect a wide variety of information about your database.
In much the same way, DB2 Web Query metadata is a materialized repository that contains
information about your database files. In other words, DB2 Web Query can potentially read all
of your database, but you have to give it information on where the data is located and how it is
structured. Before you can create a report or graph in DB2 Web Query you must first create
metadata (also referred to as synonyms) over the data sources. You can create a synonym
over the following database objects:






Tables/physical files
SQL views
DDS logical files
Stored procedures
Materialized query tables

In general, whenever you create a synonym over an object, database or flat file, two stream
files are created in the Integrated File System (IFS) in a directory that has the same name as
your folder in DB2 Web Query /qibm/UserData/qwebqry/apps/<myfolder>. The two files that
are created are called a master file and an access file:
 Access file: This file identifies the object name and type on which the metadata is created.
The access file has an extension of .acx. The access file consists of multiple
keyword-value pairs that are separated by commas. Attributes included are the name of
the synonym segment (T1_ORDERS), the underlying table that is referenced (ORDERS in
library QWQCENT), the system to connect to in order to find the data source object
(*LOCAL), and the number of key fields (0). If the table has referencial integrity
relationships with other tables, the relationships are llisted in the .acx file. If the synonym
refers to more than a table (cluster or join synonym) all the tables are referenced with the
information described above. If the object is a QRYDFN, it says QIQRY. If the object type
is a table, it says TABLENAME. Figure 3-1 on page 22 shows an access file for table
QWQCENT/ORDERS. If the table is linked with Referential Integrity relationship with other
tables, the exixsting relationships are explicitly stated in the .acx file(Figure 3-2 on
page 23).
Browse : /qibm/UserData/qwebqry/apps/simona/cen_orders.acx
Record :
1
of
1 by 18
Column :
Control :

...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+.
************Beginning of data**************
SEGNAME=CEN_ORDERS, TABLENAME=QWQCENT/ORDERS, CONNECTION=*LOCAL, KEYS=0, $
************End of Data********************
Figure 3-1 Access file for the QWQCENT/ORDERS table

22

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Browse : /qibm/UserData/qwebqry/apps/simona_10/cen_orders.acx
Record :
1
of
7 by 18
Column :
Control :

...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+..
************Beginning of data**************
SEGNAME=CEN_ORDERS, TABLENAME=ORDERS, CONNECTION=*LOCAL, KEYS=0, $
FOREIGN_KEY=Q_QWQCENT_ORDERS_PROD_NUM_00001, PRIMARY_KEY_TABLE=INVENTORY,
FOREIGN_KEY_COLUMN=PRODUCTNUMBER, PRIMARY_KEY_COLUMN=PRODUCTNUMBER, $
FOREIGN_KEY=Q_QWQCENT_ORDERS_PLANT_CODE_00001, PRIMARY_KEY_TABLE=PLANT,
FOREIGN_KEY_COLUMN=PLANTCODE, PRIMARY_KEY_COLUMN=PLANTCODE, $
FOREIGN_KEY=Q_QWQCENT_ORDERS_STORE_CODE_00001, PRIMARY_KEY_TABLE=STORES,
FOREIGN_KEY_COLUMN=STORECODE, PRIMARY_KEY_COLUMN=STORECODE, $
************End of Data********************
Figure 3-2 Access file for the QWQCENT/ORDERS table with RI

 Master file: This file identifies the fields of the table or, if the object is a QRYDFN or a
Stored Procedure, the fields in the result set. The master file has an extension of .mas.
The fields are described in terms of length and data type. This file is similar to the
information in a DSPFFD file, but the information is described in a way in which DB2 Web
Query understands. Figure 3-3 on page 24 shows a master file for table
QWQCENT/ORDERS.
Similar to the access file, the master file uses a keyword-value pairing technique to define
the column attributes. These include the name of the field, the ALIAS (the actual
underlying field name in the file), the data type and length (for both how it is used in
reports and actually defined in the file), and the title to be used in report column headings.
For QRYDFN objects, there are three additional metadata files:
 .fex
 .txt
.inf
In DB2 Web Query V2R1M0 metadata can be created in a common folder where they can
be used by everybody who has access to the product or can be created in a private
directory that is associated to a folder defined int the product. This has been done to achieve
two purposes:
 security - synonyms associated to an application folder can only be modified by those who
have development rights on the specific folder
 privacy - synonyms associated to an application folder are presented only to those who
can develop in the specific folder and are only usable by those who can use the folder and
its contain.
A really nice thing about metadata is that it is an abstraction layer. You can build business
logic into the metadata so that all reports and graphs that reference those synonyms have
access to all of that logic. This greatly simplifies the environment for the report developers.

Chapter 3. Defining metadata

23

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Browse : /qibm/UserData/qwebqry/apps/simona_10/cen_orders.mas
Record :
1
of
33 by 18
Column :
70 by 131
Control :

...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+..
..8....+..
************Beginning of data**************
FILENAME=CEN_ORDERS, SUFFIX=DB2
,
REMARKS='Orders table for Web Query QWQCENT DB', $
SEGMENT=CEN_ORDERS, SEGTYPE=S0, $
FIELDNAME=ORDERNUMBER, ALIAS=ORDERNUMBER, USAGE=A5, ACTUAL=A5,
TITLE='Order,Number', $
FIELDNAME=PRODUCTNUMBER, ALIAS=PRODUCTNUMBER, USAGE=A4, ACTUAL=A4,
TITLE='Product,Number', $
FIELDNAME=ORDERDATE, ALIAS=ORDERDATE, USAGE=YYMD, ACTUAL=DATE,
TITLE='Order,Date', $
FIELDNAME=STORECODE, ALIAS=STORECODE, USAGE=A6, ACTUAL=A6,
TITLE='Store,Code', $
FIELDNAME=PLANTCODE, ALIAS=PLANTCODE, USAGE=A3, ACTUAL=A3,
TITLE='Plant,Code', $
FIELDNAME=SALESREP, ALIAS=SALESREP, USAGE=A50, ACTUAL=A50,
TITLE='Sales Rep', $
FIELDNAME=QUANTITY, ALIAS=QUANTITY, USAGE=I11, ACTUAL=I4,
MISSING=ON,
TITLE='Quantity', $
FIELDNAME=LINETOTAL, ALIAS=LINETOTAL, USAGE=P22.2, ACTUAL=P11,
MISSING=ON,
TITLE='Revenue', $
FIELDNAME=COSTOFGOODSSOLD, ALIAS=COSTOFGOODSSOLD, USAGE=P22.2,
ACTUAL=P11,
MISSING=ON,
TITLE='Cost of,Goods Sold', $
FIELDNAME=RETURNS, ALIAS=RETURNS, USAGE=I11, ACTUAL=I4,
MISSING=ON,
TITLE='Returns', $
FIELDNAME=WARRANTYEXP, ALIAS=WARRANTYEXP, USAGE=P22.2, ACTUAL=P11,
MISSING=ON,
TITLE='Warranty,Expenses', $
FIELDNAME=SHIPPINGCOST, ALIAS=SHIPPINGCOST, USAGE=P22.2, ACTUAL=P11,
MISSING=ON,
TITLE='Shipping,Cost', $
************End of Data********************
Figure 3-3 DB2 Web Query master file example

3.1.1 Benefits of metadata


The primary objective of the metadata layer is simple: Improve the productivity of the DB2
Web Query report developers by providing an abstraction layer and burying the database
complexity. Report developers can be more productive if you keep the data model simple. A
simple and intuitive data model also means that you can extend the report developer
community because it does not require an intimate knowledge of the database. By

24

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

empowering more and more of your users, you can reduce their dependence on IT and the
number of backlogged reporting requests.
But before this can happen, some work needs to be done to build up this abstraction layer.
While in previous releases of the product additional tool DB2 Web Query Developer
Workbench was needed, in DB2 Web Query V2R1M0 it is possible to create and edit
synonyms via the web interface.
The web based metadata editor allows you to:







Define database joins.


Build virtual columns to centralize business logic.
Standardize column formats.
Convert and standardize date fields.
Create filters.
Create business views.

3.2 Creating metadata


DB2 Web Query metadata can be generated in multiple ways. Each technique is discussed
below.
 Create your own.
Metadata creation wizards are available from both the Web browser (Creating metadata
with the web interface on page 26) via the Web Query launch page and in the DB2 Web
Query Developer Workbench tool - more on this tool later (Creating metadata with
Developer Workbench on page 30). In alternative you can create metadata
programmatically using the CRTWQSYN CL command (Creating metadata with CL
command CRTWQSYN on page 34). To create metadata, you must either be a DB2 Web
Query DBA as explained in Chapter 4, Security Center on page 147.
Metadata can be created within your application folder (then it is available only in your
folder) or in the Common application folder (metadata available from all applications).
 Through the use of third-party tools.
Some examples of this include:
The Databorough x-WebQuery product (www.databorough.com) generates the
metadata based on the data model that it derives from both database definitions and
business logic buried in application programs. It can also use this extracted information
to generate the necessary dimensions for instant OLAP capabilities.
Information Builders's iWay Data Migrator (www.ibi.com) and Coglin Mill's RODIN DB2
Web Query Edition (www.thinkrodin.com) products generate the metadata in
conjunction with building a data mart or data warehouse.
 Provided by ERP or services provider.
ISVs have the ability to include DB2 Web Query content as part of their solutions package.
If you purchase such a distribution, the metadata will be included in the package. Similarly,
a services provider may have the expertise and tools to build the metadata for you.
 JDE Adapter provides metadata for JDE as is explained in Chapter 21, Assignment 15:
Creating JD Edwards reports on page 685.

Chapter 3. Defining metadata

25

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

3.2.1 Creating metadata with the web interface


In most cases you are going to create your own metadata using the provided metadata
creation wizards. To do this, take the following steps:
1. Open a Web browser and enter the URL of the DB2 Web Query home page.
2. On the DB2 Web Query home page, expand the folder in which you want to work.
Right-click the specific report folder and select Metadata Figure 3-4 on page 26

Figure 3-4 Metadata

3. In the new pane, on the left hand side select the adapter that you want to use - in this
example we want to use DB2 data on the local system, hence select DB2 CLI. You will see
the *LOCAL connection appear below it. Right click on *LOCAL and select Create
Synonym, as shown in Figure 3-5. If you have configured connection to remote
databases or installed other adater they will be presented in the list.
To learn more about data adapters refer to Chapter 1.4.5, Data adapters on page 11.

26

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-5 Create Synonym for DB2 CLI

4. In the Select Synonym Candidates for DB2 CLI pane (Figure 3-4), enter your
collection/library name. Select the type of data that you want to query. In our example, we
select Tables because want to create metadata on a table in QWQCENT. In the Library
field, type qwqcent. Click Next.

Chapter 3. Defining metadata

27

8063ch03.fm

Figure 3-6 Select Synonym Candidates

28

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

5. The Create Synonym for DB2 CLI pane is displayed (Figure 3-7) and shows all the
different tables that reside on the QWQCENT schema. Select the table names for which
you want to create reports.

Figure 3-7 Selecting tables from a schema or library

You might want to include a prefix or suffix. In our example, cen_ is our prefix because the
table resides in library QWQCENT. We leave the suffix blank, but the developer has the
choice to use it. In the Application field you find the name of the folder in which you are
creating metadata.
If you want your metadata to have a different name than the underlying table double click
on the name and edit it.
Click on the Create synonym button.

Chapter 3. Defining metadata

29

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Prefix and suffix (optional, yet recommended): The prefix and suffix are optional
letters that 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 whether it is
necessary to use the prefix and the naming convention that is preferred. We
recommend that you use the library name or an abbreviated version of the library name
for the prefix. This way, when you create your reports, you can search on all metadata
that starts with the library name.
Keep in mind that all metadata is displayed in one box called Database Descriptions.
The box is small and list the metadata in alfabetical order, not according to library.
6. The metadata takes a few seconds to create, depending on how many items you selected.
After the processing is done, in the Status column, you see the message Created
successfully, as shown in Figure 3-8

Figure 3-8 Synonyms created

7. The process of creating metadata is now complete. Close the message box.

3.2.2 Creating metadata with Developer Workbench


Metadata can also be created using the client-server development tool, Development
Workbench.
1. Open Developer Workbench, select the system on which to work and validate with your
userid and password. Please remember that the user must be part of the DevWorkbench
group (use Administration Security Center in the web interface to set up as
documented in Chapter 4, Security Center on page 147.
2. Select Data Servers EDASERVE Applications and right click on the folder where
you want to create the new synonym and select New Synonym as shown in Figure 3-9
on page 31.

30

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-9 Create Synonym with Developer Workbench - Step 1

3. You are presented with the Select Adapter window, select *LOCAL and click on OK
(Figure 3-10).

Figure 3-10 Create Synonym with Developer Workbench - Step 2

4. In the Select synonym candidate window check Tables, position in the Library field
and type in the name of the library where to look for tables to be referenced (QWQCENT
in our example) then click on Next as shown in Figure 3-11 on page 32.

Chapter 3. Defining metadata

31

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-11 Create Synonym with Developer Workbench - Step 3

5. You are presented with a panel where to choose the table(s) for which to create synonyms.
The same considerations detailed in Chapter 3.2.1, Creating metadata with the web
interface on page 26 apply here. In this example we use prefix CEN_ and select table
ORDERS as shown in Figure 3-12 on page 33. When you are done select Create
synonym.

32

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-12 Create Synonym with Developer Workbench - Step 4

6. You are presented with a message confirming the synonym creation(Figure 3-13 on
page 34). Select Close.

Chapter 3. Defining metadata

33

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-13 Create Synonym with Developer Workbench - Step 5

3.2.3 Creating metadata with CL command CRTWQSYN


In alternative to the products browser interface it is now possible to use command
CRTWQSYN in library QWEBQRY to create metadata. This command can be used from a
5250 interactive session, inserted in programs (to automate and schedule a mass refresh
action) or used with Job Scheduler. See Figure 3-14 on page 35 for an example of using
CRTWQSYN command to create a new synonym.
The CRTWQSYN CL command has the following parameters:
FILE - Enter the name of the database file object to create the DB2 Web Query synonym
over.
SCHEMA - Enter the name of the database schema (library) which contains the files you wish
to create DB2 Web Query synonyms over. FILETYPE :
FILETYPE - When *ALL is specified for the file parameter, specifies what types of files are to
be searched for and included in the synonym creation process. Up to
four file types can be specified. EXCLSRCPF
EXCLSYSFL - When *ALL or a generic* value is specified for the file parameter, specifies
whether to exclude system files and catalogs when locating and
creating synonyms for the files in the specified schema.
EXCLSRCPF - When *ALL or a generic* value is specified for the file parameter, specifies
whether to exclude source physical files when locating and creating
synonyms for the files in the specified schema.
PREFIX - Specifies the prefix to append to the beginning of the synonym name. If you have
tables with identical table names, assign a prefix or a suffix to
distinguish them. For example, if you have identically named human
resources and payroll tables, assign the prefix HR to distinguish the
synonyms for the human resources tables.Note that the resulting
synonym name cannot exceed 64 characters.
SUFFIX - Specifies the suffix to append to the end of the synonym name. If you have tables
with identical table names, assign a prefix or a suffix to distinguish
them. For example, if you have identically named human resources
and payroll tables, assign the prefix HR to distinguish the synonyms
for the human resources tables. Note that the resulting synonym name
cannot exceed 64 characters.
APPFLR - Specify the name of the application folder where the synonym is to be created.
FRGNKEYS - Specifies whether the synonym should include foreign key relationship
definitions. If specified, the synonym being created will automatically
34

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

include every table related by a foreign key to the table specified inthe
FILE parameter. The resulting multi-table synonym describes all table
foreign key relationships.
QUALLIB QUALLIB - Specifies whether to generate a library qualified table name in the DB2
Web Query synonym Access file (.acx) for the specified table.
OPTION - Specifies what action to take if the specified synonym name (including prefix and
suffix) already exists in the specified application folder.
SHORTALIAS - When generating the table's column level information in the Master (.mas)
file, specifies whether to use the table's system (short) name for the
synonym's alias. This allows the DB2 Web Query report developer to
see and use both the SQL (long) name of the column as wellas the
system (short) name when using the report development tools.
Create DB2 Web Query synonym (CRTWQSYN)
Type choices, press Enter.
File (table/view) name . . . . . FILE

> ANART00F

Schema (library) name

> PROVEOO

. . . . . SCHEMA

File type . . . . . . . . . . . FILETYPE


+ for more values
Exclude system files/catalogs . EXCLSYSFL
Exclude source physical files . EXCLSRCPF
Synonym prefix . . . . . . . . . PREFIX
Synonym suffix . . . . . . . . . SUFFIX
Application folder . . . . . . . APPFLR

With foreign keys

. . . . . . . FRGNKEYS

Include library qualificaion . . QUALLIB


Existing synonym option . . . . OPTION
Use field short name as alias . SHORTALIAS

> *TABLE
*YES
*YES
> POO_
*NONE
> SIMONA

*NO
*YES
> *NONE
*NO

Figure 3-14 Create a new synonym using CL command CRTWQSYN

3.3 Deleting Metadata


When a metadata is not any more needed you may want to delete it.
You do not have to delete it explicitly if you simply want to recreate it (there is an option to
overwrite existing synonyms in the creation wizard) or if you want to update the metadata to
reflect a change in the underlining files - please refer to Refreshing metadata (when IBM i
database object structure changes) on page 39.
There are 3 ways of deleting metadata:
 using the browser interface
Chapter 3. Defining metadata

35

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

 using the Developer Workbench tool


 deleting correspondig files in the IFS

3.3.1 Delete metadata via the web interface


1. On the folder where the metadata is located, right click, Metadata -> Edit (Figure 3-15).

Figure 3-15 Deleting metadata with web interface - Step 1

2. In the metadata pane right click on the metadata you want to delete and select Delete
(Figure 3-16 on page 37).

36

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-16 Deleting metadata with web interface - Step 2

3. You will receive a message asking you to confirm deletion. Click on OK.

3.3.2 Delete metadata via the Developer Workbench tool


Additional client server tool Developer Workbench can be used to create, edit and delete
synonyms.
1. Open Developer Workbench, select the system on which to work and validate with your
userid and password. Please remember that the user must be part of the DevWorkbench
group (use Administration -> Security Center in the web interface to set up).
2. Select Data Servers -> EDASERVE -> Applications -> <yourfoldr> and in the right hand
side of the panel select the metadata that you want to delete, as shown in Figure 3-17 on
page 38. Right click on the files highlighted and select Delete.
Note: Please notice that a metadata is made by two files, a .acx and a .mas. When
using Developer Workbench to delete a synonym only the .mas file need to be selected
- both .acx and .mas files will be deleted. If you select both you may get ar error
message - however the synonym gets correctly deleted.

Chapter 3. Defining metadata

37

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-17 Deleting metadata, Dev. Workbech - Step 1

3. You will receive a message prompting you to confirm delete. Select Yes (Figure 3-18).

Figure 3-18 Deleting metadata, Dev. Workbech - confirm

3.3.3 Deleting files in the IFS


1. From the System i command line, enter the following command:
WRKLNK OBJ('/qibm/UserData/qwebqry/apps/<myfolder>')
2. Select option 5 for directory <myfolder>.
3. Browse the <myfolder> directory for the metadata that you want to delete. When you find
it, select option 4 (Figure 3-19 on page 39) and press Enter to delete.

38

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Work with Object Links


Directory . . . . :

/qibm/UserData/qwebqry/apps/simona_10

Type options, press Enter.


2=Edit 3=Copy 4=Remove 5=Display
11=Change current directory ...
Opt

4
4

Object link
cen_inventory.acx
cen_inventory.mas
cen_orders.acx
cen_orders.mas
cen_orders_with_ri >
cen_orders_with_ri >
cen_plant.acx
cen_plant.mas
cen_stores.acx

Type
STMF
STMF
STMF
STMF
STMF
STMF
STMF
STMF
STMF

7=Rename

Attribute

8=Display attributes

Text

Figure 3-19 Deleting metadata via 5250

Note: Please remember that a metadata is made by two files, .acx and .mas. Both files
have to be selected if you want to delete the synonym with the IFS interface or commands!
To delete files in the IFS it is also possible to use CL command DEL. For instance to delete
metadata CEN_ORDERS in folder SIMONA_10 you would use
DEL OBJLNK('/qibm/UserData/qwebqry/apps/simona_10/cen_orders.*')
Using .* it is possible to catch both .acx and .mas files in one delete command.

3.4 Refreshing metadata (when IBM i database object structure


changes)
The database structure can be subject to changes, the application is updated:





new tables are defined


and/or existing tables get deleted
new columns are added to the table
or columns get deleted because they are not used any more.

What happens to metadata and the report that make inquiries on our data? This is a common
concern for many customers, what happens when the metadata gets out of synch with the
underlying data source? For example, if the database administrator alters a table and either
adds a new column or removes an existing one, do existing reports still run successfully? The
answer to this is that it depends. The synonym may need to be refreshed to reflect this
change. If none of your reports reference a column deleted from the underlying file, a
synonym refresh is not required. The same applies if you do not want to include the new
column in any existing or new reports. However, if the changes do impact your reports, you
must synchronize the synonym with the altered file. For this, you can use the new synonym
interface provided by DB2 Web Query, Developer Workbench or CL command CRTWQSYN.
Chapter 3. Defining metadata

39

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

The refresh option is only supported in these environments:


 Synonyms based on DB2 cli adapter:
The following adapters are NOT supported:
Query/400
JD Edwards
SQL Server
 *LOCAL databases only
no support for remote objects
 Supported file types:
Table
Physical File
SQL View
Logical file
Using the CRTWQSYN command, *ALL and generic (wildcard) search are supported in the
FILE parameter. Useful for refreshing ALL files in a library (or all files that start with ORD*).

3.4.1 Refreshing metadata via the browser interface


1. In the folder where the metadata was created select Metadata -> Edit as shown in
Figure 3-20.

Figure 3-20 Refresh Synonym - web - Step 1

2. You are taken into the Metadata management window. Right click on the synonym that
needs to be refreshed and select Refresh synonym as shown in Figure 3-21 on page 41

40

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-21 Refresh Synonym - web - Step 2

When this action is taken, the synonym is parsed and its contents are compared with the
structure of the actual underlying data source. New columns are added to the synonym and
deleted columns are removed. Any custom changes (joins, virtual columns, filters, OLAP
dimensions, and so on) that were made to the synonym are preserved.

3.4.2 Refreshing metadata with Developer Workbench


Additional client server tool Developer Workbench can be used to create, edit and delete
synonyms.
1. Open Developer Workbench, select the system on which to work and validate with your
userid and password. Please remember that the user must be part of the DevWorkbench
group (use Administration -> Security Center in the web interface to set up).
2. Select Data Servers -> EDASERVE -> Applications -> <yourfoldr> , in the right hand
side of the panel right click on the metadata that you want to refresh, and select Refresh
as shown in Figure 3-22 on page 42.

Chapter 3. Defining metadata

41

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-22 Developer Workbench - refresh synonym

3. You will be presented with a message box confirming that the sysnonym has been
refreshed, as shown in Figure 3-23. Select OK.

Figure 3-23 Developer Workbench - refresh completed

3.4.3 Refreshing metadata with command CRTWQSYN


As an alternative to the products browser interface the it is now possible to use command
CRTWQSYN in library QWEBQRY to perform metadata refresh (Figure 3-24 on page 44).
This command can be used from a 5250 interactive session, inserted in programs (to
automate and schedule a mass refresh action) or used with Job Scheduler.
The CRTWQSYN CL command has the following parameters:

42

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

FILE - Enter the name of the database file object to create the DB2 Web Query synonym
over.
SCHEMA - Enter the name of the database schema (library) which contains the files you wish
to create DB2 Web Query synonyms over. FILETYPE :
FILETYPE - When *ALL is specified for the file parameter, specifies what types of files are to
be searched for and included in the synonym creation process. Up to
four file types can be specified. EXCLSRCPF
EXCLSYSFL - When *ALL or a generic* value is specified for the file parameter, specifies
whether to exclude system files and catalogs when locating and
creating synonyms for the files in the specified schema.
EXCLSRCPF - When *ALL or a generic* value is specified for the file parameter, specifies
whether to exclude source physical files when locating and creating
synonyms for the files in the specified schema.
PREFIX - Specifies the prefix to append to the beginning of the synonym name. If you have
tables with identical table names, assign a prefix or a suffix to
distinguish them. For example, if you have identically named human
resources and payroll tables, assign the prefix HR to distinguish the
synonyms for the human resources tables.Note that the resulting
synonym name cannot exceed 64 characters.
SUFFIX - Specifies the suffix to append to the end of the synonym name. If you have tables
with identical table names, assign a prefix or a suffix to distinguish
them. For example, if you have identically named human resources
and payroll tables, assign the prefix HR to distinguish the synonyms
for the human resources tables. Note that the resulting synonym name
cannot exceed 64 characters.
APPFLR - Specify the name of the application folder where the synonym is to be created.
FRGNKEYS - Specifies whether the synonym should include foreign key relationship
definitions. If specified, the synonym being created will automatically
include every table related by a foreign key to the table specified inthe
FILE parameter. The resulting multi-table synonym describes all table
foreign key relationships.
QUALLIB QUALLIB - Specifies whether to generate a library qualified table name in the DB2
Web Query synonym Access file (.acx) for the specified table.
OPTION - Specifies what action to take if the specified synonym name (including prefix and
suffix) already exists in the specified application folder.
SHORTALIAS - When generating the table's column level information in the Master (.mas)
file, specifies whether to use the table's system (short) name for the
synonym's alias. This allows the DB2 Web Query report developer to
see and use both the SQL (long) name of the column as wellas the
system (short) name when using the report development tools.

Chapter 3. Defining metadata

43

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Create DB2 Web Query synonym (CRTWQSYN)


Type choices, press Enter.
File (table/view) name . . . . . FILE

> ANART00F

Schema (library) name

> PROVEOO

. . . . . SCHEMA

File type . . . . . . . . . . . FILETYPE


+ for more values
Synonym prefix . . . . . . . . . PREFIX
Synonym suffix . . . . . . . . . SUFFIX
Application folder . . . . . . . APPFLR

With foreign keys . . . . . . . FRGNKEYS


Include library qualificaion . . QUALLIB
Existing synonym option . . . . OPTION
Use field short name as alias .
*NO

> *TABLE
> POO_
*NONE
> SIMONA

*NO
*YES
> *REFRESH <<<<< NOTICE!!!
*YES, *NO

Figure 3-24 Refresh synonym using the CRTWQSYN CL command

Attention: The Refresh Synonym will not update the synonym for all database object
changes. For example, if column attributes such as data type or length are altered in the
database object, those changes are not applied to the synonym. For those types of
changes, the synonym must either be manually edited or recreated.

3.4.4 What happens to the metadata if the IBM i database object is deleted
If you delete the underlying database object or the QRYDFN object, the DB2 Web Query
report cannot run based on the metadata alone. If you attempt to run the report in DB2 Web
Query, you receive an error message. You have the option to recreate the table or QRYDFN
exactly as it was before. Therefore, you do not need to recreate the metadata. Or if you create
a new, yet slightly different object, you must create new metadata on that object. Or you
delete all report and underneath metadata if these info is not needed any more.

44

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

3.5 Miscellaneous considerations about creating metadata


The DB2 CLI adapter can create metadata on five different i5/OS object types:






Tables
Views
Aliases
Stored procedures
MQTs

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 be unable to tell which object type you are
using in your report.

3.5.1 Stored procedure synonyms


A stored procedure is a program or procedure in a service program that can be called by an
application using the SQL CALL statement. Stored procedures can be written in the SQL
procedural language, or you can use existing programs or service program procedures
(written in RPG, COBOL, JAVA, and so on) and register them to the database as stored
procedures.
When it comes to DB2 Web Query data sources to base their reports on, many developers
only use database objects like tables and views. But a very powerful, yet under-utilized
feature of DB2 Web Query is its ability to use a stored procedure as a data source, provided
that the stored procedure returns a result set. DB2 Web Query has the ability to capture that
result set and use it as the source data for a report.
When a DB2 Web Query synonym is created over a stored procedure, the result set is used
as the format for synonym. This means that all fields in the result set can be used as columns
in the report. In addition, the input parameters of the stored procedures can be used as input
parameters for the report. Consequently, you can pass parameter values from a report to the
stored procedure, let the procedure use those values to perform the business logic, and
return the results to the report.
This is a powerful technique because it gives the report developer programmatic control over
what is returned to DB2 Web Query. Consider the following ways that a stored procedure
could be used with the tool:
 Reuse and repurpose the business logic in your existing programs.You can take an
existing RPG program (or one written in any language supported by the IBM i), make small
modifications to return a result set, and register it to the database as a stored procedure.
This means that many existing reports generated by RPG programs could be converted to
work with DB2 Web Query. Comment out the header lines and change the details line to
write to a result set, temporary file, or array, rather than a print file record. By combining
DB2 Web Query with existing report programs, you can salvage proven business logic and
provide a modernized output format for those old reports.
 Use native record level access (RLA), instead of SQL, if you prefer that method of data
access.
 Provide the ability to call to other programs, commands, and system APIs as well as pull
data from other system objects such messages queues, data queues, or data areas.

Chapter 3. Defining metadata

45

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

 Provide a way to dynamically change the library list by passing an input parameter to the
stored procedure (and changing the library list based on that parameter value), then
execute the appropriate process to return the result set.
 Adopt authority of the user profile that owns the underlying program or service program.
This gives you the ability to restrict access to the database objects and only allow users to
access the objects through the programs (stored procedures) with adopted authority.
 Provide auditing capability. The stored procedure can include logic to insert a row in an
audit log table to record any report request. With so much attention given to security and
auditing these days (that is, Sarbanes-Oxley), this can be very important consideration,
especially for users who have access to sensitive information.
 Provide the ability to programmatically change attributes of the querying job. Examples of
what can be specified in a stored procedure to change the environment are:
SET CURRENT DEGREE to enable Symmetric Multi Processing (SMP) and boost
query performance of a long-running report if the requestor is an executive or other
high-profile user.
SET OPTION SRTSEQ to change the collating sequence of the report.
To illustrate how a stored procedure could be used, lets assume that you need to create a
report that returns rows from a sensitive table (the HR table) and you must add an auditing
feature to this report. That is, each time the report is run, information such as the time stamp,
name of the report, and requesting user profile must be logged to an audit table.
Note: This example uses material from the QWQCENT sample library - requested tables
and stored procedure may already be there.
To create a stored procedure that returns data from specific columns in the payroll table and
satisfies the auditing requirement take the following steps:
1. From an SQL interface such as System i Navigator Run SQL Scripts, create the audit
table:
CREATE TABLE qwqcent.rptaudlog (rpttimst TIMESTAMP, rptname CHAR(25),rptusrprf
CHAR(10))
2. From same SQL interface, create the stored procedure:
CREATE PROCEDURE qwqcent.hr_table_audit (inplantcode CHAR(3))
DYNAMIC RESULT SETS 1
LANGUAGE SQL
NOT DETERMINISTIC
MODIFIES SQL DATA
P1 : BEGIN
DECLARE c1 CURSOR WITH RETURN TO CLIENT FOR
SELECT lastname, firstname, status, payscale, salary
FROM qwqcent.hr
WHERE plantcode = inplantcode;
INSERT INTO qwqcent.rptaudlog VALUES(CURRENT TIMESTAMP,
'HR Salary Report', SESSION_USER);
OPEN c1 ;
END P1 ;
Several items must be pointed out for this store procedure:
 The cursor is declared with the WITH RETURN TO CLIENT clause specified. It is a good
idea to specify this clause to ensure that the result set is returned to the client application.
WITH RETURN TO CALLER is the default, which would cause problems in the event
46

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

that you had a nested stored procedure (a stored procedure called by another stored
procedure) that was actually returning the result set.
 The INSERT statement is specified to log the request. This satisfies the auditing
requirement.
 The cursor is opened (and left open). This returns a result set to the client application
(which is DB2 Web Query).
3. Check that your stored procedure is working
CAll PROCEDURE qwqcent.hr_table_audit (BOS);
The process for creating a stored procedure synonym is similar to that of creating a synonym
over a table. Take the following steps:
1. Right click on the folder where you want to create the synonym and select Metadata
New. You are presented with the synonym wizard, select the DB2 CLI adapter, right click
on *LOCAL and select Create synonym as shown in Figure 3-25.

Figure 3-25 Creating stored procedure synonym: Step 1

2. In the Select Synonym Candidates select Stored Procedure, type in the library name
(QWQCENT in our example) and select Next as shown in Figure 3-26 on page 47.

Figure 3-26 Stored Procedure synonym, select candidate

3. From the list of stored procedures displayed, select HR_TABLE_AUDIT, as shown in


Figure 3-27

Chapter 3. Defining metadata

47

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-27 Creating stored procedure synonym: Step 2

4. If the stored procedure has input parameters, you will be prompted to enter a valid value
for the input parameter. As demonstrated in Figure 3-28, specify a valid input parameter
value by taking these steps:
a. Select/check the INPLANTCODE parameter.
b. Specify ORL as the value for the input parameter. (This is a valid Plant Code value.)
c. Select Create Synonym.
Note: When the synonym is created, the stored procedure is called by DB2 Web
Query so that it can receive the result set. This is because it must store the format of
the result set in the synonym. Consequently, you must pass it a valid value for the
input parameter at this step.

48

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-28 Creating stored procedure synonym: Step 3

5. As shown in Figure 3-29 on page 49, a confirmation window is displayed to confirm that
the stored procedure synonym was successfully created. Close this window.

Figure 3-29 Stored procedure synonym created

For examples using stored procedure with DB2 Web Query see Chapter 19, Assignment
#14: Stored procedures in action on page 605.
Multiple result sets: DB2 Web Query supports the return of multiple result sets from the
stored procedure. In this case, it assigns a distinct segment name to the fields of each
separate result set.
Chapter 3. Defining metadata

49

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

3.5.2 Considerations with multimember files


SQL can only read data from the first member in a file. Perhaps you have run into this
situation when writing SQL queries on multimember files before. It is possible to use an SQL
alias to point to a member within a multimember file and then create a synonym against the
SQL alias. This way you will be able to use the DB2 CLI adapter to get to data in a member
and the SQL statement issued will be eligible for SQE.
An alias is a permanent i5/OS object that points to a specific member in a file. It is easy to
create, and after it exists, SQL treats the alias the same as it would a table. Simply substitute
the alias name in any query where you would put a table name.
An example of a CREATE ALIAS command in SQL is:
CREATE ALIAS QGPL/MYALIAS FOR QGPL/MULTI_MBR_FILE (MBR_NUM_2)
You can run this command in the Run SQL Scripts window of iSeries Navigator or in STRSQL
from the command line. STRSQL has a prompt for CREATE ALIAS that is intuitive.
You can create metadata on an alias as easily as you can on a regular table. Refer to
Creating metadata on page 25, which explains how to create DB2 Web Query metadata.

3.6 Joining database objects


In DB2 Web Query it is possible to define joins to other metadata (that refer to database
objects) at the report level as it was done in Query/400. This approach is still working, but it is
not very productive and it is error prone:
 if you need 2 tables to be joined in 150 reports you have to repeat this step 150 times
 in some of the previous mentioned 150 reports the join definition may be set incorrectly,
thus generating incorrect data in the report output.
To overcome these problems the person in charge with defining and mantaining metadata
(DBA role in the folder) may decide to define join relationships directly in the metadata, thus
developing metadata that are comprehensive of all the joins that can be needed in the various
reports - this is one of the great advantages provided by metadata in a reporting environment.
As an alternative, joins can be defined at the database level, creating SQL views to define the
joins and then building metadata on the SQL view.
If the table(s) on which metadata are created have referencial integrity relationship defined
the metadata creation wizard can detect that there are natural joins available among the
tables and have the capability to describe it in the metadata. Hence a single synonym will be
created, referencing all objects and their relationships. This is described in Benefit of using
referential integrity in DB2 Web Query on page 51.
If you do not have Referencial Integrity defined you can setup joins in metadata using either
the web interface or the Developer Workbech tool.
To summarize the different techniques:
 Join defined at DB level with in SQL view + metadata on view
 Join defined in the DB2 Web Query metadata layer automatically enforcing Referencial
Integrity rules
 Join defined in metadata using
web metadata editor

50

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Reference to existing synonym


Segment manually
Developer Workbench tool
Reference to existing synonym
Copy of existing synonym
Segment via metadata import
Segment manually
The various approaches, with relative advantages and disadvantages are described in the
following sections.
Note: One of the main concerns people usually have with creating complex metadata with
multiple join is about performance. This arises from the idea that access can be slow when
joining multiple database object.
Metadata is an abstraction layer, not the phisical data.
If in the report are included columns from just one segment, the subsequent SQL
statement that is generated by DB2 Web Query will only reference that single object - even
if the metadata used references many tables with their join relationship.
Think of these join as potential joins that only become effective when they are really
needed in reports.
On the other hand, when a join is needed it is already defined and ready to be used by
everyone who develops reports.

3.6.1 Referential integrity


In this section we explain the benefits to DB2 Web Query of having referential integrity
defined in the database. We begin by briefly explaining 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 the meaning of referential integrity, you are 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. That is, you are not allowed to
place an order for a product that is not confirmed to be in your inventory. The referential
constraint does not permit an entry into the orders table unless the entry has a value for
PROD-NUM in the inventory table. This prohibits unmatched, or orphan, entries in the Orders
table.
Tip: You can also think of the small dimension tables as parent tables, and the large fact
table as a child table. Do not let the part about the child table being larger confuse you.
Think of it as a parent that has many children. The constraint does not let the child be born
unless the parent already exists.

Benefit of using referential integrity in DB2 Web Query


When DB2 Web Query creates metadata, it recognizes files that are related through
referential integrity and brings them all in together in one piece of metadata. When you write
Chapter 3. Defining metadata

51

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

your report, you select a single synonym or table name that includes several files that are all
related to each other. You do not need to manually define all the table joins. In order to have
this convenience, you must have defined constraints on your tables.
If you do not currently have referential integrity in your database, we strongly recommend that
you consider implementing it. Not only does referential integrity aid in more effective report
writing in DB2 Web Query, but it also moves your business logic closer to the database level
to reduce the programming effort. You do not need to understand SQL to add constraints to
your database. You can do this easily by using iSeries Navigator. Referential integrity
constraints can be added to files that are created with DDS and CRTPF, or they can be added
to tables that are created with the CREATE TABLE statement.
Tip: If you want to add constraints by using the command line, use the ADDPFCST
command. If you want to add constraints by using SQL, use the CREATE TABLE or ALTER
TABLE statement.
The following brief example demonstrates how to set up referential integrity on our sample
QWQCENT database. The orders table is the fact table. The inventory, plant, and stores
tables are the dimensional tables. For our example, we set up referential integrity between the
orders table and the inventory table. An item must exist in the inventory table before it can
have a child in the orders table.
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 that no child entry is inserted into the table
unless an entry exists in the parent table.

Creating a primary key on INVENTORY field PROD_NUM


Open iSeries Navigator and follow these steps:
1. Expand the database container.
2. If the QWQCENT schema is not currently displayed, right-click Schemas and then Select
Database to display.
3. In the Select Schemas to Display window (Figure 3-30), in the Enter schema names field,
type Century and click Add. Then click OK.

Figure 3-30 Select Schemas to Display window

52

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

4. In the left navigation bar of iSeries Navigator, expand the QWQCENT schema and click
Tables. In the right pane, right-click the INVENTORY table and select Definition, as
shown in Figure 3-31.

Figure 3-31 Selecting the Definition Option

5. In the next window, from the tabbed selections, click the Key Constraints tab and then
click Add.

Chapter 3. Defining metadata

53

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

6. In the New Key Constraint window (Figure 3-32), complete these steps:
d. Under Constraint type, select the Primary Key radio button.
e. Under Available columns, select the ProductNumber field and click the Add arrow
button. Now the ProductNumber field is displayed under Selected columns. Click OK.

Figure 3-32 Key Constraints window

7. In the window that contains the various tabs (Figure 3-33), click OK.

Figure 3-33 Key Constraints tab showing the ProductNumber field

54

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

You are now finished creating the primary constraint on the Inventory table. Next, we go to the
orders table and create a referential constraint. Remember that the orders table checks the
inventory table to ensure that any new record also has a matching key value in Inventory.
1. Expand the QWQCENT schema and click Tables. Right-click the Orders table and select
Definition.
2. In the next window, click the Foreign Key Constraints tab. Click Add.
3. In the New Foreign Key Constraint window (Figure 3-34) complete these steps:
a. For table name, select Inventory.
b. Under Available Columns, select ProductNumber and click Add. We know that this is
the primary key on the inventory table because it is indicated under Key columns near
the top of the window on the right. Click OK.

Figure 3-34 New Foreign Key Constraint window

You are now finished creating the referential constraint between the inventory and orders
tables. You can 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 as it did for the inventory table.
After you are done creating the other two referential constraints, your database is now ready
for metadata creation.

Chapter 3. Defining metadata

55

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

3.6.2 Creating metadata on tables with referential integrity


The process to import a cluster of related tables into one piece of metadata is similar to
creating a single piece of metadata. Refer to Chapter 3.2.1, Creating metadata with the web
interface on page 26 for detailed instructions.
1. In the Create Synonym pane (Figure 35), notice the With foreign keys check box at the
top of the page. This is the only difference in the process. You must check the With
foreign keys check box, so that the related tables are included in the same piece of
metadata.
Then the only table that you have to select is the fact table, which in our example library is
ORDERS. The dimension tables are automatically included. Then click Create synonym.

Figure 35 Creating metadata with referential integrity

2. Next the Status pane (Figure 3-36) is displayed, on which you see the status message
Created successfully. Notice that there is only one piece of metadata. You can close this
panel selecting Finish.

56

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-36 Created successfully message

As we have already mentioned, this one synonym includes references to all of the tables
connected by referential integrity relationship, specifying the join relationships. A synonym
that includes joins can be referred to as a clustered synonym. When you first start to write the
report based on the file cluster, you are presented with the metadata window: the related files
are all under one name. The description says Cluster xxx for table yourFactTable, as in
Figure 3-37. The word Cluster in your metadata indicates that referential integrity has been
used to create that metadata. All the related dimension tables with referential constraints
defined appear in the development tool, Info Assit.

Figure 3-37 Cluster: metadata with referential integrity

3.6.3 Creating metadata over tables without referential integrity


While there are many advantages to implementing referential integrity, many existing DB2 for
IBM i production databases currently do not have RI set up. This means that soem activities

Chapter 3. Defining metadata

57

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

have to be performed to define the relationship to set up the join between objects. The
following three options are viable if tables must be joined together:
 Define join in SQL views
 Define join in the DB2 Web Query metadata layer
 Define join in the reports and graphs
Each of the above options is discussed in the following sections.

3.6.4 Defining joins in SQL views


An SQL view is a virtual table whose definition is based on a SELECT statement. In
traditional i5/OS terms, they can be thought of as non-keyed logical files. Because there are
no keys associated with views, there is no access path maintenance. This means that you
can create as many views as you like and not worry about performance repercussions
associated with access plan maintenance.
SQL views are can be used to join tables together, present only some columns, define
derived columns, aggregate data and so on. This way report development can be simplified
and only desired data are presented for reporting, masquerading the database complexity
and/or avoiding exposing sensitive data when unnecessary. Once the view is created DB2
Web Query metadata can be created over the view (instead of the base tables). Reports
using that synonym can access any of the columns from each of the join segments defined in
the view. Using reports based on SQL views provides several distinct advantages to DB2
Web Query, including the following:
 Encourages database optimization (pushes logic down to DB2)
 Provides method for implementing more complex reporting requirements such as row and
column-level security
 Provides additional join types, unions, intersects, excepts, Common Table Expressions,
complex business logic (case statements, and so on)
 Data-centric because business logic and rules can be defined in one place (at the
database level) rather than the application level
In addition, SQL views can be accessed by other interfaces such as RPG programs (with
embedded SQL or native Record Level Access), ODBC, JDBC, and so on.
In Example 3-1 we illustrate an SQL View that could be leveraged by DB2 Web Query.
Example 3-1 SQL View definition

CREATE VIEW ORDERSVIEW


(ORDERNUMBER FOR COLUMN ORDER_NUM,
PRODUCTNUMBER FOR COLUMN PROD_NUM,...)
AS SELECT a.*, b.*, c.*, d.* FROM orders a
INNER JOIN stores b
ON a.storecode = b.storecode
INNER JOIN inventory c
ON a.prod_num = c.prod_num
INNER JOIN plant d
ON a.plantcode = d.plantcode
A synonym created over the example SQL view would contain all of the columns in the joined
tables.

58

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

You create a synonym over an SQL view in the same way as you do with tables - see
Chapter 3.2, Creating metadata on page 25 for detailed instructions.

3.6.5 Defining joins in DB2 Web Query synonyms


You can also define the relationship among files in the DB2 Web Query metadata. When this
technique is employed, DB2 Web Query join syntax is stored in metadata and translated to an
SQL statement with join syntax. Because the joins are defined at the synonym level, you only
must do this in one place. Every report that uses this synonym will have access to the join
logic already defined, thus it is not necessary to define joins in each report. This is an
example of the power of the metadata abstraction layer.
Consider the following when using this technique:
 Can be accessed by all DB2 Web Query reports and graphs that use the synonym. It is
not accessible from any other SQL interface.
 Simply defining the join in a metadata does not force a join at execution time if columns
from the other table(s) are not used in the report.
 Performance could suffer if logic is not pushed down to database due to database
optimization disablers. For more information about this see Chapter 23.5.2, Performing
analysis and looking for optimization disablers on page 746.
Before you begin this exercise, you must have a basic understanding of the different types of
joins that DB2 Web Query supports:
 Multiple (SEGTYPE=S0)
Indicates that the segment has no key field and is therefore not sorted. Keys and
sequences are defined in the access file. With the multiple segment type, each joined file
is represented as an individual join segment. If no matching row is found based on the join
criteria, no row is returned to the join. This prevents something called the multiplicative
effect, but also does not allow a developer to write a report that sorts (or performs a
combination of sorting and selecting) across the different segments.
 Unique (SEGTYPE=U)
For each join definition. Every child segment becomes logically part of the parent. At least
one row will be retrieved, regardless of whether a matching row was found. If there is a
one-to-many relationship between parent and child, all children will be returned (despite
the name Unique, which indicates a one-to-one relationship). Since the child becomes an
extension of the parent, the result is one virtual segment. This provides the ability to sort
and select fields across the underlying segments, but could also result in a report that
delivers incorrect results due to the multiplicative effect.
For this exercise, we are not concerned about the multiplicative effect. Therefore, Unique join
types are defined.
Another very important concept is on how synonym are linked one into the other. Basically
four different approaches are available:
 Reference to existing synonym means that the content of the second (joined)
metadata is just referenced in the main one (joiner). The joined synonym must still exist
and can be updated/refreshed. These changes are reflected in the joiner (are or can?
requires manual refresh?).
 Copy of existing synonym means that the content of the second (joined) metadata is
copied in the main one (joiner). The joined synonym can be deleted if it is not used

Chapter 3. Defining metadata

59

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

stand alone. If the joined synonym is updated/refreshed these changes are not reflected
in the joiner.
 Add segment via metadata import enables you to add reference to a new object using
the Create Synonym tool. This tool includes in the existing synonym the reference to
another object and describes its content. The result is just one synonym definition, the
pre-existing one, that includes all definition needed to access multiple objects.
 Add segment manually implies coding the reference manually, i.e. describing not only
the location of the joined object and the join relationship, but also all columns that are in
the objects. This is a very cumbersome task and highly error prone, hence it is not
recommended.
All of the various approaches described are available when using the Developer Workbench
tool, while when using the web interface only Reference to existing synonym and Add
segment manually are available.

Define join in metadata using the web interface


Here it is documented how to define a join in the web interface, using the Reference to
existing synonym capability. Please notice that with this tecnique all of the synonyms must
exist and have to be mantained. The result can be a proliferation of synonyms that make
maintenance more difficult. In our example we will be joining together some synonyms we
have already created, CEN_ORDERS, CEN_INVENTORY, CEN_PLANT and
CEN_STORES.
1. In your folder select Metadata -> Edit.
2. Double click on the metadata you want to enrich with a join, cen_orders in our example
(Figure 3-38).

Figure 3-38 Edit in Synonym Editor

The cen_orders master file is opened in the synonym editor.


3. Right-click the CEN_ORDERS segment and select Insert Reference to Existing
Synonym, as shown in Figure 3-39.

60

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-39 Add join segment to synonym

The list of existing synonyms is presented.


4. From the presented list, select the cen_inventory synonym, as shown in Figure 3-40 and
click the Next button.

Chapter 3. Defining metadata

61

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-40 Select synonym to add

The segment CEN_INVENTORY is added under CEN_ORDERS.

62

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

5. Select the CEN_INVENTORY segment and, in the right hand part of the pane, set
relation, type and conditions of the join (Figure 3-41).

Figure 3-41 Specify join properties

Chapter 3. Defining metadata

63

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

6. To help with defining the conditions start the calculator using the little dotted button on
the right of the field to set the join. PRODUCTNUMBER is the field that is used to join
ORDERS to INVENTORY. Select this field on the ORDERS table, it gets inserted in the
calculator panel, select the = symbol and then select the PRODUCTNUMBER filed in the
INVENTORY table. When you are done select OK (Figure 3-42 on page 64).

Figure 3-42 Specify join condition

Note: Once you have set the relation to one-to-one , the icon next to the
CEN_INVENTORY segment becomes a red color.

7. Once the relationship is defined click on Apply, at the top on the pane (Figure 3-43 on
page 65).

64

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-43 Join properties

8. Repeat step 3 on page 60 to step 7 for the CEN_STORES segment. The join field for this
join is STORECODE.
9. Repeat steps 3 on page 60 to step 7 for the CEN_PLANT segment. The join field for this
join is PLANTCODE.

Chapter 3. Defining metadata

65

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

10.At this point you have created a cluster for the ORDERS table. Notice that the access file
has been updated to mention all the tables that have been described to be connected. The
segments of this cluster should look like the example shown in Figure 3-44.

Figure 3-44 CEN_ORDERS with all join segments

11.Save your work by selecting the control icon on the top left hand corner of the pane and
selecting Save, as shown in Figure 3-45.

Figure 3-45 Save synonym

Note: creating a cluster synonym has no negative effect when querying data. The SQL
statement is composed to reference ONLY the tables whose columns are queried, not all
the tables that are defined in the synosym.

66

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Define join in metadata with Developer Workbench


Developer Workbench is described in 16.5, DB2 Web Query Developer Workbench on
page 494.
It gives a very powerful interface to interact with metadata, in a more grafical way than with
the web interface included in the base product and with more options and functions.
The differences among the different join options have already been discussed in
Chapter 3.6.5, Defining joins in DB2 Web Query synonyms on page 59. Here we will
document how to add a join using two different techniques, copy of existing synonym and
segment via metadata import. These techniques are only available with Developer
Workbench at the time when this redbook was written. Things may change over time.

Join - copy of existing synonym


1. Open Developer Workbench, select the system on which to work and validate with your
userid and password. Please remember that the user must be part of the DevWorkbench
group (use Administration -> Security Center in the web interface to set up). Select
Data Servers -> EDASERVE -> Applications -> <yourfoldr> as shown in Figure 3-46.

Figure 3-46 Join in Developer Workbench - Step 1

2. Double click on the synonym you want to enrich with join relationships to open it. In our
example we will change CEN_ORDERS to add joins with the INVENTORY, PLANT, and
STORES tables. Since we will be using copy of existing synonym the synonyms for these
tables must already exist.
3. Right click on the main segment name, CEN_ORDERS in our example, and select Insert
-> Copy of Existing Synonym (Figure 3-47).

Chapter 3. Defining metadata

67

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-47 Join in Developer Workbench - copy of existing synonym - Step 1

4. You are presented with a list of synonyms available in the folder where you started to work.
Highlight CEN_INVENTORY and click on Select (Figure 3-48 on page 69). if the synonym
you want to use resides in a different folder locate it using the Look in box at the top of the
screen.

68

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-48 Join in Developer Workbench - copy of existing synonym - Step 2

5. On the left hand part of the pane notice the join option. The options can be edited and
changed where it is necessary using the pull downs and the list items on the side of each
definition. In Figure 3-49 on page 70 you can see what we have selected:
Relation = One-to-One
Type = Inner Join
Condition
CEN_ORDERS.PRODUCTNUMBER=CEN_INVENTORY.PRODUCTNUMBER

Chapter 3. Defining metadata

69

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-49 Join in Developer Workbench - copy of existing synonym - Step 3

6. If you want to get a graphical view of the relationship select the Modeling View tab at the
bottom of the screen and hover over the arrow between the tables as shown in
Figure 3-50.

Figure 3-50 Join in Developer Workbench - copy of existing synonym - Step 4

7. When the line connecting the two files is dotted it means that some elements are missing
in the join definition. You can always see and edit the join conditions right clicking on the
line and selecting join properties, as shown in Figure 3-51 on page 71.

70

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-51 Join in Developer Workbench - copy of existing synonym - edit condition

8. Save the change using the save icon on the tool bar. You may receive a message
regarding a warning condition (Figure 3-52 on page 71), select OK to continue saving.

Figure 3-52 Join in Developer Workbench - copy of existing synonym - error message on save

This error message is caused by one of the columns in the Orders tables, which is named
RETURNS. This is a reserved word in SQL. If you want to get rid of this message rename the
field as shown in Figure 3-53 on page 72 and save again.

Chapter 3. Defining metadata

71

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-53 Rename field

Note: Rename in the FIELDNAME (the name used by DB2 Web Query). If you change the
ALIAS the metadata will not work any more. Against logic, the term ALIAS is used to refer
to the actual column name in database!
Repeat the process for CEN_PLANT and CEN_STORES to get the full environment.
After COPYING the synonym the original CEN_INVENTORY, CEN_PLANT and
CEN_STORES can be deleted unless you want to use them for other purposes.
Please remember that if your report only reference columns in one segment (table) the
product will generate an SQL statement to reference that one object even if the metadata
used has references to multiple segments.

Join - segment via metadata import


1. Open Developer Workbench, select the system on which to work and validate with your
userid and password. Please remember that the user must be part of the DevWorkbench
group (use Administration -> Security Center in the web interface to set up). Select
Data Servers -> EDASERVE -> Applications -> <yourfoldr> as shown in Figure 3-54
and double click on the .mas file of the synonym you want to edit.

72

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-54 Join in Developer Workbench - Step 1 - Import

2. Right click on the segment to which you want to add a join and select Insert -> Segment
via metadata import (Figure 3-55 on page 73).

Figure 3-55 Join in Developer Workbench - Import - Step 2

3. You are presented with a panel where to choose the data source. Select *LOCAL as
shown in Figure 3-56 and click on OK.

Chapter 3. Defining metadata

73

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-56 Join in Developer Workbench - Import - Step 3

4. Set the name of the library - QWQCENT - and select Next (Figure 3-57 on page 74).

Figure 3-57 Join in Developer Workbench - Import - Step 4

5. select the table you want to join in, INVENTORY in this example, and click on Create
Synonym (Figure 3-58 on page 75).

74

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-58 Join in Developer Workbench - Import - Step 5

6. You will get a message saying that the segment has been created succesfully. Click on
Close to get back to the synonym editor.
7. In the synonym editor you are presented with the option to edit the join relationship. The
options can be edited and changed where it is necessary using the pull downs and the list
items on the side of each definition. In Figure 3-59 on page 76 you can see what we have
selected:
Relation = One-to-One
Type = Inner Join
Condition
CEN_ORDERS.PRODUCTNUMBER=CEN_INVENTORY.PRODUCTNUMBER
(calculator can be used to define join condition, as documented in Appendix , Join copy of existing synonym on page 67)

Chapter 3. Defining metadata

75

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-59 Join in Developer Workbench - Import - Step 6

8. If you want to get a grafical view of the relationship select the Modeling View tab at the
bottom of the screen and hover over the arrow between the tables as shown in
Figure 3-60.

Figure 3-60 Join in Developer Workbench - import - Step 7

9. Save the change using the disc icon on the tool bar. You may receive a message regarding
a warning condition (Figure 3-61 on page 77), select Ok to continue saving.

76

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-61 Join in Developer Workbench - import - error message on save

This error message is caused by one of the columns in the Orders tables, which is named
RETURNS. This is a reserved word in SQL. If you want to get rid of this message rename the
field as shown in Figure 3-62 and save again.

Figure 3-62 Rename field

Note: Rename in the FIELDNAME (the name used by DB2 Web Query). If you change the
ALIAS the metadata will not work any more. Against logic, the term ALIAS is used to refer
to the actual column name in database!
Repeat the process for tables PLANT and STORES to get the full environment.
Please remember that if your report only reference columns in one segment (table) the
product will generate an SQL statement to reference that one object even if the metadata
used has references to multiple segments.

Chapter 3. Defining metadata

77

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

3.7 Date decomposition


In our ORDERS table there is a date column, ORDERDATE. We want to be able to use its
primary logical elements (YEAR, MONTH, QUARTER, DAY) when reporting. This is very
usefull when we have to aggregate and compare elements based on the date basic
components (i.e. compare sales for year xx, on a quarter basis) without having to code
complex formulas and calculation in our reports and we want these functionalities to be
available to all report developers without any hassles.
To overcome this situation DB2 Web Query provides a DATE DECOMPOSITION funtionality,
really easy to implement. This can be obtained both with the web interface or using the
Developer Workbench tool.
In the latest releases of DB2 Web Query, applying the date decomposition function the date
transformation gets pushed to the database level, applying to appropriate SQL function on the
date field - for instance, if you want to use the year portion of the orderdate field in a report,
you will see YEAR(ORDERDATE) coded in the underneath SQL statement. This may lead to
significant performance improvements when compared to the previous releases, when this
request would have lead to a transformation at a higher level.
Either the web interface or the Developer Workbech tool can be used to decompose date
fields. Here we will present both, for your reference.
Note: It is now possible to get a field decomposed automatically while building a DATE
DIMENSION - refer to Chapter 3.12, Defining dimensions - InfoMini & OLAP on
page 124.

3.7.1 Date decomposition with web interface


In our sample database in the ORDERS table we have a date field, ORDERDATE, from which
we want to gather basic elements, YEAR, QUARTER, MONTH and DAY. To decompose the
ORDERDATE date field with the web interface:
1. Right click on folder Century Electronics and select Metadata -> Edit as shown in
Figure 3-63

78

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-63 Date decomposition - Step 1

2. Right click on cen_orders and select Open (Figure 3-64 on page 79).

Figure 3-64 Date decomposition - Step 2

3. The synonym editor opens up. Right click on field ORDERDATE and select Decompose
Date (Figure 3-65)

Chapter 3. Defining metadata

79

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-65 Date decomposition - Step 3

4. The synonym gets updated with four new field representing the date base component, as
shown in Figure 3-66.

80

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-66 Date decomposed

3.7.2 Date decomposition using Developer Workbench


To decompose a date field using the Developer Workbench synonym editor:
1. Open Developer Workbench, select the system on which to work and validate with your
userid and password. Please remember that the user must be part of the DevWorkbench
group (use Administration Security Center in the web interface to set up - see
Chapter 4, Security Center on page 147). Select Data Servers EDASERVE
Applications <yourfolder> and double click on the .mas file of the synonym you want
to edit.
2. In your synonym right click on the field date to be decomposed (ORDERDATE in this
example) and select Decompose Date as shown in Figure 3-67 on page 82.

Chapter 3. Defining metadata

81

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-67 Decompose date with Developer Workbech - Step 1

3. You are presented with a panel (Figure 3-68) where you can select the decomposition
items: Day, Month, Quarter and Year. Select OK.

Figure 3-68 Decompose date with Developer Workbech - Step 2

4. In Figure 3-69 on page 83 you can see the decomposition results. Save your synonym and
exit.

82

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-69 Decompose date with Developer Workbech

3.8 Understanding your data


To make your reporting successfull you have to know and understand your data:
 how many rows in tables?
 how many rows for any differentiator in your tables (% and total numbers)? Even or
uneven distribution?
 what are the relationship between tables?
There are instances where the report developers may not have a good understanding of the
data they are dealing with, and this may lead to unexpected results.
To help developers with understanding the data structure DB2 Web Query provides some
nice features, both in the web interface and in Developer Workbench.
Here we show them to you using the web interface.
Right click on the synonym you want to analyze, as shown in Figure 3-70 on page 84.
Notice the following options:

Chapter 3. Defining metadata

83

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

 Sample Data
 Data Profiling
Statistics
Count
Key Analys

Figure 3-70 Web Interface - understanding your data

In Figure 3-71 you can see the SAMPLE DATA output.

Figure 3-71 Sample Data output

In Figure 3-72 on page 85 you can see the STATISTICS output.

84

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-72 Web Interface - Statistics

In Figure 3-73 you can see the COUNT output.

Figure 3-73 Web Interface - Count

Similar functions are available in Developer Workbench.

Chapter 3. Defining metadata

85

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

3.9 Field formatting


It is very common that to present information nicely you may need to change fields default
formatting (decimal, thousands delimiters, currency symbol, titles...). This can be done report
by report (but it can be a very cumbersome task!) or you can exploit the power of metadata
and just do it once in the synonym and enjoy the new formatting in all of the reports where the
synonym is used.
You can use either the web interface or the Developer Workbench tool. Here, for your
reference we will present both ways.

3.9.1 Field formatting with the web interface


In our example data library QWQCENT/ORDERS we have a LINETOTAL field that is defined
as Decimal field. However, in our reports we prefer it to be presented as an INTEGER, with
thousands delimiters and the $ currency symbol. Plus we are in a multilingual environment
and we want to provide titles in different languages, according to the various users
preferences.
To change the way the LINETOTAL field is presented:
1. In the web interface select the folder where the synonym is located, right click and select
Metadata Edit.
2. Locate the synonym you want to edit in the list, double click on it or right click on it and
select Open as shown in Figure 3-81.

Figure 3-74 Open synonym with web interface

3. You are presented with a panel with all the existing field. Double click on the LINETOTAL
field. On the right hand side of the panel you will be presented with all details on the
selected field, starting from the Property View tab, as shown in Figure 3-75 on page 87.
86

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-75 Web inteface - format field 1

4. Here you can make all the changes required. In the USAGE portion set the field to show
as a INTEGER (#1), 11 digits long (#2) then select Comma (#3) and Floating $ (#4).
Select the Apply button to confirm your changes, as shown in Figure 3-76 on page 88.
Note: Only change the USAGE portion - if you change the ACTUAL section you end up
with a database mismatch!

Note: the appearence of the thousands delimiter depends on your regional/national


settings. Even if the caption says comma you will get a . as your delimiter if have a
european environement setting.

Chapter 3. Defining metadata

87

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

1
2

Figure 3-76 Web Inteface, format field 2

5. We also want to set up the title to show up in the language preferred by each user. To do
this select the little dotted button on the side of the TITLE field (# 6 in Figure 3-76). You are
presented with a new panel (Figure 3-77 on page 89) where you have to
a. select the language you are adding from the pulldown
b. select the ADD button to add the selected language
c. key in the appropriate text
d. repeat the process for all the languages you need
e. select OK to get back to the PROPERTY VIEW

88

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-77 Web interface - add multilingual titles

6. In the PROPERTY VIEW tab select APPLY to confirm your change.


7. Click on the More Options and select SAVE to save your changes to the synonym, as
shown in Figure 3-78.

Figure 3-78 Web interface - save synonym

3.9.2 Field formatting with Developer Workbench


To format a field with Developer Workbench:
1. Open Developer Workbench, select the system on which to work and validate with your
userid and password. Please remember that the user must be part of the DevWorkbench
group (use Administration Security Center in the web interface to set up - refer to
Chapter 4.1.2, Security Concepts on page 148. Select Data Servers EDASERVE
Applications <yourfolder> and double click on the .mas file of the synonym you want
to edit.
2. In your synonym right click on the name of the field you want to format (LINETOTAL in this
example) and select properties or just double click on it. In the PROPERTIES pane locate
the USAGE portion - see Figure 3-79 on page 90. Set the field to show as a INTEGER
(#1), 11 digits long (#2) then select Comma (#3) and Floating $ (#4).

Chapter 3. Defining metadata

89

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Note: Only change the USAGE portion - if you change the ACTUAL section you end up
with a database mismatch!

Note: The appearence of the thousands delimiter depends on your regional/national


settings. Even if the caption says comma you will get a . as your delimiter if have a
european environement setting.

1
2

Figure 3-79 Developer Workbench, formatting LINETOTAL field

3. We also want to set up the title to show up in the language preferred by each user. To do
this select the little dotted button on the side of the TITLE field (# 5 in Figure 3-79). You are
presented with a new panel (Figure 3-80 on page 91) where you have to
a. select the language you are adding from the pulldown
b. select the ADD button to add the selected language
c. key in the appropriate text
d. repeat the process for all the languages you need

90

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-80 Developer Workbench - formatting title for field LINETOTAL

4. select OK to get back to the PROPERTY VIEW


5. When you are done save your synonym using the SAVE icon in the tool bar. Close your
synonym.

3.10 New fields - Define vs Compute


There are two types of calculated fields in DB2 Web Query, DEFINE and COMPUTE.
When you use the define field, you add the definition to the list of fields within the table. This
field is calculated every time that a record is read and selected.
When you create a compute field, the field is not calculated until after the data is sorted and
all aggregation is complete. Compute fields are often required for percentages and variances.
Note: A computed field is a field whose calculation are performed not on each row that
enters in the data set but in the final step, after needed basic data have already been
aggregated together. In some cases this can make a difference. Lets say we want to
calculate a percentage on revenue by country. To calculate the percentage on each
LINETOTAL row and then sum each percentage is very different than summing all rows by
country and then calculate each country percentage.
Both type of fields can be created in the synonym to:
 ensure consistency accross reports
 shield report developers from data definition complexity
 make report development quicker and easier

Chapter 3. Defining metadata

91

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

New fields can accomplish very sofisticated and complex tasks. In them you can use:
 arithmetic operators (+, -, *, /)
 concatenation (| or ||)
 comparison operators (EQ, NE, LE, GE, LT, GT)
 logic operators (IF, THEN, ELSE, AND, OR, NOT)
 Upper/Lower case (a A, A a)
 Date / Datetime
 transformation and decoding functions provided by DB2 Web Query (full documentation
available in the products manual Using Functions, downloadable from the DB2 Web
Query wiki page
Note:
DB2 Web Query wiki URL:
https://www.ibm.com/developerworks/mydeveloperworks/wikis/home/wiki/W516d8b60d
32c_4fc5_a811_5f3d840bf524?lang=en
"Using Functions" Manual:
https://www.ibm.com/developerworks/mydeveloperworks/wikis/home?lang=en#/wiki/W
516d8b60d32c_4fc5_a811_5f3d840bf524/page/Functions

 system functions (current date & time, system variables, current user...)
Though new calculated fields (defined and computed) may be created at the report level, we
strongly encourage you to exploit the power of metadata creating them in synonyms.
Moreover, some of the above listed functionalities may only be available when using the
Developer Workbench to create a new field.
Generally speaking either the web interface or the Developer Workbech tool can be used to
create define and compute fields, though the two interface can have different capabilities in
some cases. Here we will present both ways of doing things, for your reference.

3.10.1 Define field - web interface


We want a new PROFIT field, that calculates (LINETOTAL - COSTOFGOODSOLD). This will
be used in many reports, hence it is worth while creating it once in metadata and make it
available for all development needs.
To create a new define field in the web interface:
1. In the web interface select the folder where the synonym is located, right click and select
Metadata Edit.
2. Locate the synonym you want to edit in the list, right click on it and select Open as shown
in Figure 3-81.

92

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-81 Open synonym with web interface

3. You are presented with a panel with all the existing field. Right click on the segment name
and select Insert Define (Figure 3-82 on page 93) or alternatively go to the end of the
list of fields and click on the little folder icon you find in it that says Constant
Define/Compute to create a new field.

Figure 3-82 Create a new define field - web inteface - Step 1

4. Type the desired field name in Define, here we use PROFIT (see #1), and then click on
the little dotted button on the right of Expression (see #2) as shown in Figure 3-83.

Chapter 3. Defining metadata

93

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

1
2

Figure 3-83 Define field

5. You are presented with a calculator where you can setup your formula (see Figure 3-84).
Drag the LINETOTAL (#1) field in the expression box, click on the - symbol (#2) then drag
the COSTOFGOODSSOLD (#3) field in the expression box. Click on OK.

94

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

1
3

Figure 3-84 Define Field calculator

6. Finish defining and formatting your field. Select Apply when you are done. Please refer to
the online help for the various formatting capabilities. In this example (Figure 3-85 on
page 96) to get a title, numeric field, 11 digits long with thousands separator and the
currency symbol we have used:
a. Title - Gross Profit
b. Type - Integer
c. Lenght - 11
d. Comma - C
e. Currency symbol - M

Chapter 3. Defining metadata

95

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-85 Formatting options

7. You will notice that your new field is added to the list of the available fields for the segment
(Figure 3-86 on page 97).

96

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-86 Fields list

8. Right click on the Other options icon and select Save as shown in Figure 3-87.

Figure 3-87 Save synonym

3.10.2 Define field - Developer Workbench


We want a new PROFIT field, that calculates (LINETOTAL - COSTOFGOODSOLD). This will
be used in many reports, hence it is worth while creating it once in metadata and make it
available for all development needs.
To create a new define field with Developer Workbench:
1. Open Developer Workbench, select the system on which to work and validate with your
userid and password. Please remember that the user must be part of the DevWorkbench
group (use Administration Security Center in the web interface to set up - see
Chapter 4, Security Center on page 147). Select Data Servers EDASERVE

Chapter 3. Defining metadata

97

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Applications <yourfolder> and double click on the .mas file of the synonym you want
to edit.
2. In your synonym right click on the segment name (ORDERS in this example) and select
Insert Define as shown in Figure 3-88 on page 98. Another way of doing this would be
selecting the fx - Define icon from the tool bar.

Figure 3-88 Define Field, Developer Workbench

3. You are presented with the Define Calculator (Figure 3-89 on page 99). Type in the field
name (#1) and a title (#2). Drag (or double click) the LINETOTAL field to the calculator
area (#3), click on the - symbol (#4) and drag the COSTOFGOODSOLD filed to the
calculator (#5).

98

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

4
3
5

Figure 3-89 Developer Workbench - Define Calculator

4. Now you can check the data resulting from your formula using the Sample Data button on
the top right side of the pane as shown in Figure 3-90 on page 100.

Chapter 3. Defining metadata

99

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-90 Developer Workbench - Define Calculator - Sample data

5. You may now want to format your field. Click on the dotted button next to the format field
and you will be presented with the fomatting pane (Figure 3-91 on page 101) - select OK
when you are done. In this example to get a numeric field, 11 digits long with thousands
separator and the currency symbol we have used:
a. Type - Integer
b. Lenght - 11
c. Comma - C
d. Currency symbol - M

100

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-91 Developer Workbench - Define Calculator - Format options

6. Select OK to close the Define Calculator and save your synonym.


Developer Workbench provides you with more options that the web interface. Please notice
the Function tab in the Define Calculator, as shown in Figure 3-92 on page 102. From there
you can get to all of the DB2 Web Query functions. For documentation please refer to the
"Using Functions" manual, downloadable for the DB2 Web Query wiki.
Note:
DB2 Web Query wiki URL:
https://www.ibm.com/developerworks/mydeveloperworks/wikis/home/wiki/W516d8b60d32
c_4fc5_a811_5f3d840bf524?lang=en
"Using Functions" Manual:
https://www.ibm.com/developerworks/mydeveloperworks/wikis/home?lang=en#/wiki/W516
d8b60d32c_4fc5_a811_5f3d840bf524/page/Functions

Chapter 3. Defining metadata

101

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-92 Developer Workbench - functions

3.10.3 Compute field - web interface


As stated computed field is a field whose calculation are performed not on each row that
enters in the data set but in the final step, after needed basic data have already been
aggregated together.
We now want to create a new MARGIN field, to calculate the gross profit margin, expressed
as (((LINETOTAL - COSTOFGOODSSOLD) / COSTOFGOODSSOLD) *100). In the previous
section we have defined a new PROFIT field (LINETOTAL - COSTOFGOODSSOLD) and we
can now use it in our PROFIT definition: ((PROFIT / COSTOFGOODSSOLD) *100)
Note: Please notice that the order in which things are created is important to DB2 Web
Query.
If you want to reference field XX in field YY, XX MUST have already been described when
you describe YY or YY will not work!
To create a new compute field in the web interface:
1. Right click on folder Century Electronics and select Metadata -> Edit as shown in
Figure 3-93.

102

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-93 Web Interface - Edit Metadata

2. Right click on cen_orders and select Open (Figure 3-94)

Figure 3-94 Web Interface - open metadata

3. The synonym editor opens up. Right click on segment ORDERS and select Insert
Compute (Figure 3-95 on page 104).

Chapter 3. Defining metadata

103

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-95 Web Interface - Insert Compute field

4. You are presented with the Synonym editor, Figure 3-96. Type in a name and a title for the
new field, MARGIN (1#) and Gross Profit Margin (2#) in this example, then click on the
dotted button on the Expression field.

1
3
2

Figure 3-96 Web interface - compute field

5. You are presented with a calculator where to input the formula for your new field. Double
click on the field you need to get them in the calculator or just type in it. Usually it is better
to select fields to preventy typos. Scroll the list till you get at the PROFIT field (#1), double
click on it to select, double click on the / symbol (#2), double click on
104

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

COSTFGOODSSOLD (#3) then type in *100 as shown in Figure 3-97 on page 105. When
you are done select OK.

Figure 3-97 Web Interface - Compute field calculator

6. Make sure the format options are consistent with the data you are handling, change type,
lenght and any other options according to needs as shown in Figure 3-98 on page 106.
Here we have also selected the %sign to be shown in our field. When you are done select
Apply.

Chapter 3. Defining metadata

105

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-98 Web Interface - Format Compute field

7. Your new compute field will appear in the Constant Defines/Computes folder at the bottom
of the list. Selecting it you will be presented with its properties in the right hand side of the
pane. Select the Other options icon and Select, as shown in Figure 3-99 on page 107.

106

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-99 Web Interface - Save synonym

3.10.4 Compute field - Developer Workbench


To create a new compute field with Developer Workbench:
1. Open Developer Workbench, select the system on which to work and validate with your
userid and password. Please remember that the user must be part of the DevWorkbench
group (use Administration Security Center in the web interface to set up - see
Chapter 4, Security Center on page 147). Select Data Servers EDASERVE
Applications <yourfolder> and double click on the .mas file of the synonym you want
to edit.
2. In your synonym right click on the segment name (ORDERS in this example) and select
Insert Compute as shown in Figure 3-100 on page 108. In alternative, you can select
the little calculator icon (1) in the tool bar.

Chapter 3. Defining metadata

107

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-100 Developer Workbench - Insert Compute field

3. You are presented with the Compute Calculator. Type in a name (#1) and title (#2) for the
field (here we use MARGIN and Gross Profit Margin) and fill in the desired formula
((PROFIT / COSTOFGOODSSOLD) *100) (#3) - this can be done typing or selecting
items (we encourage you to select items, to avoid typos). Please notice the Function tab,
refer to Chapter 3.10.2, Define field - Developer Workbench on page 97 for information.

108

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

2
3

Figure 3-101 Developer Workbench - Compute Calculator

4. Using the Sample Data button you can check what is the result of your new compute field,
as shown in Figure 3-102 on page 110.

Chapter 3. Defining metadata

109

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-102 Developer Workbench - Compute Calculator sample data

5. Selecting the little dotted button on side of Format you get the formatting pane. You can
notice in Figure 3-103 on page 111 that we have asked for the % symbol to be posted in
our new field. Select OK to confirm your choices.

110

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-103 Developer Workbench - format compute field

6. You will be brought back to the Compute Calculator, select OK to confirm. On the
synonym editor (Figure 3-104 on page 112) use the save icon to save your synonym and
close it.

Chapter 3. Defining metadata

111

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-104 Developer Workbench - save synonym

3.11 Creating filters


You can predefine standard selection criteria in the master file both using the web interface
and the Developer Workbench tool. This allows the criteria to be specified once and used in
multiple reports. In this example, we create a filter called Europe. This allows us to easily run
a report including/excluding the European countries.

3.11.1 Creating filters with the web interface


To create a filter in your synonym with the web interface:
1. Open the DB2 web Query web interface, right click on your folder and select Metadata ->
Edit as shown in Figure 3-105 on page 113.

112

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-105 Web Interface - Edit Metadata

2. Right click on your synonym - here we use cen_orders - and select Open (Figure 3-106)

Figure 3-106 Web Interface - open metadata

3. The synonym editor opens up. Right click on the segment name (here it is ORDERS) and
select Insert Filter (Figure 3-107 on page 114).

Chapter 3. Defining metadata

113

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-107 Web Interface - Insert Filter

4. You will get, in the right hand sida of the pane, the Property View for the filter you are
creating.Type in a name and a title for the new filter (Figure 3-108). Here we use Europe
and European Countries, since we want to create a pre-defined filter to check for
European countries information in our reports - or for non-European countries, since filters
can be checked for true or false at runtime. After you have entered a title cick on the little
dotted button on the right side of the EXPRESSION field (#1) to enter the rule you want to
set.

Figure 3-108 Web interface, filter properties

114

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

5. You are presented with the Relationa Expression calculator. On the left side, in th list of
available fields locate the field on which you want to set the comparison (here we use
COUNTRY) and drag it in the Field field. Select the relation you want to set than right
click on the Value field and select Get Values as shown in Figure 3-109.
Note: Comparison operators provided in the web interface:







EQ
NE
LT
GT
LT
GE

Developer Workbench provides a wider selection.

Figure 3-109 Web Interface - relational expression in filter

6. In the filter panel you will be presented with all the values that are available in the field at
the moment. Select the appropriate values and add them to the right hand side of the list.
When you are done click on OK. Please notice that in this interface it is not possible to key
in values that are not in database when building the filter (i.e. if, later on, you start doing
business with Portugal you have to edit your filter and add Portugal).

Chapter 3. Defining metadata

115

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-110 Web Interface - set relational expression in filter

7. You will be brought back to the Filter Property View pane, select APPLY as shown in
Figure 3-111.

Figure 3-111 Web Interface - Filter completed

8. Save your synonym as shown in Figure 3-112 on page 117.

116

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-112 Web Interface - save synonym

9. The filter will be displayed in your list of column names when you create a report. Drag the
filter to the Selection criteria pane. A WHERE filter is true statement is generated by
default. This report will now include only the countries that are defined in the Europe filter
(Figure 3-119).

Figure 3-113 Using predefined filter in a report

3.11.2 Creating filters with Developer Workbench


To create a filter in a synonym using Developer Workbench:
1. Open Developer Workbench, select the system on which to work and validate with your
userid and password. Please remember that the user must be part of the DevWorkbench
group (use Administration -> Security Center in the web interface to set up). Select

Chapter 3. Defining metadata

117

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Data Servers -> EDASERVE -> Applications -> <yourfoldr> as shown in Figure 3-114.
Double click on the synonym where you want to define the filter.

Figure 3-114 Developer Workbench - add filter to synonym

2. Double click on the synonym where you want to add a new filter.
3. Right-click the master file name segment that contains the field that you would like to filter
and select Insert Filter, as shown in Figure 3-115 on page 119, or alternatively
selecting the symbol highlighted. In this case, we want to filter on the Country field, which
exists in our STORES segment.

118

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-115 Developer Workbench - Define Filter

4. In the Filter Calculator window (Figure 3-116) go to Column, type Europe, and define it as
an I1 (integer one long) column. This means that we can test it for true or false in our
reports. Double-click COUNTRY under the STORES segment to add it to the filter.
Change the Relations to IN because we must provide multiple countries for the value.
Click on the list button on the value field.
Note: Comparison operators provided in Developer Workbench are:














EQ
NE
LT
GT
LT
GE
CONTAINS
OMITS
LIKE
UNLIKE
IN
INCLUDES
EXCLUDES

This selection is wider that that available in the web interface.

Chapter 3. Defining metadata

119

8063ch03.fm

Figure 3-116 Developer Workbench - Creating a filter

120

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

5. Double-click the countries or use the > button to move the selections to the right-hand side
in the Value(s) Selection window (Figure 3-117). Click OK to close the Value(s) Selection
window.

Figure 3-117 Developer Workbench - Values in a filter

6. In case of need you can add more elements typing in directly in the VALUE box - you know
that your company is going to open new stores in Portugal and want your metadata to be
ready for that occurency, so you add OR Portugal to the list of values to be checked.
Click OK to close the Filter Calculator window (Figure 3-118 on page 122).

Chapter 3. Defining metadata

121

8063ch03.fm

Figure 3-118 Developer Workbench - Creating a Filter Detail

122

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

7. The filter will be displayed in your list of column names when you create a report. Drag the
filter to the Selection criteria pane. A WHERE filter is true statement is generated by
default. This report will now include only the countries that are defined in the Europe filter
(Figure 3-119).

Figure 3-119 Using predefined filter

Chapter 3. Defining metadata

123

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

3.12 Defining dimensions - InfoMini & OLAP


Within synonyms it is possible to define hierachies or dimensions to be used:
 in reports to enable pre-defined paths for drill down in data
 to be able to include new columns according to end users need (OLAP function - refer to
Chapter 14, Assignment #7: Implementing OLAP on page 423)
 to include pre-chained filters in reports (using InfoMini slicers refer to 12.4, Filter in
metadata - Europe Revenue and Profit report on page 366 ) at runtime.
Before a user can OLAP enable a report, a developer must define hierarchies that represent
the data. This hierarchy is automatically used by DB2 Web Query whenever a developer asks
to OLAP enable a report that references tables that contain these hierarchies. Hierarchies,
also known as dimensions, can involve elements from multiple tables, although the norm is
to have a single hierarchy composed of columns from a single table.
1. Start Developer Workbench.
2. Expand WebFOCUS Environments system name Data Servers
EDASERVE Applications <yourfolder>.
3. Right-click the cen_orders.mas table and select Edit in Synonym Editor (Figure 3-120).

Figure 3-120 Developer Workbench, edit synonym

124

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

4. In the Synonym Editor select the Dimension Builder icon in the tool bar, highlighted at # 1
in Figure 3-121. You are presented with the Dimension Builder pane, highlited at #2.
1

Figure 3-121 Developer Workbench - Dimension Builder

5. Right click on Dimension and select Insert New Time Dimension. as show in
Figure 3-122.

Figure 3-122 Dimension Builder, New Time Dimension

6. You are presented with a list of the segments defined in your sysnonym. Select the
segment that holds the date field you want to use. In our example we user ORDERS, with
its ORDERDATE field (Figure 3-123 on page 126). Click OK.

Chapter 3. Defining metadata

125

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-123 Time dimension candidates

7. You are presented with a panel where you can set if you want to choose individual fields
(where the basic date components are already decomposed - see Chapter 3.7, Date
decomposition on page 78) or if you want one single field to be decomposed into basic
elements. Here we take the second choice (Figure 3-124). Select Next.

Figure 3-124 Date Dimension - Decompose date field

8. You will notice that a full time decomposed dimension is populated, as shown in
Figure 3-125 on page 127.

126

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-125 Time Dimension

9. Richt click on the original label, select Rename and rename it to suit your needs, here we
use Order Date Hierarchy. Repeat the process for the second level title (Figure 3-126).

Figure 3-126 Rename Hierarchy

10.Right-click Dimensions and select Levels Hierarchy as shown in Figure 3-127 on


page 128.
There are two types of hierarchies. One is based on levels and the other is based on
parent-child relationships. We use level hierarchies. The level hierarchy is the example
that we have used so far, that is, country, regions, state, and city are a level hierarchy.
For more information about the different types of hierarchies see the Developer
Workbench help text.

Chapter 3. Defining metadata

127

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-127 Insert new dimension

11.Right click on the new hierarchy and select Rename (Figure 3-128). Here we use Product
Info. Repeat the step at the Dimension level.

Figure 3-128 Rename a hierarchy

12.In the left hand side of the Edit Synonym window select the segment in which the required
fileds are located, here we use INVENTORY. Hold the CTR key and select the field you
want to be in the dimension in the exact order you want them to appear (here the
sequence is Product Type, Product Category, Model, Product Name). Press the left
mouse button and drag all fields to the hierarchy on the right hand side of the panel - see
Figure 3-129 on page 129. In alternative you can drag each field, one by one.

128

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-129 Drag fields to hierarchy

13.You can repeat the process from step 10 and build as many dimensions as you need.
when you are finished save your metadata.
You have now completed all the definitions that are required for OLAP-enabling your reports.
Typically, this is done once by the IT department. After this, any user with authority to create
reports can choose to OLAP-enable their report.
You can see how easy it is to define a hierarchy in your data and create the necessary
metadata to OLAP-enable your reports for detailed analysis.
Note: Developer Workbench, a DB2 Web Query optional feature, is a prerequisite for
creating OLAP-enabled reports. Developer Workbench is the only interface for defining the
hierarchies that are required by OLAP at the time this redbook was written. Eventually a
Web based interface for building dimensions may be available.

Chapter 3. Defining metadata

129

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

3.13 Segmenting and securing Metadata - DBA


In DB2 Web Query V2 all metadata are kept in Applications (directory in the IFS) related to
the report folder where they are used. All metadata that must be seen and used by
everybody can still be hosted in the base application, Common
(/qibm/UserData/qwebqry/apps/Common), that is associated with the Common folder .
Having metadata in private folders ensures that:
 Only those allowed to interact (use, modify/create) with a folder can see associated
metadata, thus ensuring an optimal protection of sensitive data.
 It is easy to extract (save) metadata from a system to import (restore) either on the same
system for safety reasons or on another system for duplicating the environment.
 Identifying the desired metadata is easier when developing reports.
There are situations where you may want to hide information from certain users, so, even if
they are allowed to run a report they do not get to see data for certain columns or for certain
rows. It is possible to define security rules at the metadata level, so that they are applied for
every sort of reports. This is done using the DBA function, available in the Developer
Workbench tool.
Note: An alternative security approach based on authorization tables, SQL views and
stored procedures can be implemented. This may be easier and quicker to implement than
DBA functionalities native in DB2 Web Query.
For more information please refer to Gene Cobbs article Using SQL Views and Stored
Procedures to control Security with DB2 Web Query available from the DB2 for i Wiki
Article page
https://www.ibm.com/developerworks/mydeveloperworks/wikis/home?lang=en#/wiki/W516
d8b60d32c_4fc5_a811_5f3d840bf524/page/Articles
Here we will see how to set up security rules in metadata using the Developer Workbech tool.
This is performed using the DBA function which provides facility for setting up a reporting
environment with granular security restrictions. Can secure by:





Segment (File)
Field
Value (Row level security)
No Print (Column level security)

We will set two kind of rules:


1. Field level, No Print - to prevent a user from seeing data coming from a field
2. Value, row level - to authorize a determined user only to data coming from certain rows

3.13.1 Field level security, No Print


1. Open Developer Workbench, select the system on which to work and validate with your
userid and password. Please remember that the user must be part of the DevWorkbench
group (use Administration -> Security Center in the web interface to set up). Select
Data Servers -> EDASERVE -> Applications -> <yourfoldr> as shown in Figure 3-130
on page 131. Double click on the synonym where you want to create a security rule to
open it - here we use CEN_ORDERS.

130

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-130 DevWorkbench set security - Select metadata - Step 1

2. Once in the synonym, select the icon representing the DBA function on the tool bar, as
shown in Figure 3-131.

Figure 3-131 DevWorkbench set security - Select metadata - Step 2

3. A new panel will be opened, where it is possible to the security rules. Right click on the
metadata name and select Insert -> DBA (Figure 3-132 on page 132).

Chapter 3. Defining metadata

131

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-132 DevWorkbench set security - Select metadata - Step 3

4. The rule has the same name as the user that creates it. Now you can start defining rules.
Right click on the DBA name and select Insert User (Figure 3-133).

Figure 3-133 DevWorkbench set security - Select metadata - Step 4

5. You will see that a generic USER0001 is added, right click on it and select Rename
(Figure 3-134). Change the name to that of the user you want to manage - in our example
it will be COBBG.

Figure 3-134 DevWorkbench set security - Select metadata - Step 5

6. Now we will define a READ rule for user COBBG. Right click on the user name and select
Insert Read Access (Figure 3-135 on page 133).

132

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-135 DevWorkbench set security - Select metadata - Step 6

7. Right click on Read and select Insert Noprint Restriction (Figure 3-136).

Figure 3-136 DevWorkbench set security - Select metadata - Step 7

8. The first field of the segment is referenced automatically. To change it go to the


Properties pane, above the DBA one, and select the field you want to manage,
LINETOTAL in our example (Figure 3-137 on page 134). The bottom part of the pane will
be updated to reflect the selection made.

Chapter 3. Defining metadata

133

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-137 DevWorkbench set security - Select metadata - Step 8

9. The NOPRINT rule prevents user COBBG from reading the content of the selected field.
The whole rule is shown in Figure 3-138. Save the metadata.

134

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-138 DevWorkbench set security - Select metadata - Step 9

10.Now running the same report, user COBBG would get a column with no values for
LINETOTAL, where other users get the actual values, as shown in Figure 3-139.

Figure 3-139 DevWorkbench set security - Data shielded

If you need to define the same rule for another user you have to repeat the process, starting
from #4.

Chapter 3. Defining metadata

135

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

3.13.2 Row level security, Value


1. Open Developer Workbench, select the system on which to work and validate with your
userid and password. Please remember that the user must be part of the DevWorkbench
group (use Administration -> Security Center in the web interface to set up). Select
Data Servers -> EDASERVE -> Applications -> <yourfoldr> and double click on the
synonym in which you want to set the security rule to edit it.
2. In the synonym editor select the DBA icon, as shown in Figure 3-140 on page 136.

Figure 3-140 Developer Workbench, DBA

3. In the bottom right side of the synonym editor the DBA panel appears. Right click on the
synonym name and select Insert -> DBA (Figure 3-141) .

Figure 3-141 DBA - value rule - Step 1

4. A new rule is created, with the same name as the user profile you are using. Right click on
the DBA rule and select Insert -> User, as shown in Figure 3-142 on page 137.

136

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-142 DBA - value rule - Step 2

5. A new entry is added, named USER0001. Right click on it and select Rename to change
it to the name of the user for which you want to set the security rule. In this example we will
use SEPTIA (Figure 3-143).

Figure 3-143 DBA - value rule - Step 3

6. Right click on the name of the rule and select Insert Read Access (Figure 3-144).

Figure 3-144 DBA - value rule - Step 4

7. Right click on Read and select Insert Value Restriction (Figure 3-145).

Chapter 3. Defining metadata

137

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-145 DBA - value rule - Step 5

8. A new item is inserted, represented by the function symbol and named SYSTEM. Select
it and move to the panel above. Use the little dotted button on the side of the VALUE field
as shown in Figure 3-146 on page 138.

Figure 3-146 DBA - value rule - Step 6

9. You are presented with a panel where to set up the rule. It offers you two choices,
Expression is used to set up rules that requires operations or functions to be applied to
data, Relationa Expression is used to set up comparison to fields data. In our example we
want to check contain of a field and restrict usage of all the rows that have the selected
value. Double click on the field you want to check, COUNTRY in our example. It will be
inserted in the left hand side of the panel. Select the comparison operator, EQ in our
example, and ask for a list of values clicking on the dotted button as shown in Figure 3-147
on page 139.

138

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-147 DBA - value rule - Step 7

10.In the Value selection pane select the value for which you want to restrict access, Canada
in our example, and then click on OK (Figure 3-148 on page 139).

Figure 3-148 DBA - value rule - Step 8

Chapter 3. Defining metadata

139

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

11.You will be brought back to the previous pane where the settings can be verified. In case
of need you can use the button on the top right hand corner of the pane to check
expression, sample data and find. Select OK.

Figure 3-149 DBA - value rule - Step 9

12.In the main DBA pane you can see the whole rule (Figure 3-150).

Figure 3-150 DBA - value rule completed

13.Save the synonym using the save icon in the tool bar (Figure 3-151 on page 141).

140

IBM i DB2 Web Query for i Implementation Guide

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-151 DBA - value rule save

14.Now running the same report, user SEPTIA would only get data for country Canada,
where other users get the values for all countries, as shown in Figure 3-139.

Figure 3-152 DevWorkbench set security - Data shielded

3.14 Business Views


A business view is an alternative view of the Master File in which you can limit the fields
available or create a subset of fields from the original Master File. It can be used to mask
database and data model complexity for the DB2 Web Query report developer. In a business
view you can:
 Include only commonly used database fields
 Eliminate ambiguously named field (from different join segments)
 Customize the field names, titles, and descriptions that appear in the development tools
 Organize logically related fields into folders

Chapter 3. Defining metadata

141

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Note: Do not confuse a business view with an SQL view. A business is a type of DB2 Web
Query synonym that is based on an existing synonym and provides an even higher level of
abstraction than the synonym it references.
With business views, you can hide the database complexity by presenting information in
business terms and groupings based on user preferences. For example, in a business view,
you can include only commonly used database fields, change the field names that appear in
the development tools, and organize logically related fields into folders. All of this provides
report developers with an easy way of viewing and selecting the fields needed to deliver the
required reports.
To define a Business View with Developer Workench:
1. Open Developer Workbench, select the system on which to work and validate with your
userid and password. Please remember that the user must be part of the DevWorkbench
group (use Administration -> Security Center in the web interface to set up). Select
Data Servers -> EDASERVE -> Applications -> <yourfoldr> and double click on the
synonym in which you want to create the business view to edit it.
2. In the synonym editor select the Business View icon, see Figure 3-153 # 1. You will notice
that a Business View pane opens up in your window (# 2).
1

Figure 3-153 Developer Workbench, Business View

3. In the Business View pane right click on the synonym name. there are 3 choices:
Properties, Create Default Business View and New Folder. If you select create default all
segments and field that are in your synonym will be brought into your Business View, and
you can than delete unnecessary ones or edit titles and description according to need. If
142

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

you select new folder you create a folder where you can group together information that
in your environment have a logical relationship (having fileds grouped in folders can be
very handy for developers). Here we select New Folder (Figure 3-141).

Figure 3-154 Dev. Workbench - Business View new folder

4. A new folder is created, right click on it and select Rename to give it a meaningful name
(Figure 3-155).

Figure 3-155 Dev. Workbench - rename folder

5. When you have renamed your folder (here we use DATES) select from the field list on the
left hand side the fields that you want to present in this folder and drag them in the folder.
Here we select the various dates that we have in our file (ORDERDATE, INVOICEDATE,
REQUESTEDSHIPDATE, SHIPDATE and RECEIVEDATE) as shown in Figure 3-156 on
page 144. Please notice that we could have used the decomposed components, instead
of the original fields. Your choices depend on the intended usage for fields.
Chapter 3. Defining metadata

143

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-156 Dev. Workbench, fields in a folder

6. Now you can add information to the fields, to make them more easily understandable both
for developers and users. Here we change a fields title and description (Figure 3-157 on
page 145).

144

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch03.fm

Figure 3-157 Developer Worbench - Business View edit field

7. In Figure 3-157 you may notice the little dotted buttons on the right. Selecting these
buttons you can access the multilingual setup for the field, as shown in Figure 3-158. Here
you can add titles (or descriptions) for all the languages needed in your environment and
each user will see titles in the language selected for the user profile. So in the same report
a Spanish-setup user will see titles in Spanish and a German-setup user will see titles in
German, without any additional action on the report (neither at development time nor at
run time). Select OK when you are done.

Chapter 3. Defining metadata

145

8063ch03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 3-158 Dev. Workbench - multilingual setup for field

8. Create as many folders, add fields and edit them as you need. When you are finished use
the SAVE AS option to save your Business View, or you will make your original synonym
unaccessible - see Figure 3-159.

Figure 3-159 Developer Workbench - Business View SAVE AS

9. To use a Business View in development simply select the view name when developing a
new report in Info Assist.

146

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch04.fm

Chapter 4.

Security Center
User management is now handled through the Web Query Security Center. This is a
graphical user interface that simplifies Web Query user administration because it is tightly
integrated with License Manager and will dynamically upate license information.
Note: In Chapter 6, Security Center - Setting up users on page 169 the handling of
Security Center is explained in more detailed.

Copyright IBM Corp. 2012. All rights reserved.

147

8063ch04.fm

Draft Document for Review August 30, 2013 2:37 pm

4.1 Security Architecture and Concepts


Security Architecture consits of a new security model which is called Universal Object
Access (UOA) Security. UOA Security provides more granular control of objects. Rules
define what a user can or cannot do.

4.1.1 Security Architecture


UOA is composed of:
1. Users - unique ID.
2. Folders - contain Managed Reporting (MR) content.
there are no limits to folder depth.
3. Groups (Roles) - container of users or subgroups with similar capabilities.
Each Top Level folder has six groups/roles:
i. Folder-Run
ii. Folder-Analyst
iii. Folder-Developer
iv. Folder-DBA
v. Folder-Sched
vi. Folder-Admin
4. Permission Sets - group of permitted or denied operations.
These are pre-defined for Web Query Folder-xxx groups above.

4.1.2 Security Concepts


The following outlines role-based security concepts. Web Query groups are pre-defined to
represent a specific set of functions or role. Global groups define a role at the Web Query
product level and apply across folders whereas folder groups define a role at the top level
folder level.
There are two global groups defined as follows:
Table 4-1 Global groups
Group Name

Role Description

WebQueryAdministrator

Can perform all functions in Web Query and can access all
folders.

DevWorkBench

Can connect to Web Query using Developer Workbench.

The six folder groups are defined as follows:


Table 4-2 Goups associated to a top level folder

148

Group Name

Role Description

Folder-run

Can run reports in the respective folder.

Folder-analyst

Can develop, run and schedule private reports..

IBM i DB2 Web Query for i Implementation Guide

8063ch04.fm

Draft Document for Review August 30, 2013 2:37 pm

Group Name

Role Description

Folder-dev

Can develop and run both private and managed(published)


reports.

Folder-dba

Can only manage metadata.

Folder-sched

Can schedule reports to run via Report Broker.

Folder-admin

Can manage users in the respective folder.


Note: A Folder-admin cannot add or release (delete) a
developer or group license

4.2 System i Security


Regardless of DB2 Web Query authorities granted, end users still need IBM i OS object level
authority to all objects that are used in a report.
This includes:
 Tables/Physical Files
 SQL Views
 Stored Procedures
 IFS Files
 Query/400 Definitions

Note: Just because a user has access to a report does not mean he will be able to run
it.

4.3 Groups and their capabilities


In section 4.1.2, Security Concepts on page 148 we showed you which groups are
generated when you create a Top Level folder. The following picture shows the global and the
Top Level Folder Groups and their capabilities.

Chapter 4. Security Center

149

8063ch04.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 4-1 Groups and their capabilities

4.4 Top Level folders and Subfolders


In this section we will explain the top level folders and subfolders.

4.4.1 Top Level folders


Top level folders reside at the top of the Web Query Client Repository and are used to
segregate applications. For example you want to have a top level folder for Human
Resources (HR) and another folder for Sales where users can be assigned to one or more
folders. In our tutorial we use a top level folder Century Electronics.
A user can have a different set of roles for each folder. For example, a user can be assigned
to only run reports in Sales and HR, but takes on a developer/dba role in Century Electronics.
Each top level folder is created with its own set of Web Query groups that define the
authorization rules for the folder (see 4.1.2, Security Concepts on page 148).
The Common top level folder exists for all Web Query installations. The purpose of this folder
is to contain content that can be run by all users. If you prefer not to display the Common top
level folder, there is an option to hide. it. You can do this by right-clicking top folder Common
and select Hide (see next figure).

150

IBM i DB2 Web Query for i Implementation Guide

8063ch04.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 4-2 Hide the Common Top Level folder

Note: To be able to hide the Common folder you must be a member of the
WebQueryAdministrator group.
Web Query content consists of different types of objects:
 Reports
Folder containing report and graphics objects.
Can be organized in one or more subfolders.
 Other Files
Contains images (.gif, .jpg), HTML files, and other files used to customize and enhance
reports.
Available only to administrators and developers.
 Subfolders
Allows for logical segments of reports within the Top Level Folder group.
Beside the six groups, an application folder for storing metata (apps/folder_name) is
created. Metadata will be secured at the IFS using an authorization list that is automatically
updated based on a users authorization to the top level folder.
 Run users will only require READ.
 DBA users will require READ/WRITE .

Each top level folder that is created will automatically have the six folder based groups
created in the Web Quiry repository.

Chapter 4. Security Center

151

8063ch04.fm

Draft Document for Review August 30, 2013 2:37 pm

For example, if you add a top level folder named Century Electronics, the following six
groups are automatically created:
1. Century_Electronics-run. Can run reports in the Century Electronics folder.
2. Century_Electronics-analyst. Can develop and run reports in private folders within the
Century Electronics folder.
3. Century_Electronics-developer. Can develop, run, and publish reports in a published
folder within the Century Electronics folder.
4. Century_Electronics-dba. Can manage metadata in the Century Electronic folder
application directory.
5. Century_Electronics-sched. Can manage schedules and distribution lists in the Century
Electronics folder.
6. Century_Electronis-admin. Can add or remove a user from the Century Electronics group.
Note: Users are added to one or more groups to provide the functionality they require
to perform their job. This is done using the Security Center (see chapter 06),.

4.4.2 Subfolders
Subfolders are created within Top Level folders and can go multiple levels deep. Your
reporting objects (reports, charts, documents, and dashboards) are created in these
subfolders. You can create reporting objects in the top level folder (and not a subfolder) if you
wish. However, use of subfolders allows for further logical segmentation and organization of
reporting objects within the Top Level folder.
The previous version restriction of only allowing two levels of subfolders has been removed.
Therefore you may create as many levels of subfolders as you need to properly organize your
reporting objects.
Note: Top Level folder authority is applied to all subfolders and the metadata (synonyms).

4.4.3 Controlling accessiblity to subfolders and reporting objects


In addition to the security features already described, DB2 Web Query has additional ways
for developers to control if and how content in the top level folder is accessed by other users.
This is accomplished by utilizing two additional properties: publication status and hide/show
attribute. These properties can be applied to both subfolders and reporting objects (reports,
charts, dashboards, compound documents, HTML files, etc) within those folders.

Publication status
The publication status determines if other users can see and run that particular element. The
two values for publication status are as follows:
 Private
Also referred to as Unpublished, this status means that only the developer that created the
report or subfolder has access to that element. It will not appear on the resource tree for
other users, nor can it be run from other interfaces. This gives the developer an
opportunity to continue working on the report until it is ready to promote for others to see
and run.

152

IBM i DB2 Web Query for i Implementation Guide

8063ch04.fm

Draft Document for Review August 30, 2013 2:37 pm

This is the default value. Consequently the developer must publish any report before
others users can access it. Y.
 Published
Whan a subfolder or reporiting object is in Published status, all users who have Run
authority to the top level folder can see the report in the resource tree. They can also run
the report from any supported interface such as the resource tree, the spreadsheet client
plug-in, or from a web services call using the software development kit.

Hide/Show Attribute
In addition, there is also an property known as the Hide/Show attribute which can be applied
to top level folders, subfolders, and reporting objects. The two values for this property are as
follows:
 Show
The subfolder or report is seen by all users with Run authority to the top level folder. This
is the default value..
 Hide
The folder or report is only seen by the developer from the resource tree. However it can
still be referenced and run from other interfaces such as a drill down from another report,
or called from a web services call using the software development kit. Because this is not
the the behavior, the developer must explicitely take this action to activate this attribute.
You might be wondering why you would want to publish a report so that it is accessible to
all users and then hide it. This technique might be appropriate if you have many drill down
reports (where you have a summary or parent report and allow your users to drill down to
other reports or charts with more details). You might not want to expose the drill down
reports or charts in the resource tree (since they are only meant to provide more
information through the drill down process). If you hide these detailed reporting objects,
you can prevent your users from running them directly from the resource tree. A side
benefit of this is that your folders will look much more organized and less cluttered.
Tip: Create a specific subfolder for all of your drill down reports within a top level folder.
Then hide the subfolder so none of that content appreas on the resource tree.

Determining publication status and hide/show attribute


For each folder and reporting object, DB2 Web Query gives you a visual representation of the
publication status and the hidden attribute. An icon is placed to the left of the element. The
color and transparency of the icon are meant to inform you of both the publication status and
whether the element is hidden or not. The rules are as follows:
 Unpublished - The icon is gray
 Published - The icon has color
 Hidden - The icon is semi-transparent
 Not hidden - The icon is opaque.
A folder example of this visual representation is shown in Figure 4-3.

Chapter 4. Security Center

153

8063ch04.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 4-3 Icons for publication status and hidden attribute

For reporting objects like reports, graphs, and dashboards, the icons themselves are different
but follow the same rules as described above for representing publication status and hidden
attribute. This is demonstrated in Figure 4-4.

Figure 4-4 Icons for reporting object publication staus and hidden attribute

Notice the use of color and transparency to help you understand if the contenet is published
and whether it will be hidden from the resource tree of other users.
Note: You may also notice that published elements appear in bold font. This feature was
enabled in the first two group PTFs of the product, was inadvertantly removed, and later
added back in again.
If you find it hard to visually distinguish the differences in the icons and are unsure of the
values of publication status and hide/show attribute for a particular reporting object or
subfolder, you can obtain this information by right clicking on the report or folder and selecting
properties as shown in Figure 4-5.

154

IBM i DB2 Web Query for i Implementation Guide

8063ch04.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 4-5 Properties of a report

In the above example, we see that the report is hidden and published.

Publishing and unpublishing content


As mentioned, new reports are private and not accessible to other users. When the report is
ready for promotion, you can publish it by right clicking on the report and selecting the Publish
option. An example is shown in Figure 4-6 on page 155.

Figure 4-6 Publish a report


Chapter 4. Security Center

155

8063ch04.fm

Draft Document for Review August 30, 2013 2:37 pm

Published content can also be unpublished. You might want to do this to make changes to a
an existing report - this option effectively takes it out of production and allows you to edit and
test it. To unpublish a report, right-click on it and select the Unpublish option as shown in
Figure 4-7.

Figure 4-7 Unpublish a report

You can also publish/unpublish at the subfolder level. Simply right click the subfolder and
select the appropriate option (Publish or Unpublish). This will change the publication status of
all content in the subfolder (including nested subfolders and reporting objects within).
Tip: You cannot publish/unpublish at the top folder level. However, you can process
multiple reports at once by holding down the Ctrl key, selecting the reports, and selecting
the Publish or Unpublish option.

Hiding and showing content


By default, reports are not hidden. You can change this attribute by right clicking on the report
and selecting the Hide option. An example is shown in Figure 4-8.

156

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch04.fm

Figure 4-8 Hide report

If you hide a report and decide later that it should be displayed on the resource tree, you can
accomplish this by right clicking on the hidden report and selecting the Show option. An
example is shown in Figure 4-9.

Figure 4-9 Show report

4.4.4 Controlling order of elements


By default, subfolders (and the content within those subfolders) appear in the resource tree in
alphabetical order by name. In some cases you might want to override this and specify your

Chapter 4. Security Center

157

8063ch04.fm

Draft Document for Review August 30, 2013 2:37 pm

own ordering. This can be accomplished by using the Sort Order property. Simply right click
on the report or folder, select Properties, and specify a value for the Sort Order setting. An
example of this is displayed in Figure 4-10.

Figure 4-10 Specify sort order

The elements will appear in the folder in ascending order of the Sort Order value. An example
is shown in Figure 4-11.

Figure 4-11 Results of specifying sort order

Notice that the reports and charts are not in alphabetical order. This is because each one has
a Sort Order setting specified.
Tip: Elements that have a Sort Order value specified will appear after the elements
without a Sort Order value. This means if you want complete control over all the ordering,
you must specify a Sort Order value for all of the elements in the folder.

158

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063p02.fm

Part 2

Part

Tutorials for DB2 Web


Query
This part is structured as tutorials. These examples are not intended to replace reference
manuals or customer education classes. The intent is to provide hands-on exercises that help
you get started and demonstrate the more common reporting techniques.
This part includes the following chapters:



















Chapter 5, Getting started with the tutorials on page 161


Chapter 6, Security Center - Setting up users on page 169
Chapter 7, Creating and editing metadata - Century Database on page 191
Chapter 8, Assignment #1: Summary Reports on page 205
Chapter 9, Assignment # 2: Implementing Various Date Functions in Reports on
page 247
Chapter 10, Assignment # 3: Implementing Other Report Features and Formats on
page 269
Chapter 11, Assignment # 4: Charting on page 311
Chapter 12, Assignment #5: Adding filters to reports and charts on page 341
Chapter 13, Assignment #6 : Detail/print reports on page 393
Chapter 14, Assignment #7: Implementing OLAP on page 423
Chapter 15, Assignment # 8: Building Documents/Dashboards on page 455
Chapter 16, Assignment #9: Exploring/comparing other dashboard options on page 477
Chapter 17, Assignment #10: Scheduling and Distribution of reports on page 541
Chapter 18, Assignment #11: Going mobile on page 583
Chapter 19, Assignment #14: Stored procedures in action on page 605
Chapter 20, Assignment #14: Query/400 Modernization on page 631
Chapter 21, Assignment 15: Creating JD Edwards reports on page 685
Chapter 22, The Century BI Solution Challenge: Postmortem on page 711

Copyright IBM Corp. 2012. All rights reserved.

159

8063p02.fm

Draft Document for Review August 30, 2013 2:37 pm

The tutorials all use tables in the QWQCENT library. This library can also be referenced as
the Century library. Century is the fictitious electronics company that is referenced throughout
these tutorials. Specifically, we use 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 directly refer to the ORDERS table. Thanks to the
knowledge and understanding that DB2 Web Query has DB2 for i, the other three tables are
automatically made available whenever ORDERS is referenced.

Map of tables in QWQCENT: Century library

In DB2 for i, 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.

160

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch05.fm

Chapter 5.

Getting started with the tutorials


This chapter provides the backdrop for The Century Challenge, a fictional account of a
companys struggle to fulfill their Business Intelligence reporting requirements. In this chapter
you will understand more about the companys query and reporting needs, how it resulted in
the challenge, and what you must do to win the support of a misinformed executive.
The subsequent chapters in Part 2 are structured as basic tutorials. These examples are not
intended to replace reference manuals or customer education classes. The intent is to
provide hands-on exercises that help you get started and demonstrate the more common
reporting techniques using the DB2 Web Query product.
Disclaimer: The company, Century Electronics, used in this publication was chosen as a
fictitious name. It is used for instructional purposes only. This name is part of the toolkit
supplied by Information Builders and was selected to assist readers wanting to explore
DB2 Web Query for IBM i powered by Information Builders .

Copyright IBM Corp. 2012. All rights reserved.

161

8063ch05.fm

Draft Document for Review August 30, 2013 2:37 pm

5.1 The Century Challenge


Century Electronics is a manufacturer and distributor of electronic equipment and sell their
products to electronics stores world-wide. They are a loyal IBM i client and have run their
business on the IBM midrange platform since the AS/400 was first available in 1988.
In November of last year, the position of IT Director opened up at the company and after
several interviews the executives at Century hired Dan Lassiter, a self-proclaimed rising star
who previously worked a national pharmaceutical retail chain where he held a similar
position. To date, Dan has said and done all the right things to impress his upper
management chain, but has shown little respect to and care for those that work under him. As
a result, his employees have formed a less than favorable impression of the man they jokingly
refer to as Executive Dan.

Figure 5-1 Executive Dan

You are Pat Spencer and have worked at Century since 1990 where you have worked your
way up the ranks in the IT department. During this time you have developed deep skills in the
RPG and CL programming languages as well as SQL on DB2 for i. You have attended
several COMMON conferences and have built up skills in Java and PHP and are passionate
about the prospect of modernizing the Century applications. You currently work for Mel
Runkle, a close friend who has been a good boss over the years, but he is 3 months from
retirement, and doesnt want to say or do anything that might jeopardize these plans. Mel
reports directly to Executive Dan and has privately not agreed with any of Dans philosophies
so far but has remained quiet after all, he only has to put up with Dan for another 88 days
(but whos counting?)
The IBM i platform has served Century well over the years and the various organizations that
IT department has served have been very happy with the applications and reports produced
by your department. Aside from the occasional glitch, the relationship between IT and the
other organizations has been quite harmonious for the last 2 decades. However, Executive
Dan has a different background, perspective, and set of ideas. He views the IBM i as a
dinosaur and thinks it is old technology. His first order of business is to form a strategy to
replace the IBM i servers and applications with more modern and sophisticated technology.
In May he schedules a meeting with you and Mel to execute this strategy. The meeting goes
something like this:

162

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch05.fm

Executive Dan: Runkle, this AS/400 is old, stale, and needs to go. We are losing market
share and it is because we lack information, tools, and the appropriate hardware technology.
Mel (stunned): Dan, its called an IBM i and it is far from old and stale. Its actually built on
IBMs POWER7 processor technology, the same technology IBM built Watson on for the
Jeopardy Challenge. So I really dont think this is a good idea. And who says we are losing
market share? Our reports certainly dont indicate that.
Executive Dan: Those reports must be wrong they are written in Query/400 and RPG arent
they? (he snickers to himself) Anyway, I extracted a Query/400 report to a spreadsheet, did
some reswizzling of the numbers, and created a pie chart that says we are losing market
share. Besides, our tools and hardware are not modern enough and cant handle todays
complex business intelligence requirements. Its time to bring in an Intel server farm and
move everything to SQL Server. That way I can triple my IT staff. Hmmmjust think of how
much better the office Christmas parties will be.
You: Wait? What? Really? Our numbers arent wrong. That is the danger with creating
extracts like that - its way too easy to adjust the numbers in a spreadsheet and create your
own version of the truth. The data and business rules need to be centralized.
Executive Dan: Well, I dont see the harm. I always did this in my last job. At any rate, we can
centralize things on a more modern platform.
You: Dan - the IBM i platform is as good as anything out there. The security is second to
none we have never been hacked and never had a breach of security. The system never
goes down and rarely needs to be IPLd. In fact we have not had an unplanned outage in 9
years and that was because a squirrel on the roof chewed through a power line. The
database is integrated, requires very little administration, and new features are being added
at every new release and PTF. And not modern? JAVA, PHP, SQL, and WebSphere are all
supported. IBM i curriculum is being offered in many colleges and universities. As far as our
current environment, our production system is 6 years old so we could sure use a hardware
upgrade to a new Power 7 system. I have seen demos and have been doing some reading the new multi-core models really scream.
Executive Dan: Har! My fellow executives at the country club say otherwise! They tell jokes
at my expense and tell me I am running my business on 80s technology. My caddy Fitzgerald
even told me that this system still runs old System/36 code.
You: Well, yes it can run S/36 code but that doesnt mean the technology has not been
keeping up over the years. In fact, many companies have modernized their database and
applications and have dynamic websites that are served up by the IBM i and the DB2 for i
database. This is where I would like to see us going. As far as Business Intelligence tools, I
have been researching this tool called DB2 Web Query-
Executive Dan (interrupting): Harrumph. Well anyway, my mind is made up. We need reports
that go to Excel in one step. We need charts! We need executive dashboards!
You: Dan - DB2 Web Query is an IBM i product and is supposed to be able to provide all of
those things. Tell you what Dan: give me two months to try out this product. You give me your
business intelligence requirements and I will use DB2 Web Query and features in the DB2 for
i database. At the end of the two months, I will deliver a business intelligence solution to you.
If the results are satisfactory, please consider staying on the platform.
Executive Dan (who never backs away from a challenge): HmmmmYour e on, Spencer!
Tell you what. If you pull this off, I will give you a raise, Runkles job, and I might just upgrade
to a new Power7 system.

Chapter 5. Getting started with the tutorials

163

8063ch05.fm

Draft Document for Review August 30, 2013 2:37 pm

Executive Dan gets up to leave. He whirls around just before walking out the door, points to
his beard and exclaims And see this bad boy? I have had it for 10 years. As further
incentive, if you can meet my requirements, I will shave it off! And with that he leaves, his
guffaws echoing down the hallway.
You : Wow.
Mel : Yeah. Dan means well but is he ever misinformed. It would be a huge mistake to move
off this platform. Not to mention expensive. My brother-in-law works for a company that
moved all their data and applications off of the IBM i, realized what a mistake it was, and are
in the process of actually moving everything back.
You: Yeah, no kidding. But Dan is right. We do need better BI tools to help our executives
make better business decisions. But with the help of the DB2 Web Query product, we should
be able to avoid the same mistake of moving off the platform and prove to Dan that the there
is no reason to leave this platform! Lets get busy Mel we have work to do!

5.2 The Assignments


In the subsequent chapters in Part 2, you will be given several assignments by Executive
Dan. Each assignment will be a specific set of report requirements that Century Electronics
needs as part of its business intelligence solution. It is your job to use DB2 Web Query to
fulfill these requirements and prove to Executive Dan that the IBM i is the platform of the past,
present, and future for Century Electronics. The tutorials in these chapters guide you through
each set of requirements and provide complete step-by-step instructions. Once you have
completed the tutorials, you will have a folder of reports, charts, and dashboards that go
above and beyond Executive Dans expectations!

5.3 The QWQCENT Library


The tutorials in these chapters all use tables in the QWQCENT library. This library can also
be referenced as the Century library. Specifically, the following tables will be used througout
the tutorials






164

ORDERS
INVENTORY
PLANT
STORES
DATE_CONV

IBM i DB2 Web Query for i Implementation Guide

8063ch05.fm

Draft Document for Review August 30, 2013 2:37 pm

ORDERS is the central table. It contains foreign keys or links to the INVENTORY, PLANT,
and STORES tables. In most of the examples, you will see that we only directly refer to the
ORDERS table. This because we define joins to the other three tables in the ORDERS table
synonym. Subsequently we only need to reference ORDERS to access any of the columns in
all four tables. A diagram of this data model is shown below.

Map of tables in QWQCENT: Century library

In DB2 for i, 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.

Chapter 5. Getting started with the tutorials

165

8063ch05.fm

Draft Document for Review August 30, 2013 2:37 pm

Note: The version of the ORDERS table at the time of this publication contained data
for the years 2011 and 2012. You may want to update the date column values to
reflect more recent information. The following SQL statement can be used to add
one year to the date columns of the ORDERS table:
UPDATE qwqcent/orders
SET order_date = ADD_MONTHS(order_date , 12),
req_date = ADD_MONTHS(req_date , 12),
ship_date = ADD_MONTHS(ship_date , 12),
inv_date = ADD_MONTHS(inv_date , 12),
recv_date = ADD_MONTHS(recv_date , 12)

A pre-populated date table named DATE_CONV is also provided in the QWQCENT library.
This table has a row for every day in the date range January 1, 1900 through December 31,
2030. Multiple columns are provided to represented the dates in various ways and is used in
the tutorials and examples throughout this Redbook. However, you may find this table useful
for other applications.

5.3.1 Restoring QWQCENT on your system


The QWQCENT library is now shipped with the 5733WQX product. If you did not have a
version of QWQCENT already installed on your system, the GA version of the library will be
restored when you first restore the 5733WQX licensed program. If you already had a version
of QWQCENT, your current version is not overwritten and you must restore the new version
manually by specifying the following command:
RSTLIB SAVLIB(QWQCENT) DEV(*SAVF) SAVF(QWEBQRY/QWQCENT) MBROPT(*ALL)
ALWOBJDIF(*ALL)
The IBM DB2 Web Query development team will make occasional changes and updates to
the QWQCENT library. When this happens, a new save file will be shipped as part of a group
PTF. The save file will always be named QWEBQRY/QWQCENT. If you want to restore the
latest version from this shipped save file, you will need to use the command above.
Tip: The new version of QWQCENT contains several new columns that are used in the
Redbook tutorials. If you already had QWQCENT installed and have existing synonyms
built over the tables in this library, you will want to refresh those synonyms so that the new
database columns appear in the InfoAssist tool. For more information on refreshing
synonyms, refer to Chapter 3.4, Refreshing metadata (when IBM i database object
structure changes) on page 39.

5.3.2 Downloading completed tutorials


While we encourage you to go through the tutorials in this Redbook (step by step) yourself,
we realize that you may not have time to complete all of them. A completed version of all the
tutorials is available on the Redbook website. If you would like to download these completed
tutorials, you may do so by following these steps:
1. Go to the Redbook website:
http://www.redbooks.ibm.com/abstracts/sg248063.html?Open

166

IBM i DB2 Web Query for i Implementation Guide

8063ch05.fm

Draft Document for Review August 30, 2013 2:37 pm

2. Click on the additional materials link. You will see a file named
DB2_Web_Query_21_Redbook_Tutorials.zip.
3. Click on this zip file to download it
4. Use the Change Management tool to load this package into your DB2 Web Query
environment. See the Change Management chapter for more information.

Chapter 5. Getting started with the tutorials

167

8063ch05.fm

168

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ch06.fm

Chapter 6.

Security Center - Setting up


users
While Executive Dan is meeting with the other departments in the organizaiton to gather the
Century Challgenge BI solution requirements, you can do some initial set up of the
environnment. Once the product is installed and configured, the first thing you need to do is
add licensed users to the DB2 Web Query product. In Chapter 4, Security Center on
page 147, we introduced the new security concepts and explained the architecture of the
Security Center. In this chapter we show you how to manage users and groups with the DB2
Web Query Security Center.

Copyright IBM Corp. 2012. All rights reserved.

169

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

6.1 How to open the Security Center


1. Sign on to DB2 Web Query as QWQADMIN.
2. On the menu bar, click or right-click Security Center as shown in Figure 6-1.

Figure 6-1 How to open the Security Center

The Security Center opens, as shown in Figure 6-2.

Figure 6-2 Security Center

170

IBM i DB2 Web Query for i Implementation Guide

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

6.2 Registering user profiles to DB2 Web Query


If you want to authorize a user to DB2 Web Query, the user has to be registered. Follow the
steps below to add licensed user to DB2 Web Query.
Note: In DB2 Web Query V1.1.2 and below this was done with the help of one of the
CL-Commands WRKWEBQRY or ADDWQLUSR. With version 2.1 these commands
cannot be used any more to register user profiles. For these types of tasks you must use
Security Center.
1. On the Security Center window click the New User icon as shown Figure 6-3.

Figure 6-3 Start to select a new user

A new User dialog box opens.


2. A new user dialog box opens, select one or more users from the list and click Import
Users as shown in Figure 6-4 to add the user ID(s) as a named user (developer) to DB2
Web Query.
Note: All IBM i user profiles will appear on this liist. Group profiles do not show up on
this list.

Chapter 6. Security Center - Setting up users

171

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 6-4 Import a user to DB2 Web Query

The new user is added to the users list as shown in Figure 6-5 on page 173.

172

IBM i DB2 Web Query for i Implementation Guide

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 6-5 New user in the users list

6.3 How to designate a Web Query Administrator


As we wexplained in Chapter 4, Security Center on page 147, there are two global
authorization groups which are already pre-defined:
 WebQueryAdministrator
 DevWorkBench
In this example we will add a user to the group WebQueryAdministrator.
1. In the users list select the user to be added to the WebQueryAdministrator group.
2. Select WebQueryAdministrator from the Groups panel.
3. Click the Add (>>) button as shown in Figure 6-6 on page 174.

Chapter 6. Security Center - Setting up users

173

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 6-6 Add a user to the WebQueryAdministrator group

The user is added to the WebQueryAdministrator group as shown in Figure 6-7 on page 175.

174

IBM i DB2 Web Query for i Implementation Guide

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 6-7 New user in the WebQueryAdministrator group

Tip: You can also add users by dragging and dropping the selected uses into a group.

Note: After you added the new DB2 Web Query user to the WebQueryAdministrator group,
you can use this user profile for the next steps, instead of QWQADMIN.

6.4 Remove a user from a Web Query group


Provided the Security Center is still opened:
1. In the Groups panel, select the group which you want to modify. The members of the
selected group are listed in the Users in Group panel, as shown in Figure 6-8 on
page 176.

Chapter 6. Security Center - Setting up users

175

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 6-8 Remove a user from a group

2. In the Users in Group panel, select the user or users that you want to remove from the
group. You can choose multiple users by pressing the Ctrl key as you make your
selections.
3. Click the Remove selected users from group (<<) button to remove users from that
group as shown Figure 6-8.
Note: There is another way to remove a user from a group. You can right-click the user
in the Users in Group panel and select Remove as shown in Figure 6-9 on page 177.

176

IBM i DB2 Web Query for i Implementation Guide

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 6-9 Remove a user from a group

6.5 Adding a developer to a Top Level Folder


As we explained in Chapter 4, Security Center on page 147, when you create a Top Level
Folder, six groups (roles) are created for this folder.
In this section we will add a user as a developer to the top level folder Century_Electronics.
1. Assumed the Security Center is opened, select the Century_Electronic-dev group on the
Groups panel as shown in Figure 6-10.

Figure 6-10 Select a group for adding a user to it

2. Next select the user you want to add from the Users panel and click the Add (>>) button
as shown in Figure 6-11 on page 178.

Chapter 6. Security Center - Setting up users

177

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

Note: You can also add users by dragging and dropping the selected users into a
group.

Figure 6-11 Select a user to be added to a group

The user is added to the Century_Electronics-dev group, as shown in the following image.

178

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch06.fm

Figure 6-12 New user in the Century_Electronics-dev groupl

6.6 Give Run-Only authority to existing IBM i group profile


With Runtime Users support you give run-only authority to a user by adding a group profile.
Note: The group profile does not have to be an MUxxxx group profile. ANY existing IBM i
group profile can be assigned to a Folder-run group role.
After assigning a group profile to a Folder-run group, you have to add the group profile to all
users who should be allowed to run the reports inside the folder, by using the CHGUSRPRF
command.
For our next example we use a profile CENELEC as a group profile. All users with this group
profile should be allowed to run reports in the Century Electronis folder.
1. Create a user profile by using CL command CRTUSRPRF, or copy an existing profile and
name it CENELEC.
Note: A user profile becomes a group profile as soon as it is added to a profile as a
group profile. Whenever the goup profile is removed from a user or from all users, it still
remains a group profile.

Chapter 6. Security Center - Setting up users

179

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

2. Add this new created profile to another user as a group profile by using one of the CL
commands:
CHGUSRPRF USRPRF(TBAER1) GRPPRF(CENELEC) or
CHGUSRPRF USRPRF(TBAER1) SUPGRPPRF(CENELEC)
3. Open the Security Center.
4. Sign on as an administrator.
5. In the Groups panel, select the folder-run group that should be associated with the IBM
group profile: Century_Electronics_run.
6. Click the Edit group button or right-click Century_Electronics_run and select Edit as
shown in Figure 6-13.

Figure 6-13 Select the folder-run group Century_Electronics_run

7. The Edit Group dialog box appears, click the Browse button to retrieve a list of IBM group
profiles (see Figure 6-14 on page 181).

180

IBM i DB2 Web Query for i Implementation Guide

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 6-14 Retrieve a list of group profiles

A list of all group profiles appear as shown in Figure 6-15 on page 181.

Figure 6-15 Browse External Groups

8. Select group profile CENELEC and click Add all selected Groups button to add the
selected group profile to the Web Query folder-run group Century_Electronics_run as
shown in Figure 6-16.

Chapter 6. Security Center - Setting up users

181

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 6-16 Add group profile to Selected Groups

The group profile is added to the Selected Groups panel as shown in Figure 6-17 on
page 182.

Figure 6-17 Selected Groups panel with a new group profile

9. Click OK
10.Notice a group CENELEC is now associated with the Web Query Century_Electronic_run
group as shown in Figure 6-18.

182

IBM i DB2 Web Query for i Implementation Guide

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 6-18 Group CENELEC associated with

11.Click OK.
12.Notice the Century_Electronics_run group icon has changed to indicate a linkage to an
IBM i group profile as shown in Figure 6-19.

Figure 6-19 The icon has changed to indicate a linkage to a group profile

Note: Groups are not displayed in the Users in Group pane (see Figure 6-20 on
page 184).

Chapter 6. Security Center - Setting up users

183

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 6-20 Associated group proffiles are not disoplayed in Users in Group panel

13.Click Close to exit the Security Center.


14.Now you have to add group profile CENELEC to all users who should get permission to
run reports in Century_Electronics folder. Use CL command CHGUSRRF as explained
previously.

184

IBM i DB2 Web Query for i Implementation Guide

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

6.7 How to manage users and their attributes


In Security Center you can find an option to manage users and their attributes. You are
authorized to do this, if you are an administrator.This can be QWQADMIN or a user with
authority WebQueryAdministrator.
1. Provided the Security Center is opened, right-click the user in the Users panel.
2. Select any one of the options, as shown in Figure 6-21.

Figure 6-21 Select a user to manage the attributes

New
Creates a new user.
Edit
Edits the user attributes.
Delete
Deletes the user.
Groups
Opens a submenu that contains the following options:

Group memberGroup membership report: Generates a report listing all the


groups to which the user belongs. (See Figure 6-22 on page 186.)

Chapter 6. Security Center - Setting up users

185

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 6-22 Group membership report

Remove from: Opens a dialog box to remove the user from one, more, or all
groups.(See Figure 6-23.)

Figure 6-23 Options to remove users from groups

6.8 Change the owner of a report


When you create a report, by default, you are the owner of this report. By default, this report is
not published, so other users cannot see and run this report.
There are two ways to publish a report:
 Right-click the report you want to publish and select Publish as shown in Figure 6-24 on
page 187.

186

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch06.fm

Figure 6-24 How to publish a report

Or:
 Right-click the report and select Security Owner Select the new owner (see
Figure 6-25 on page 188).

Chapter 6. Security Center - Setting up users

187

8063ch06.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 6-25 Change the owner of a report

Note: You can publish all reports in a subfolder by publishing the subfolder. However,
publish does not work at Top Level Folder level.

Note: All reports which are published, appear in bold font while private content is not bold.

188

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch06.fm

6.9 Preparing steps for the tutorial


In this section we will provide the steps which are necessary to follow the tutorial for a
dedicated user named Simona.
These are the steps:
1. Sign in as QWQADMIN.
2. Open Security Center as shown in 6.1, How to open the Security Center on page 170.
3. Import user Simona to Web Query (see 6.2, Registering user profiles to DB2 Web Query
on page 171).
4. Add user Simona to WebQueryAdministrator group (see 6.3, How to designate a Web
Query Administrator on page 173).
5. Sign out.
6. Sign in as Simona.
7. Create Top Level Folder Century Electronics: This folder will be used for all our tutorials.
a. In the main DB2 Web Query pane right click on WebQuery and select New Folder
as shown in figure Figure 6-26.

Figure 6-26 Create folder - Step 1

b. You are presented with the Create Folder pane. Please type Century Electronics in
the title field. The summary field can be used for a short description with purpose and
containt of this folder (Figure 6-27 on page 189) and select OK..

Figure 6-27 Create folder - Step 2

Chapter 6. Security Center - Setting up users

189

8063ch06.fm

190

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ch07.fm

Chapter 7.

Creating and editing metadata Century Database


While Executive Dan is still in the process of meeting with the other departments to define the
requirements for the Century Challenge BI solution, you already know (based on your past
experience and knowledge of the business applications and database) what tables will be
used as the basis for this solution. As described in Chapter 3, Defining metadata on
page 21, before you can create any report, graph, or dashboard, you must create metadata
(or synonyms) over the target tables. These tables are located in the QWQCENT library and
are named ORDERS, INVENTORY, PLANT, and STORES.
DB2 Web Query is structured to organize objects in folders, which are the container for
reports and the basic level to handle security. Metadata are defined in applications, each one
is related to a folder, and are only accessible/usable by those who are authorized to the folder.
In the previous chapter we created folder Century Electronics - we are now ready to start
creating metadata in the corresponding application.

Copyright IBM Corp. 2012. All rights reserved.

191

8063ch07.fm

Draft Document for Review August 30, 2013 2:37 pm

7.1 Creating metadata using the metadata creation wizard


In most cases you are going to create your own metadata using the provided metadata
creation wizards. To do this, take the following steps:
1. Open a Web browser and enter the URL of the DB2 Web Query home page,
http://<myhost>:12331/webquery.
2. On the DB2 Web Query home page, expand the folder in which you want to work.
Right-click the specific report folder and select Metadata (Figure 7-1).

Figure 7-1 Create metadata - Step 1

3. In the new pane, on the left hand side in the ADAPTERS section select DB2 CLI
*LOCAL, right click on *LOCAL and select Create Synonym, as shown in Figure 7-2.

Figure 7-2 Create metadata - Step 2

192

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch07.fm

If you have configured connection to remote databases or added additional data adapters
they will be presented in the list. To learn more about data adapters refer to 1.4.5, Data
adapters on page 11
4. In the Select Synonym Candidates for DB2 CLI pane (Figure 7-3 on page 193), select the
type of data that you are interested in, We select Tables because we want to create
metadata on tables in QWQCENT, enter QWQCENT in the library field. Click Next.

Figure 7-3 Create metadata - Step 3

5. The Create Synonym for DB2 CLI pane is displayed (Figure 7-4) and shows all the
different tables that reside on the QWQCENT schema. In this panel, set CEN_ in the prefix
field, then select tables INVENTORY, ORDERS, PLANT and STORES.

Chapter 7. Creating and editing metadata - Century Database

193

8063ch07.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 7-4 Create metadata - Step 4

You might want to include a prefix or suffix. In our example, cen_ is our prefix because all
these tables reside in the same library and will be used for the Century Electronics
reporting. We leave the suffix blank, but the developer has the choice to use it. In the
Application field you find the name of the folder in which you are creating metadata,
century_electronics in our tutorials. Click Create synonym.
Prefix and suffix (optional, yet recommended): The prefix and suffix are optional
letters that 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 whether it is
necessary to use the prefix and the naming convention that is preferred. We
recommend that you use the library name or an abbreviated version of the library name
for the prefix. This way, when you create your reports, you can search on all metadata
that starts with the library name.
Keep in mind that all metadata is displayed in one box called Database Descriptions.
The box is small and list the metadata in alfabetical order, not according to library.

194

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch07.fm

The metadata takes a few seconds to create, depending on how many items you selected.
After the processing is done, in the Status column, you see the message Created
successfully, as shown in Figure 7-5

Figure 7-5 Synonyms created

The process of creating metadata is now complete. Close the message box

7.2 Enhancing metadata - join


The metadata you just created will be used in tutorials, but before starting with reports we
may want to enhance them to make reporting quicker and easier to develop, predefing joins
among the various tables we will be using.
Please be aware that many enhancements can be set in metadata:






join relations among tables (),


date decomposition,
defined and computed fields,
filters.
....

We will be showing how to do it when we need to use the various features, in the next
chapters. For details on the various operations that can be perfomed in synonyms please
refer to Chapter 3, Defining metadata on page 21.
Many techniques are available to define joins in synonym - all of them are documented in
Chapter 3.6, Joining database objects on page 50.
Here we are going to use Developer Workbenc and the copy of existing synonym technique:
1. Open Developer Workbench, select the system on which to work and validate with your
userid and password. Please remember that the user must be part of the DevWorkbench
group (use Administration -> Security Center in the web interface to set up). Select
Data Servers -> EDASERVE -> Applications -> century_electronics as shown in
Figure 7-6.

Chapter 7. Creating and editing metadata - Century Database

195

8063ch07.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 7-6 Join in Developer Workbench - Step 1

2. Double click on the synonym you want to enrich with join relationships to open it. In our
example we will change CEN_ORDERS to add joins with the INVENTORY, PLANT, and
STORES tables. Since we will be using copy of existing synonym the synonyms for these
tables must already exist.
3. Right click on the main segment name, CEN_ORDERS in our example, and select Insert
-> Copy of Existing Synonym (Figure 7-7).

Figure 7-7 Join in Developer Workbench - copy of existing synonym - Step 1

196

IBM i DB2 Web Query for i Implementation Guide

8063ch07.fm

Draft Document for Review August 30, 2013 2:37 pm

4. You are presented with a list of synonyms available in the folder where you started to work.
Highlight CEN_INVENTORY and click on Select (Figure 7-8 on page 197). iI you wanted
to use a synonym from a different folder you could locate it using the Find button (#1) at
the top of the screen.

Figure 7-8 Join in Developer Workbench - copy of existing synonym - Step 2

5. On the left hand part of the pane notice the join option. The options can be edited and
changed as necessary using the pull downs and the list items on the side of each
definition. In Figure 7-9 on page 197 you can see what we have selected:
Relation = One-to-One
Type = Inner Join
Condition
CEN_ORDERS.PRODUCTNUMBER=CEN_INVENTORY.PRODUCTNUMBER

Figure 7-9 Join in Developer Workbench - copy of existing synonym - Step 3

Chapter 7. Creating and editing metadata - Century Database

197

8063ch07.fm

Draft Document for Review August 30, 2013 2:37 pm

6. If you want to get a graphical view of the relationship select the Modeling View tab at the
bottom of the screen and hover over the arrow between the tables as shown in
Figure 7-10.

Figure 7-10 Join in Developer Workbench - copy of existing synonym - Step 4

7. When the line connecting the two files is dotted it means that some elements are missing
in the join definition. You can always see and edit the join conditions right clicking on the
line and selecting join properties, as shown in Figure 7-11 on page 199.

198

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch07.fm

Save

Figure 7-11 Join in Developer Workbench - copy of existing synonym - edit condition

8. Save the change using the save icon on the tool bar, highlighted in Figure 7-11.
9. You may receive a message regarding a warning condition (Figure 7-12 on page 199),
select OK to continue saving.

Figure 7-12 Join in Developer Workbench - copy of existing synonym - error message on save

This error message is caused by one of the columns in the Orders tables, which is named
RETURNS. This is a reserved word in SQL. To get rid of this message you have to rename
the field:
10.Get back to the Field View tab, right click on the RETURNS field and select RENAME as
shown in Figure 7-13 on page 200, rename it to RETURNED and save again your
synonym using the SAVE icon.

Chapter 7. Creating and editing metadata - Century Database

199

8063ch07.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 7-13 Renaming a field

Note: Rename in the FIELDNAME (the name used by DB2 Web Query). If you change the
ALIAS the metadata will not work any more. Against logic, the term ALIAS is used to refer
to the actual column name in database!
11.Repeat the process for CEN_PLANT (join field CEN_ORDERS.PLANTCODE =
CEN_PLANT.PLANTCODE) and CEN_STORES (join field CEN_ORDERS.STORECODE
= CEN_STORES.STORECODE) to get the full environment.
12.Save your CEN_ORDERS synonym that now includes references to all of the four tables
that will be used in our scenario. Your CEN_ORDERS synonym Modeling View should
look like Figure 7-14 on page 201.

200

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch07.fm

Figure 7-14 CEN_ORDERS synonym with full joins

13.Close Developer Workbench.


After COPYING the synonym the original CEN_INVENTORY, CEN_PLANT and
CEN_STORES can be deleted unless you want to use them for other purposes.
Note: Please remember that if your report only reference columns in one segment (table)
the product will generate an SQL statement to reference that one object even if the
metadata used has references to multiple segments.

7.3 Date decomposition


In the ORDERS table there are mulitple date columns. One is particular is named
ORDERDATE and represented the date that a specific order was placed. As with many date
fields we will eventually want to break ORDERDATE down and reference the individual
components of order year, order quarter, order month and order day. Breaking a date down
into these components is referred to as Date Decomposition and is a feature that is part of
the Synonym Editor. This feature will create a separate virtual/define field in the synonym for
each of the components. This is very usefull when we have to aggregate and compare
elements based on these basic date components (i.e. compare sales for year xx, on a quarter
basis) without having to code complex formulas and calculations in our reports. By creating
these define field in the synonym, they are immedeiatly available to ALL reports in the folder!
This function can be perfomed either in the web interface or in Developer Workbench. Here
we will be using the web interface. To decompose the ORDERDATE date field:
1. Right click on folder Century Electronics and select Metadata -> Edit as shown in
Figure 7-15
Chapter 7. Creating and editing metadata - Century Database

201

8063ch07.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 7-15 Date decomposition - Step 1

2. Right click on cen_orders and select Open (Figure 7-16 on page 202).

Figure 7-16 Date decomposition - Step 2

3. The synonym editor opens up. Right click on field ORDERDATE and select Decompose
Date (Figure 7-17)

202

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch07.fm

Figure 7-17 Date decomposition - Step 3

4. The synonym gets updated with four new field representing the date base component, as
shown in Figure 7-18.

Chapter 7. Creating and editing metadata - Century Database

203

8063ch07.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 7-18 Date decomposed

5. Save your synonym selecting the SAVE option from the More Options icon pulldown, as
shown in Figure 7-19.

Figure 7-19 Save option

6. Close the synonym editor panel.

204

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch08.fm

Chapter 8.

Assignment #1: Summary


Reports
This chapter provides step by step instuctions to create three summary reports based on the
Century database using the DB2 Web Query InfoAssist tool.
In this chapter we explain how to do the following:
 Create summary reports using the InfoAssist development tool
 Add sort by and sum fields to your report
 Create Define and Compute fields and understand the differences
 Create report headers and footers
 Change the report theme
 Visually ehance the report wit raffic lights and visualation bars
 Add report subtotals
 Publish the report
Prerequisites: Before starting this chapter, make sure the following steps have already
been completed:
 Create synonym over the ORDERS table
 Edit ORDERS synonym and define joins to INVENTORY, PLANT, and STORES tables.
 Edit ORDERS synonym and decompose the ORDERDATE field.
If you have not completed these steps, please go to Chapter 7, Creating and editing
metadata - Century Database on page 191.

Copyright IBM Corp. 2012. All rights reserved.

205

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

8.1 Revenue Summary


Executive Dan has met with the various departments in the organization and has come up
with a set of requirements for the Century Challenge BI solution. The first report in this
solution is a fairly basic one: a summary report that shows revenue and gross profit for each
product category and product type. For this, you will create a define (virtual) field to calcuate
gross profilt. In addition, a report header and footer are required, as is a very useful feature in
BI reporting: traffic lighting to easily spot data outliers in the organization. In this case you are
going to identify the top and bottom gross profit performers.
In this section we explain how to create this report. Once completed, your Revenue and
Gross Summary Report will look as shown in Figure 8-1 below.

Figure 8-1 Final Result of Revenue Summary

8.1.1 Create Revenue Summary Report


Follow steps below to create the revenue report.
1. In the Reporting area, create folder Assignment 01 - Simple Reports. In this tutorial,
the folder is created under Century Electronics folder as in Figure 8-2.
To create new folder, right click on Century Electronics folder, select New Folder.

Figure 8-2 Menu to Create New Folder

2. Expand DB2 Web Query Century Electronics Assignment 01 - Simple Reports.


Right-click the Assignment 01 - Simple Reports folder, which is where you will store your
report, and select New Report as in Figure 8-3.

206

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch08.fm

Figure 8-3 Menu to Open or Create Report

3. The InfoAssist page appears, and you see a list of available data sources (also known as
metadata or synonyms) in Figure 8-4 on page 207. Select CEN_ORDERS and click OK.

Figure 8-4 Data Source Selection Menu

After you choose the CEN_ORDERS table, you see the list of all fields on the Data panel at
the left side of InfoAssist. Be notified that in Data panel synonyms are divided into two groups:
Dimensions, and Measures/Properties.
4. Double click Product Category which is under Dimensions. You see that now Product
Category column appears in Interactive Design View as in Figure 8-5.

Chapter 8. Assignment #1: Summary Reports

207

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-5 Product Category Field

Note: Besides double click, you can also drag and drop the field you want from Data
panel to Interactive panel, or drag and drop it to Query panel (below the Data panel).
5. Drag and drop Product Type.You see an additional menu appears: Drop as Sort and
Drop as Sum. For this tutorial select Drop as Sum as in Figure 8-6.

Figure 8-6 Product Type Additional Menu

208

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch08.fm

6. Double click Revenue which is under Measures/Properties. The Revenue column will
appear on the right side of Product Type column. See Figure 8-7 on page 209 to see the
result.

Figure 8-7 Revenue field

7. Next we create grand total of the report. First, select the Home ribbon and make sure
Report group is expanded so we can see Column Totals and Row Totals function as in
Figure 8-8.

Figure 8-8 Home Ribbon and Report functions

8. Click Column Totals. Selecting Column Totals adds a grand total row in the end of your
report (see Figure 8-9). It will summarize the numeric data in each column.
In the other hand, selecting Row Totals adds a grand total column and put it on the right
side of your report. It will summarize the numeric data in each row.

Chapter 8. Assignment #1: Summary Reports

209

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-9 Grand Total Row in Revenue report

To improve the readability of the report, you can add some formatting to the Revenue column.
9. First, select the Revenue field. You see new menu named Field - Revenue appears as in
Figure 8-10 on page 210.

Figure 8-10 Field-Revenue Ribbon Page

10.Some of the groupings may already be expanded depending on the width of your screen.
In this case you may need to expand the Format group as in Figure 8-10 above (see the
arrow).
11.Select the Comma as in Figure 8-11.

210

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch08.fm

Figure 8-11 Comma Format

Note: For the decimal place, this document is referring to North American standard which
comma refers to thousand, and point refers to decimal.

12.Click on the Currency symbol $ down arrow, and then choose Floating currency as in
Figure 8-12.

Figure 8-12 Currency Symbol

In this case, if you use Non floating currency the symbol will displayed only on the first row of
your report page.
13.The result will be as in Figure 8-13.

Figure 8-13 Revenue result

8.1.2 Add Gross Profit Define Field


At this point, the only measure column in this report is the revenue field. Recall that we also
need to include gross profit, which is defined as revenue minus cost of goods sold. In many
cases, businesses do not store derived fields such as these in the transactional database.
Consequently the formula for gross profit must be defined in either the report or in the

Chapter 8. Assignment #1: Summary Reports

211

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

synonym. Lets do this by first defining it in the report as a define field. Later you will move this
to the synonym so that all reports in this folder have immediate access to the gross profit field.
Note: Gross Profit formula is: Revenue - Cost of Goods Sold
1. Still using the same report, click Data on the menu bar to open Data ribbon as in
Figure 8-14.

Figure 8-14 Data Ribbon

2. Click Detail (Define) as in Figure 8-14 above. A new window pops-up.


3. Type Field name as Gross_Profit as in Figure 8-15.

Figure 8-15 Detail Field (DEFINE) menu

4. Click the Format button, and format it as Integer with Floating Currency (M) and Comma
(C). The field length should be 10. The Format page should as in Figure 8-16 below.

212

IBM i DB2 Web Query for i Implementation Guide

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-16 Field Format Options for Gross_Profit Define

5. Click OK.
Another way to do this formatting is by directly type I10MC in the format field as in
Figure 8-17.

Figure 8-17 Advance Format Field

6. In the Detail Field, create the gross profit formula by double click the Revenue followed by
typing - which means substract, then double click Cost of Goods Sold.
The filled result as in Figure 8-18 on page 214.

Chapter 8. Assignment #1: Summary Reports

213

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-18 Gross Profit Define Field

7. Click OK.
8. If you see Interactive Design View, nothing is changed in the view. In the Data panel,
expand Measures/Properties. Here you will find the new field named Gross_Profit.
9. Drag and drop Gross_Profit to the next field of Revenue as shown in Figure 8-19.
Gross_Profit
Location

Figure 8-19 Gross_Profit Field

10.After you put Gross_Profit field in the Interactive Design View, you see that Gross_Profit
field is already formatted with comma and floating currency. Recall that you defined this
formatting when you created the Gross_Profit field definition. Instead of defining the
formatting in the define field you could have formatted this field is by right clicking on the
Gross_Profit field in the interactive design view. From the right click menu, select Edit
Format as in Figure 8-20 on page 215.

214

IBM i DB2 Web Query for i Implementation Guide

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-20 Alternative Format field

11.Field Format Options menu pops up, and it exactly the same window as you see when you
define the format on the first time. Fill the Field Format Options as in Figure 8-21 and click
OK.

Figure 8-21 Field Format Options for Gross_Profit

Note: What we explain here is there are several way to do numbers formatting in the field:
 using Format menu from the field specific ribbon;
 define the format when first time we create definition of the field;
 or, do right click directly in the field from Interactive Design View panel.
12.The result as in Figure 8-22 on page 216.

Chapter 8. Assignment #1: Summary Reports

215

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-22 Summary Report including Gross_Profit field

8.1.3 Add Header and Footer


As we finish to create the gross profit report, the next step is to add header and footer in
report so that the report consumer can knows what information is provided in the report.
1. Select the Home ribbon, and expand Report if it is not already expanded.
2. On the Report ribbon, select Header & Footer Report Header as in Figure 8-23.

Figure 8-23 Header and Footer menu

3. The Header & Footer menu appears. You can either type in the name of the report, or you
can use a system variable that will insert the actual name of the saved report into the
selected area. For this report, lets use the system variable. Type &MR_FULL_FEXNAME
in the Report Header page as in Figure 8-24. Click OK.
Note: &MR_FULL_FEXNAME is an example of a DB2 Web Query system variable.
System variables are predefined and automatically supplied by the system when a
procedure references them. For a complete list of system variables, see Appendix B,
DB2 Web Query System Variables on page 831

216

IBM i DB2 Web Query for i Implementation Guide

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-24 Report Header menu

Note: For now, &MR_FULL_FEXNAME doesnt have a value because the report has not
yet been saved. To resolve this variable, the report must be saved, and run the report from
DB2 Web Query Reporting page.

4. Next step is to create footer using Page Footer function. As in previous step, choose:
Home Report Header & Footer Page Footer.
5. For this Page Footer sample, we use preformatted text content function which is another
alternative of configuring header and footer. Preformatted text content function is as in
Figure 8-25.

Figure 8-25 Preformatted Text Content menu

6. In this sample choose Date Tue, Jun 12, 2012 as in Figure 8-25 on page 217. Variable
&DATEt, &DATEtM &DATED, &DATEYY appears in the blank page as in Figure 8-26.
Click OK.

Figure 8-26 Setting Variable for Date using preformatted text content

Note: Go to Appendix A, Date and time functionality on page 781 to see a list of all
the date and time formats that you can use.

7. In the end of the report you see current day and date. See Figure 8-27 for the date result.
Chapter 8. Assignment #1: Summary Reports

217

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-27 Page footer result

Note: If you see Header & Footer menu, you realize that there are two types of header and
two types of footer. Each has Report and Page. The difference are:
 Report header and report footer only appears once in the report. Report header
appears only in the beginning of the report, and report footer appears only in the end of
the report. So if you create a report which needs more than one page to view, report
header appears in the first page, and report footer appears in the last page.
 Page header and page footer appears in every page of the report.

8.1.4 Change Theme


When you first create a report, the look and style of the report is inherited from the default
theme. In some cases you may want to override this theme and select a different one. DB2
Web Query comes with many themes you can choose to make it more interesting. Follow
these steps below to change your report theme.
1. Go to Home Report Theme. A new page pops-up.
2. Experiment with different themes to see if there is one you like. Do this by selecting a
theme and clicking the Open button.
3. For our report we want to use the ENgray_theme.sty as in Figure 8-28 on page 219.

218

IBM i DB2 Web Query for i Implementation Guide

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-28 Themes

8.1.5 Add Traffic Lighting


A common feature in BI tools is something called traffic lighting. A report developer can define
conditions in the data that exceed or fall below specific thresholds. When this occurs, ta
different color or font can be used to make that component in the report more visible to the
report consumer. Traffic lighting allows the consumer to easily spot outliers, top and bottom
performers, and other conditions which might need immediate attention.
Follow steps below in how to use Traffic Lights functions in gross profit field where you will:
 Display a green color if the gross profit value is more than 25 million dollars
 Display a red color if the gross profit value is less than 10 million dollars.
1. Click Gross_Profit field in the Interactive Design View. You find that theres menu named
Field - Gross_Profit.
2. Click on Display menu if it is not yet expanded. You can find Traffic Lights menu as in
Figure 8-29.

Chapter 8. Assignment #1: Summary Reports

219

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-29 Traffic Lights menu

3. Click Traffic Lights Menu.


4. A Traffic Light Condition menu for Gross_Profit appears. Fill the fields as Figure 8-30 on
page 220 below to fulfill the condition as mentioned before.

5
6

Figure 8-30 Traffic Light Condition menu

Below is explanation of each button or field in Traffic Light Condition menu:


1. The button to add new condition of the traffic lights. In this tutorial you need to use the
button since you use two conditions for the report;
2. The button to delete condition;
3. The button to add styling if value of the field fulfill the condition. In this example, if a
records gross profit value is greater than 25 million, the you have to configure the field to
be green highlighted;
4. The button if you want to add more action if the condition is fulfilled. For example, you can
refer the field to another report;
5. The active status of the condition. In picture Figure 8-30 above the current active status is
the first condition so you can delete or add styling in this condition;
6. The condition itself. Traffic lights provide so many conditions: equal to, not equal to,
greater than, less than, greater than or equal to, less than or equal to.
7. The preview of style you made for each condition
8. Click OK.
9. You go back to Interactive Design View and see that all gross profit value are in red
highlight. This is because Interactive Design View only fetch the first 500 records which

220

IBM i DB2 Web Query for i Implementation Guide

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

might doesnt represent the real condition. To see the real result, you should run the
report.
10.Click Run button as in Figure 8-31 below.

Figure 8-31 Run button

11.A new tab named Report1[0] appears. You see that now gross profit column has green
and red highlighted values. But you also notice that the header still doesnt have any
meaning.
To solve this thing, save the report and go to DB2 Web Query Reporting page to run the
report.

Figure 8-32 Run Report from Interactive page

12.Close Report1[0] tab.


13.Save the report by clicking IA button on the top left side as in Figure and choose Save.
Name it 1a-Revenue Summary by Product Category.

Chapter 8. Assignment #1: Summary Reports

221

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-33 Save report

14.Go to DB2 Web Query Reporting Page. Expand DB2 Web Query Century
Electronics Assignment 01 - Simple Reports. You find there is one new report you
just created.
15.Right click on 1a-Revenue Summary by Product Category. Then click Run.

Figure 8-34 Run the report from the Reporting page

16.The report result will be as Figure 8-35 below. Now you see that the report header has
change to something meaningful. The report header represents report name.

222

IBM i DB2 Web Query for i Implementation Guide

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-35 Run Report Result from Reporting page

17.Close InfoAssist

8.1.6 Publish the report


At this point, as the report developer, you are the only DB2 Web Query user that can access
and run this report. This is because the report has not yet been published. After careful
examination of both the requirements and the the report output, you are confident that the
report is ready for all DB2 Web Query users (authorized to the top level folder) to access and
run. To give them access to the report, you must now publish it.
1. To publish the report, go to DB2 Web Query page and expand the Assignment 01 folder.
Right click the 1a-Revenue Summary by Product Category report and select Publish.

Chapter 8. Assignment #1: Summary Reports

223

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-36 Publish The report

Notice that soon after you publish the report, the font in the menu will change to bold. This
allows you to easily differentiate between published and unpublished content.

8.2 Top 10 (Ten) Products by Margin


The next report that Exective Dan wants you to create is one that displays the top ten product
names by profit margin in descending order. This report should have the rank based on profilt
margin, the product name, product category, and product type. In addition to profit margin, the
measure fields to be included are revenue and gross profit. He would also like you to include
data visualization bars for Revenue and Gross_Profit fields.
After you finish the tutorial in this section, you will be able to create report as in Figure 8-37 on
page 224 below.

Figure 8-37 Top 10 Products by Margin

Because this report is very similar to the report created in Chapter 8.1, Revenue Summary
on page 206 above, you can save yourself some time by simply editing that one as saving it
as a new report.
224

IBM i DB2 Web Query for i Implementation Guide

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

8.2.1 Open and save a new copy of the report


1. If you closed the report you created in Section 8.1, re-open it by selecting DB2 Web
Query Century Electronics Assignment 01 - Simple Reports 1a - Revenue
Summary by Product Category Edit With InfoAssist from DB2 Web Query page
as shown in Figure 8-38.

Figure 8-38 Edit Existing Report using InfoAssist

2. Because we are making multiple changes to the original report and saving it as a new
copy, we want to avoid over writing the original report. Save the report with the new name
by clicking Save As under IA button as in Figure 8-39 on page 225, and naming it 1b Top 10 Products by Margin.

Figure 8-39 Save As menu

8.2.2 Add By Field


1. Now you are ready to make changes specific to this report. The first thing you need to do
is make the Product Name field the first sort by column in the report. Drag and drop
Product Name field to the left most part of the report, so Product Name will be the
first-sort-by field. Figure 8-40 below shows how it looks in the first few records.

Chapter 8. Assignment #1: Summary Reports

225

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-40 Product Name Field as the First Sort By

2. This report does not require any traffic lighting. So first remove the traffic light function in
Gross_Profit field. First, select Gross_Profit field in the Interactive Design View panel,
then select Field - Gross_Profit Display Traffic Lights in menu panel.
3. Delete two conditions you have made previously by using Delete button. See Figure 8-41.
After delete the two conditions, you find that there are no highlights in Gross_Profit field.

Figure 8-41 Delete Conditions in Traffic Lights

8.2.3 Create Define and Compute Field


In this section you learn how to create Profit Margin field using Define and Compute field.
1. The next step is to create a new Profit Margin field using Define function. First, click Data
on the toolbar to open the Data ribbon, then click Detail (Define) button to show Define
field menu.
2. Profit Margin formula is : (Gross Profit / Revenue) x 100%. So the filled Define field will be
as Figure 8-42 on page 226 below. Name this Define field as : Profit_MarginD.

Figure 8-42 Define field

3. After you finish filling in the Define field, click OK.


4. In the Data panel you find the new field named Profit_MarginD.

226

IBM i DB2 Web Query for i Implementation Guide

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-43 Profit_MarginD field in Data panel

5. Drag and drop Profit_MarginD to the right-most side of the report.


6. Run the report.
7. Figure 8-44 below shows the sample result of profit margin using Define function.

Figure 8-44 Profit Margin Calculation using Define Field

Notice the highly inflated values of the ProfitMarginD column. Either business is extremely
good at Century Electronics or the calculation for profit margin is not correct. In this case, it is
the latter: the profit margin calculation using Define field is incorrect. The reason why requires
an explanation and understanding of the differences between Define and Compute fields. To
illustrate this, create another new profit margin field using Compute function.
8. Repeat the same steps above for creating the profit margin field, however this time select
the Summary (Compute) button as demonstrated in Figure 8-45

Figure 8-45 Create Compute field

9. Name this new field as Profit_MarginC, and use the same formula as you did above for
the define field above as shown in Figure 8-46 below.

Figure 8-46 Compute field

Chapter 8. Assignment #1: Summary Reports

227

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

10.Click OK.
11.Notice that there is new field named Profit_MarginC that appears on the right side of
Profit_MarginD. Unlike Define fields, Compute fields are automatically added to your
report when you create them.
12.Run the report,
13.As shown in Figure 8-47, notice that Profit_MarginC has more realistic values for a profit
margin column. These are in fact, the correct values.

Figure 8-47 Profit Margin Calculation using Compute field

So why, in the case of Profit Margin, are the values incorrect for a Define field yet correct for a
compute field? After all, the formulas you specified for both were identical!
The reason for this is because of the difference in behavior between Define and Compute
fields. Define fields are calculated (evaluated) for every row retrieved by the report.
If your query retrieve 1,000 rows from the ORDERS table, then 1,000 distinct values of that
virtual defined field are generated. This happens even if your report does not report at the
lowest detail level, meaning the values will be executed and then aggregated. Once these
values are evaluated, they are summed at the Sort By level. So you are effectively calculating
the gross profit margin for every order and them adding them all together and displaying that
summed value for each row (product name) in the report. Hence the inflated values for each
product name.
Now contrast that with how Compute fields work. The calcuation for a compute field does not
occur until after DB2 Web Query has retrieved, sorted, and aggregated (grouped) the rows.
This means that all of the reports measures (numeric field values) are aggregated (based on
the specific sort by columns), and only after this aggregation has occured are the computed
field values calculated. So in this case profit margin is not evaluated until each of the products
have been aggregated. For each product name, the aggregated gross profit value is divided
by the aggregated revenue value, and the correct profit margin value is displayed.
Note: When the report is at the individual-row level, computed field will have the same
result as defined field. Aggregation is what makes the difference.
14.For the next step of this tutorial, you use Profit_MarginC field since in this report
Profit_MarginC is the one that provide the correct calculation.
15.Delete Profit_MarginD in the report table.
16.Move Profit_MarginC by dragging it to left side of Revenue field. The result in Interactive
Design View will be as Figure 8-48 below.

228

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch08.fm

Figure 8-48 Report with Compute Profit Margin only

17.Notice that the current report you have is sort by Product Name in ascending order. The
requirement was for the Top 10 Rank report to be sorted in descending order by Profit
Margin. Change the report by making Profit_MarginC as the primary sort field in
descending order.
18.Right click on the Profit_MarginC, select Sort Sort Descending as shown in
Figure 8-49 below.

Figure 8-49 Sort menu

19.Run the report by click Run button. The result will be as shown in Figure 8-50 below.

Figure 8-50 Report sorted by Profit Margin in descending order

8.2.4 Add Rank to Profit Margin


In this section you learn how to add a rank column to the report. To rank the rows based on
profit margin, take the following steps:
1. From the Query panel, click Profit_MarginC in the By area. See Figure 8-51 on
page 230. This is actually an alternative way to set the ribbon to be Profit_MarginC
specific.

Chapter 8. Assignment #1: Summary Reports

229

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-51 Profit_MarginC in Query panel

2. Click the Rank button in the Sort group as in Figure 8-52.

Figure 8-52 Rank menu

3. In the Interactive panel you see that new field named RANK appears in the left-most side
of the report. This field put ranks of all records in the report table.
4. But since you only want the report to display only the top 10 products, change the limit of
the rank to 10.

Figure 8-53 Rank Limit to 10

5. Run the report, and you see the report now only contains 10 records which are the
products with 10 best profit margin in descending order as in Figure 8-54 below.

Figure 8-54 Top 10 Products order by Profit Margin

230

IBM i DB2 Web Query for i Implementation Guide

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

8.2.5 Add Data Visualization Bars


The next report requirement is to include data visualization bars for the Revenue and
Gross_Profit columns. The benefit of using data visualization bars is so you can graphically
represent numeric column values using bars that are longer as the column value is larger .
This feature allows you to easily compare values between two or more columns.
1. Select the Revenue field to. This will change the ribbon to the Field - Revenue tab in the
ribbon.
2. Expand Display group menu, and click Data Bars as in Figure 8-55.

Figure 8-55 Data Bars Menu in Display group

3. You see that data bars appears on the right side of Revenue values as in Figure 8-56.

Figure 8-56 Revenue data bars

4. Repeat the same steps for Gross_Profit to shows Data Bars as in Revenue Data Bars
steps.
5. Run the report, and you see the final report as in below.

Figure 8-57 Top 10 Profit Margin Report with data bars

6. Save the report


7. Close InfoAssist page.

Chapter 8. Assignment #1: Summary Reports

231

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

8.3 Revenue Summary with Subtotals


The third summary report Executive Dan wants you to develop is one that displays
Gross_Profit subtotals for each product category.
After you finish the tutorial in this section, the finished product will look something similar to
the example shown in Figure 8-58 below.

Figure 8-58 Revenue Summary with Subtotals

Once again, for similar reports, you can avoid repeating manual development steps by
making a copy of an existing report. For this tutorial, use the report created in Chapter 8.1.
1. Open the 1a - Revenue Summary by Product Category report using InfoAssist.
2. For the purpose of tutorial in this section, remove Traffic Lights function in Gross_Profit
field. See Chapter 8.2 in how to remove Traffic Lights function.
3. Drag Product Type field to the left-most side of the report in the Interactive Design View
panel. Now Product Type become the primary sort field as in Figure 8-59.

Figure 8-59 Revenue Summary Report Sorted by Product Type

232

IBM i DB2 Web Query for i Implementation Guide

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

4. Drag Product Name field from Data panel to the right side of Product Category. Choose
Drop as Sort. This makes Product Name the third sort field.
5. In Interactive Design View panel, the report looks like as in Figure 8-60.

Figure 8-60 Revenue Summary Report with Product Name field

6. Next step is you create subtotals of all numeric fields based on Product Category.
7. To do this, click on the Product Category field to have Field - Product Category ribbon
shows up.
8. Expand Break group ribbon, and select Subtotal Recomputed as in Figure 8-61.

Figure 8-61 Subtotal menu

9. Run the report. The result for the first three Product Category will be as in Figure 8-62 on
page 233.

Figure 8-62 Summary Report with Subtotals based on Product Category

10.You see that in Figure 8-62 the subtotals applied for both Revenue and Gross_Profit field.

Chapter 8. Assignment #1: Summary Reports

233

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Note: Subtotal menu has two functions: Simple and Recomputed. The difference
between Simple and Recomputed is: Simple will just add all value within a column, while
Recompute will do the aggregation of all value in the column and do calculation in the end.
Use Recompute if you want to calculate a percentage.
See the next two figures to further understand the difference between Simple and
Recomputed. The sample report we use is revenue report with subtotals based on Product
Type.
if you see Figure 8-63 which is created using Simple, subtotals for Revenue and Gross Profit
in each Product Type shows the correct value while Profit Margin (which is made using
Compute field) showing the incorrect value. This is because Simple subtotals only add value
of all the columns. So, the profit margin percentage for Audio is just the result of adding profit
margin result from each Audio category.

Figure 8-63 Subtotal Using Simple

But if you see Figure 8-64 which is created using Recompute, all values including Profit
Margin shows the correct values. This because Recompute do the calculation after the value
aggregation is done. So for Audios Profit Margin, Recompute will do profit margin calculation
based on the subtotal result of Audios Revenue and Gross Profit.

234

IBM i DB2 Web Query for i Implementation Guide

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-64 Subtotal Using Recompute

Notice that on both above figures, the TOTAL value in the last row of the report shows the
correct value. This is because TOTAL value is created using Compute.
11.Next step we discuss how to have the subtotals for Gross_Profit field only, and do small
change in the subtotal title.
12.To do this, go back to Subtotal menu, but this time choose More Options... as in
Figure 8-65.

Figure 8-65 Subtotal menu with More options choice

13.A Subtotal for Product Category menu shows up.


14.Un-check Subtotal all fields Column, and check Gross_Profit Column.
15.If you see the Prefix Column, you find that there are several choice for Prefix. In this
tutorial leave the Prefix column as Sum.
16.Change the Current Subtotal text from Subtotal: to Subtotal for.
17.The filled Subtotal menu will be as Figure 8-66 below.

Chapter 8. Assignment #1: Summary Reports

235

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-66 Subtotal menu for Product Category

Note: Notice that Subtotal prefix has many options. This shows that Subtotal function is not
only to sum up the numeric values but, for example, it can also set the average of all value
within the column using Average function. Try to test the prefixes one by one to know the
difference between one prefix to another.
18.Click OK
19.Run the report. The result for the first three Product Category will be as in Figure 8-67.
Compare it with the report with Revenue and Gross Profit Subtotals.

Figure 8-67 Summary Report with Gross Profit Subtotals based on Product Category

20.Repeat steps above to add create subtotals based on Product Type. Figure 8-68 shows
sample revenue report with subtotals on both Revenue and Gross_Profit field based on
Product Type.

236

IBM i DB2 Web Query for i Implementation Guide

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-68 Sample Summary Report with Subtotals based on Product Type

Figure 8-69 on page 238 shows sample revenue report with subtotals only on Gross_Profit
field based on Product Type.

Chapter 8. Assignment #1: Summary Reports

237

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-69 Sample Summary Report with Gross Profit Subtotals based on Product Type

21.Save As the report, and name it 1c - Revenue Summary with Subtotals.


22.Close InfoAssist page.
23.Publish 1c - Revenue Summary with Subtotals report. To know how to publish the report
go to last part of section 8.1.5, Add Traffic Lighting on page 219.

8.4 Simple Revenue Report Group by Year


In this chapter we discuss on how to create simple revenue report group by year. This report
is used to learn how to create and use dashboard feature in DB2 Web Query.
After finish this section, you will be able to create report as in Figure 8-70 below.

Figure 8-70 Simple Revenue Report Group by Year

238

IBM i DB2 Web Query for i Implementation Guide

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Follow steps below to create the report.


1. Create new report in Assignment 01-Simple Reports folder. To create it, right click in
Assignment 01-Simple Reports and select New Report.
2. Choose CEN_ORDERS data source, and click OK.
3. Drag Product Type from Data panel to By in Query panel as in Figure 8-71. This means
Product Type is the primary sorting field.

Figure 8-71 Move Product Type from Data Panel to Query panel

4. Next, drag Revenue and Returns from Data panel to Sum in Query panel.

Figure 8-72 Move Revenue and Returns from Data Panel to Query panel

Chapter 8. Assignment #1: Summary Reports

239

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

5. Since you create the revenue report group by year, then you have to add year of order
date to the report. To do this, drag ORDERDATE_YEAR from Data panel to Across in
Query panel.

Figure 8-73 Move ORDERDATE_YEAR from Data Panel to Query panel

6. Add grand total of the report


7. In the Interactive Design View you get the report as in Figure 8-74.

Figure 8-74 Report Result in Interactive Design view

8. Add some formatting in Returns and Revenue field with Comma and Non floating
Currency.
9. Run the report. The result as in Figure 8-75.

240

IBM i DB2 Web Query for i Implementation Guide

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-75 Report result

10.Save the report and name it 1d - Revenue and Returns by Type.


11.Close InfoAssist page.
12.Publish 1d - Revenue and Returns by Type report. To know how to publish this report, go
to last part of 8.1.5, Add Traffic Lighting on page 219.

8.5 Creating Define and Compute fields in the Synonym


Previously in this chapter you created the gross profit define field and the profit margin
compute field in the reports using InfoAssist. This is fine, but consider that these are likely
fields that you will be including in many different reports and charts in the future. Rather than
re-create them over and over again in each report and chart, a best practice is to move the
definition of these derived fields to a central location so that all reports and charts have
immediate access to them. Doing so miminizes report maintenance and decreases(or
perhaps eliminates) the chance that an incorrect formula is specified for the fields. This can
be done by defining these fields in the metadata layer of DB2 Web Query. In this section you
create a these fields in the synonym of the ORDERS table.
The tool that you use to create these derived field is the Synonym Editor. You can access the
Synonym Editor through the DB2 Web Query Developer Workbench tool, or through DB2
Web Query synonym console from a web browser.This chapter discuss about how to create a
field using web based Synonym Editor.

8.5.1 Create Profit Field Using Define Field


In section 8.1.1, Create Revenue Summary Report on page 206 you created the
Gross_Profit Define field in InfoAssist. In this section you will create the same Define field
definition in the ORDERS synonym using the Synonym Editor. To distinguish the two, instead
of using Gross_Profit name, we will use the field name of Profit in the synonym.
The Profit formula is the same as before: Revenue - Cost of Goods Sold.
Follow steps below to create the new Profit field.
1. To open the Synonym Editor, go to DB2 Web Query page. Right click on the Century
Electronics folder and select Metadata Edit. See Figure 8-76 on page 242 below.

Chapter 8. Assignment #1: Summary Reports

241

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-76 Edit Synonym menu

2. A new page showing all synonyms you have appears. Right click on the CEN_ORDERS
and choose Open as in Figure 8-77 and it will redirect you to Synonym Editor page.

Figure 8-77 Open CEN_ORDERS Synonym

3. On the left panel, go to the bottom part of the panel and you can see Constant
Defines/Computes folder. Right click on it and choose Insert Define as in Figure 8-78.
This is the menu to create new Define field.

Figure 8-78 Create Define menu

4. On the right panel new fields appears. Fill in the fields as in Figure 8-79 on page 243
below. Click Apply after you finish fill in all the fields.
Notice that EXPRESSION field is filled with the formula of Gross Profit.

242

IBM i DB2 Web Query for i Implementation Guide

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-79 Define field information

Notice that the Type field is Decimal Packed. Decimal Packed is chosen since Revenue and
Cost of Goods Sold also has Decimal Packed type. You can check the properties of Revenue
and Cost of Goods Sold by right click on the field and choose Properties.
Please also notice that you have to put the right value in Length field. For example, if you set
the length as 11 while the value of your Gross Profit field reach millions (eg: 2,000,000.00)
then the Gross Profit field will not return the right value. Instead of returning numeric field, it
will just return a series of stars (********) showing that the defined field length is too short.
Note: Bear in mind that comma, period, and decimal also part of field length that should be
calculated. So numeric 2,000,000.00 need 12 field length.
In the end of this section you will be provided example of report where the defined field length
is too short.
5. Notice that you cannot find Profit field that you just created in the Constant
Defines/Computes folder. You can find it under the CEN_ORDERS.

Chapter 8. Assignment #1: Summary Reports

243

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-80 Profit field

6. Save the Synonym before you close the Synonym Editor.

Figure 8-81 Save the Synonym

7. To see whether the created field return the right number or not, you can create a new
report and use this new Profit field. See example of simple report below.
Figure 8-82 shows the correct Gross Profit length since it returns correct numeric value.

Figure 8-82 Sample Report with correct profit length

While Figure 8-83 shows the wrong Gross Profit length since Gross Profit for Audio,
Camcorders, and Video numeric value is not showed.
244

IBM i DB2 Web Query for i Implementation Guide

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-83 Sample Report with incorrect profit length

So, you have to be very careful when putting the length for your defined field.
Note: You can add comma formatting and currency as part of field definition when you
create it in the Synonym Editor.

8.5.2 Create Margin Field Using Compute Field


During the making of this Redbook the authors were debating about what is the correct
formula of gross profit margin. Is it (gross profit/cost of goods sold)*100% or (gross
profit/revenue)*100%.
In section 8.2.3, Create Define and Compute Field on page 226 you have learn to create
profit margin using Compute field with (gross profit/revenue)*100% formula.
In this book, we dont want to focus on which formula is correct. So to accommodate both
formulas in this section you learn about how to create profit margin field using Compute field
by using (gross profit/cost of goods sold)*100% formula.
Follow steps below to create the new profit margin field.
1. As usual, to open the Synonym Editor, go to DB2 Web Query page. Right click on the
Century Electronics folder and select Metadata Edit.
2. Open CEN_ORDERS synonym.
3. In the Constant Defines/Computes folder, choose Compute instead of Define.

Figure 8-84 Create Compute menu

4. Fill in the fields as in Figure 8-85 on page 246 below. Click Apply after you finish fill in all
the required field.

Chapter 8. Assignment #1: Summary Reports

245

8063ch08.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 8-85 Compute Field Information

5. Save the Synonym.


6. Notice that Margin field you created is under Constant Defines/Computes.

Figure 8-86 Margin field

7. Test the Margin you just created by creating a simple report as shown in below.

Figure 8-87 Simple Report using Margin field

246

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch09.fm

Chapter 9.

Assignment # 2: Implementing
Various Date Functions in
Reports
Dates are fundamental reporting elements in Business Intellgence. Many reports and charts
would be meaningless if you were not able to include date components to examine business
trends over time and compare your business results year over year. This chapter describes
several ways to include assorted date components in reports using a variety of functions and
techniques.
In this chapter you learn how to do the the following:
 Change the default theme/style of the reports you create
 Use aggregation functions
 Edit column titles
 Create a define field for the name of the month using DB2 Web Query functions
 Create a define field for week of the year using SQL prefixing.
 Add a join to a date table to include season of the year column

Prerequisites: Before starting this chapter, make sure the following steps have already
been completed:
 Create synonym over the ORDERS table
 Edit ORDERS synonym and define joins to INVENTORY, PLANT, and STORES tables.
 Edit ORDERS synonym and decompose the ORDERDATE field.
If you have not completed these steps, please go to Chapter 7, Creating and editing
metadata - Century Database on page 191.

Copyright IBM Corp. 2012. All rights reserved.

247

8063ch09.fm

Draft Document for Review August 30, 2013 2:37 pm

9.1 Dates Using DB2 Web Query Functions


After reviewing the reports you delivered for Assignment 1, Executive Dan was was pleased
with the results. However, the various departments at Century need additional reports with
assorted date components implemented in them to help analyze store purchasing trends
during specific periods of the year. In this chapter you will create a set of queries for the
second assignment: reports that utilize and implement various ways of extracting and
displaying date components.
The first report requirement in this assignment is to help the determine the number of orders
made in each store for each month of the year over over the last 2 years. This report should
be sorted by country, region, store name, and name of the Month. The measure field is
number of orders placed - of which there should be separate columns for the year of the
order. Having these measures side by side over year allows the report consumer to easily
compare the numbers year to year. When you have finished this report, it will look similar to
the report shown in Figure 9-1 below.

Figure 9-1 Report Result using DB2 Web Query Date function

9.1.1 Change Report Theme


Before use date function, follow these steps below to learn how to change report theme.
1. Since this is a new assignment, create new assignment folder under Century Electronics
folder. To do this, right click Century Electronics folder and select New Folder as in
Figure 9-2.

248

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch09.fm

Figure 9-2 Create New Folder for Assignment 02

2. Name the new folder with Assignment 02 - Implementing Various Date Functions in
Reports.
3. Next, create new report under Assignment 02 folder. To do this, right click Assignment
02 - Implementing Various Date Functions in Reports and select New Report as in
Figure 9-3.

Figure 9-3 Create New Report

4. Choose CEN_ORDERS data source.


5. Before you start to create the report, first you have to change the theme. Click Home
menu, and on the Home menu ribbon select Theme as in Figure 9-4.

Figure 9-4 Select Theme function

6. A Template menu pops up as in Figure 9-5. Choose ENgray_theme.sty as the theme.


Click Open.

Chapter 9. Assignment # 2: Implementing Various Date Functions in Reports

249

8063ch09.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 9-5 Select Specific theme

The theme changes you have done above is only specific for report you currently create.
So if you create another new report the theme will go back to the default theme. You as a
developer can actually change the default theme to any other themes so all reports you
create will use this specific theme without having to change it repeatedly when creating a
new report.
7. Recall that you changed the theme of the reports in assignment 1. You can either do this
for every individual report, or you can save yourself some time by making a specific theme
the default one for each and every report you create. To do this, click on the IA menu
button on the top left side of the IA window and choose Options as demonstrated in
Figure 9-6.

250

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch09.fm

Figure 9-6 Options button

8. Options menu pops-up as in Figure 9-7 below. See Environment and Styling section. On
the Document Theme, click Browse and locate ENgray_theme.sty file, or any file theme
you like.

Figure 9-7 Options menu

9. After you change the Document Theme, click OK.

Chapter 9. Assignment # 2: Implementing Various Date Functions in Reports

251

8063ch09.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 9-8 ENgray_theme.sty selected

10.Now all the report you create in the future will use the Engray_theme style by default!

9.1.2 Using Aggregation Function


The report you will create in this section displays the total number of orders made by each
store in each month. For this, you will use an aggregation function to calculate the number of
unique orders.
1. To start create the report, add these fields to the Interactive Design View in a sequential
manner : Country, Region, Store Name. You can do it by double click the these fields, or
drag and drop it from Data panel to Query panel under By section.
In this case, Country is the primary sort-by field followed by Region and Store Name as in
Figure 9-9 on page 252.

Figure 9-9 Country, Region, Store Name Fields as Sort By

2. Next step is put ORDERDATE_YEAR field as sort across field. Drag and drop
ORDERDATE_YEAR to Across under Query panel as in Figure 9-10.

252

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch09.fm

Figure 9-10 ORDERDATE_YEAR as sort across

3. Add Order,Number field as Sum to Query panel. See Figure 9-11.

Figure 9-11 Order,Number as Sum

4. Next you change the Order,Number field as count (count the amount of OrderNumber)
using Aggregation function.
To do this click on OrderNumber field in Interactive Design View or Query panel. Then
from Field - Order,Number ribbon expand Display group menu.
5. Aggregation function is part of Display group menu. Click on Aggregation and select
Count as in Figure 9-12.

Chapter 9. Assignment # 2: Implementing Various Date Functions in Reports

253

8063ch09.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 9-12 Aggregation function

6. Still on Order,Number field (which the name in Query panel is changed to


CNT.Order,Number) change its format to Integer. To do this, go to Field-Order,Number
menu ribbon and expand Format group menu. Find the Alphanumeric menu and change it
to Integer as in Figure 9-13.

Figure 9-13 Change CNT.Order,Number Column Format to Integer

7. Add comma to CNT.Order,Number field using Comma function in Format group menu.
8. After finish with formatting the column, change ORDERDATE_YEAR column title with
Number of Orders. To do this, go to Query panel and right click on
ORDERDATE_YEAR. Select Change Title as in Figure 9-14 on page 254.

Figure 9-14 Change Title menu

9. After you type the new title, click OK. Figure 9-15 shows the Edit Title dialog window.

Figure 9-15 OrderDate_Year new Title

254

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch09.fm

9.1.3 Add Month Name as Define Field


Next step is you modify the report so the number of order count will also sorted by month. So
you can know exactly how many orders are made for each month in each store.
1. To do this, first you have to create a new field using Define function in Data ribbon menu.
Click on the Detail (Define) function.

Figure 9-16 Detail (Define) Function in Data Ribbon

2. You see Define menu shows up. Fill the fields as Figure 9-17 below and click OK.

Figure 9-17 Define field

3. BecauseMonthName is Define field, you can find it in the Data panel under Dimension.
Drag and drop MonthName to Query panel in sort By, right after Store,Name.

Chapter 9. Assignment # 2: Implementing Various Date Functions in Reports

255

8063ch09.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 9-18 MonthName field position in the report

4. Run the report. Sample of few rows of the report can be seen on Figure 9-19 on page 257.
Notice that now you have amount of order numbers grouped by month.

256

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch09.fm

Figure 9-19 Run Report sample result

5. To complete this report, add Report Header and titled it Monthly Orders by Country,
Region, Store.
6. Save the report and name it 2a-Monthly Orders by Country, Region, Store.
7. Publish the report you have made. To do this, go to DB2 Web Query page and right click
in the report you just created. Select Publish as in Figure 9-20 on page 258.

Chapter 9. Assignment # 2: Implementing Various Date Functions in Reports

257

8063ch09.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 9-20 Publish the report

Notice that after you publish the report, the font is changed to bold so you can easily
identify which report is published or not yet published.
8. Do not close InfoAssist page since you will use this report on the next section.

9.2 Dates Using SQL Prefix


In some cases, there may not be a native DB2 Web Query function that delivers the
requirement you are looking for. In those situations you may need to look for alternative ways
to fulfill that requirement. One of the features of DB2 Web Query is the ability to specify a
direct SQL function and pass that request directly through to the DB2 engine. This is
accomplished by specifying an SQL prefix in your define field. In this section you learn how to
do this to calculate the week of the year for each of the rows in the ORDERS table. In the end
of this section you will be able to create report as Figure 9-21 on page 259 below.

258

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch09.fm

Figure 9-21 Order Date Report Grouped by Week of Year

Use the report you have created in section 9.1, Dates Using DB2 Web Query Functions on
page 248 to do these following steps.
1. First, remove MonthName field from the report in Interactive Design View.
2. Then remove MonthName Define field from the Data panel.
See Figure 9-22 to see MonthName field that should be removed.

Chapter 9. Assignment # 2: Implementing Various Date Functions in Reports

259

8063ch09.fm

Draft Document for Review August 30, 2013 2:37 pm

MonthName Field

Figure 9-22 MonthName Field should be removed

3. Since in this section you learn how to create Week of Year field, you need to simplify the
report. Delete Store Name field, so Week of Year field will be sorted only based on
Region.
4. Add new Define field (if you forgot how, see 9.1.3, Add Month Name as Define Field on
page 255) and fill the fields as in Figure 9-23 below.
Field Name: WeekOfYear
Format: I2
Definition: SQL.WEEK_ISO(CEN_ORDERS.T1_ORDERS.ORDERDATE)
Click OK.

Figure 9-23 WeekOfYear Define field

Note: Notice that in the define field definition you specified the SQL prefix to directly
invoke the SQL function named WEEK_ISO, a system supplied scalar function that
returns an integer between 1 and 53 reepresenting the week of the year (where the
week starts with Monday). As a result, this define field will use this function to calculate
the week of the year of the order date field. To learn more about the SQL prefixing
capability, refer to Appendix A, Date and time functionality on page 781.
5. Drag and drop WeekofYear to Query panel in sort By, right after Region.

260

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch09.fm

6. Notify that Interactive Design View is not able to resolve SQL prefixes at this time. See the
error message as in Figure 9-24 on page 261.
But dont worry, run the report to resolve SQL prefixes.

Figure 9-24 Error Message in Interactive Design view

7. Click the Run button. The sample result of several fetched record will be as in Figure 9-25
below.

Figure 9-25 Report result

Notice that now you have a report with number of orders grouped by week of year.
8. Save the report and name it 2b-Weekly Orders by Country, Region.
9. Publish the report. To see how to publish the report, go to last part of section 9.1.3, Add
Month Name as Define Field on page 255.
10.Do not close InfoAssist page since you will use this report on the next section.

9.3 Dates Using Date Table


At this point you have learned how to extract and calculate specific date components using
DB2 Web Query functions and SQL prefixes. However, there are there are some date
requirements that cannot be fulfilled by either DB2 Web Query or SQL functions. For
example, what if you wanted to sorting and aggregation of order dates by the phase of the
moon? Or the season of the year? In which season or phase of the moon do you sell the most

Chapter 9. Assignment # 2: Implementing Various Date Functions in Reports

261

8063ch09.fm

Draft Document for Review August 30, 2013 2:37 pm

products? There are no functions in DB2 Web Query or SQL that can calculate those
components. For very specialized requirements like these, a date table is a splendid solution!
A date table is actually another prepopulated table with a row for every day of the year in a
broad date range and contains columns for assorted ways to represent dates. For more
information about date tables, see the section Appendix , Using date conversion table to
convert to dates on page 794.
In this section you learn how to use Date Table to add Season in the report you have made
previously. After finish this section, you will be able to create sample report as Figure 9-26 on
page 262 below.

Figure 9-26 Sample Report with Season field

Note: To learn further about Date Table, go to Appendix A, Date and time functionality on
page 781. This appendix explain what kind of date information you can get using Date
Table.
In this tutorial, we use the report created in section 9.2, Dates Using SQL Prefix on
page 258. So if you have close the report, please re-open it using InfoAssist.
1. First, remove WeekOfYear field from the report in Query panel.
2. Then remove WeekOfYear Define field from the Data panel. See Figure 9-27 on
page 263.

262

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch09.fm

WeekOfYear fields
should be deleted

Figure 9-27 WeekOfYear Field in Data panel and Query panel

If you see the sample result of report you create in this section, you have Season field in the
third column. But if you cannot see Season field in the Data panel. This is because the date
table that contains Season field is not yet joined to CEN_ORDERS table. You can either join
these tables together in the synonym (highly recommended if you will using the date table
columns in other reports), or you can add define the join in this report. For this example, you
define the join in this report.
3. In InfoAssist page, click on Data to open Data ribbon menu.

Figure 9-28 Join Menu in Data Ribbon

4. You see Join menu field appears and shows that currently you only use one table named
CEN_ORDERS. Click on Add New as in Figure 9-29 on page 264.

Chapter 9. Assignment # 2: Implementing Various Date Functions in Reports

263

8063ch09.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 9-29 Join Menu field

5. A new menu that contain list of master files shows up. Choose CEN_DATE_CONV, and
click OK. See Figure 9-30.

Figure 9-30 Master File page

6. You go back to Join menu field and instead of one table, now you see two tables in it.
Next, drag and drop ORDERDATE in CEN_ORDERS table to DC_DATE in
CEN_DATE_CONV as in Figure 9-31 on page 265.

264

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch09.fm

Figure 9-31 Drag and Drop ORDERDATE to DC_DATE

7. A new red line appears between ORDERDATE and DC_DATE. Right click on the redline
and choose Edit as in Figure 9-32.

Figure 9-32 Edit Option for Relationship between tables

8. Edit Join page appears. In the type of Join, choose Inner as in Figure 9-33 on page 266.
Click OK until you go back to Interactive Design View.

Chapter 9. Assignment # 2: Implementing Various Date Functions in Reports

265

8063ch09.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 9-33 Edit Join Page

9. Check on the Data panel, and you can find DC_SEASON field there. Move DC_SEASON
field as third sort-by field in the report as in Figure 9-34 below.

Figure 9-34 DC_SEASON field

10.Run the report to see the result as shown in Figure 9-35 on page 267.

266

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch09.fm

Figure 9-35 DC_SEASON Run result

11.Save the report and name it 2c-Seasonal Orders by Country, Region.


12.Close InfoAssist page.
13.Publish the report. See the steps on how to publish the report in last part of 9.1.3, Add
Month Name as Define Field on page 255.

Chapter 9. Assignment # 2: Implementing Various Date Functions in Reports

267

8063ch09.fm

268

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

10

Chapter 10.

Assignment # 3: Implementing
Other Report Features and
Formats
This chapter discusses about how to use other report features to increase interactivity
between the report and the users, and also increase the ease of which end users can
navigating the report and jump to specific areas.
In this chapter you learn how to do the following:
 Activate the Table of Contents, Accordion, and Pages on Demand features for easy
navigation of large reports
 Generate other report formats such as PDF, Excel Formula, and Active Reports.
Prerequisites: Before starting this chapter, make sure the following steps have already
been completed:
 Chapter 7, Creating and editing metadata - Century Database on page 191
 Chapter 8, Assignment #1: Summary Reports on page 205 because we will use 1a Revenue Summary by Product Category and 1c - Revenue Summary with
Subtotals reports which are created in this chapter.

Copyright IBM Corp. 2012. All rights reserved.

269

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

10.1 Table of Contents


The date reports you delivered to Executive Dan were met with great fanfare and enthusiasm.
So far you have proven to him that all the BI requirements can be met using native IBM i tools
and the data can be left on DB2 for i. He is starting to believe!
The next assignment he has given you contains a set of larger reports that contain many
more rows of data. Consequently, navigation features are very important to allow the report
consumers to quickly locate information they are looking for. The first report in the assignment
is sorted by Country, Region, Product Type, Product Category, and Product Name. The
measure fields are revenue and gross profit. Because there are so many sort by fields, this
report will be aggregated at many levels and contain many rows in the result set. Providing
report consumer with a quick and easy way to jump to specific locations in the report will be
the key to acceptance by the end users and a successful implementation.
In this section you learn how to add table of contents in your report so you can easily
understand the content of your report and can navigate from one subset of report to another.
With the table of contents feature activated, report consumers see an dialog window that is
intitially collapsed to only reveal the first sort by field values. Expanding a specific row will
show them the next level of sort by fields. This condensed interface allows them to quickly
locate specific points of interest in the report and immediatly jump to that area.
In the end of this chapter you will create report a report simlilar to the one shown in
Figure 10-1 below.

Table of Contents

Figure 10-1 Sample Report with Table of Contents

1. As usual, create new folder under Century Electronics folder named Assignment 03 Other Report Features and Format. To do this, right click in Century Electronics folder
and select New Folder as in Figure 10-2. Click OK after you fill in the folder name field.

Figure 10-2 Create New Folder for Assignment 03

270

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

For the next steps of this tutorial, we will use Assignment 03 to refer to Assignment
03 - Other Report Features and Format.
2. Next, create new report under Assignment 03 folder. To do this, right click Assignment
03 - Other Report Features and Format and select New Report as in Figure 10-3.

Figure 10-3 Create New Report under Assignment 03 Folder

3. Choose CEN_ORDERS data source.


4. In a sequential manner, add following fields to Sort-By fields in Query Panel: Country,
Region, Product Type, Product Category, Product Name. See Figure 10-4 on
page 271 for more clear explanation

Figure 10-4 5 (Five) Fields Added to Sort-By Field in Query panel

5. Next, put Revenue in Sum field under Query panel, followed by Gross_Profit.

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

271

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 10-5 Revenue and Gross_Profit field

To see how to create Gross Profit using Define field, go back to section 8.1.2, Add Gross
Profit Define Field on page 211. Or you can also use Profit field that you have created using
synonym editor.
6. Dont forget to add some formatting in Revenue and Gross_Profit such as adding Comma
and Floating Currency.
7. Save the report and name it 3a - Table of Contents.
8. Run the report. The sample run result of few records as in Figure 10-6 below.

Figure 10-6 Revenue Summary Report result

Notice that it is a fairly lengthy report - because it contains so many sort-by fields. If you
want to find the first occurrence of a row for the United States you will have to do quite a bit
of scrolling and/or paging. Just imagine if you had hundreds of thousands rows in your
report! Wouldnt it be nice if you wanted to jump to specific location in the report without
have to scroll up or down or page through all of the data? Fortunately, DB2 Web Query
InfoAssist is equipped with Table of Contents feature to report you have create. Follow
steps below to add Table of Contents in the report.

272

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

9. Go to Format menu and expand Navigation group menu. Select Table of Contents as
shown in Figure 10-7 on page 273.

Figure 10-7 Table of Contents button

10.Run the report again. In the top left side of run report result you can see a new icon
appears. That is Table of Contents icon as shown in Figure 10-8.

Figure 10-8 Table of Contents icon

11.Double click the icon to show the Table of Contents as shown in Figure 10-9.

Figure 10-9 Table of Contents

12.If you feel the position of Table of Contents disturbs you from viewing the report, you can
actually move the Table of Contents to any position you like. For example, the image below
shows the Table of Contents is moved to the right side of the report.

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

273

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 10-10 Moved Table of Contents

13.Next, to jump directly to a specific area in the report, expand the United States country,
and click on New England region as shown in Figure 10-11.

Figure 10-11 Expanded Table of Contents

14.You will jump directly to the first row for the New England region. Figure 10-12 below
shows the sample of New England report for Audio Product Type.

274

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

Figure 10-12 New England Report result

15.Try to click another parameter in the Table of Contents to get familiar with it.
16.Save the report.
17.If you already feel confident and comfortable with the report, publish the report. To publish
the report, go to DB2 Web Query page and expand the Assignment 03 folder. Right click
the 3a - Table of Contents report and select Publish.

Figure 10-13 Publish 3a - Table of Contents report

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

275

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

Notice that soon after you publish the report, the font in the menu will change to bold.

10.2 Accordion
Another extremely useful navigation feature is the Accordion. The idea behind Accordion is is
very similar to Table of Contents - it allows the end user to expand and collapse at each sort
by field level. The difference is where this occurs: when Accordion is activated and the report
consumer runs the report, the the rows of the report themselves are initially collapsed. The
end user can be expand and collapse each row. This differs from Table of Contents in that
there is no seperate dialog window to control this navigation. In addition, the measure
columns are automatically summed at each of the sort by levels.
In this section you learn how to activate the Accordion feature for ease of navigation. You will
create a report that looks like the one below.

Figure 10-14 Revenue Report in Accordion mode

1. If you have close the InfoAssist page, re-open it along with 3a - Table of Contents
report.
2. Remove Table of Contents by clicking on the Table button in Format Menu as in
Figure 10-15.

Figure 10-15 Table button to disable Table of Contents

3. Now, click on the Accordion button. Accordion function is part of Features group, still
under Format menu. See Figure 10-16.

276

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

Figure 10-16 Accordion button

4. Run the report. The first report you see as in Figure 10-17.

Figure 10-17 Accordion result

If you click the (+) sign, the report will shows detailed information and you can choose to drill
down in which information that you want to see. See the drilled down sample report in
Figure 10-18.

Figure 10-18 Drill Down Report in Accordion mode

5. Save the report and name it 3b - Accordion.


6. Publish the report. Go to last part of section 10.1, Table of Contents on page 270 to
learn how to publish a report.
Now you have tried Table of Contents and Accordion function. So what is the difference
between those two functions?
In Table of Contents you actually have all the records in opened in the web page. With table of
contents feature you can jump from one subset of record to another.

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

277

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

Another key difference is with Accordion, you can open two subsets of records at the same
time. For example, Figure 10-19 which use Accordion can open Western Canada and West
Germany revenue and gross profit information for each product type. In Table of Contents,
you cannot do this, you can only jump to Western Canada revenue and gross profit
information, or jump to West Germany revenue and gross profit information. This is very
useful when you want to compare the data between two areas of the report that would be far
apart when fully expanded.

Figure 10-19 Another Sample of Accordion

10.3 Pages on Demand


A third option for navigating large reports is the Pages on Demand feature. With this option
the result set is broken into pages and you are presented an interface which allows you to
jump to a specific page on the report. There is also a search feature which (if a match is
found) takes you to the first occurrence of the search word.
To do this, follow these steps below to learn how to use Pages on Demand function.
1. Still using 3b - Accordion report, deselect Accordion function by clicking on Accordion
button. Make sure that the button already in disabled mode (colored grey).
If you forgot where Accordion button is, it is under Format menu ribbon as part of
Features group.
2. Now, still on Format menu, expand the Navigation group and click on Pages On Demand
as in Figure 10-20.

Figure 10-20 Pages On Demand menu

278

IBM i DB2 Web Query for i Implementation Guide

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

3. Run the report to see the result as in Figure 10-21 on page 279.

Figure 10-21 Pages on Demand Report result

4. Notice that there is a new panel appears right below the report:
1 shows page search navigation where you can easily jump to the page you want;
2 shows page navigation to help you navigate through pages in sequential manner;
3 shows search panel where you can search the report based on keywords. For example
you can search Germany revenue report by typing Germany in the search panel.
5. Save the report and name it 3c - Pages On Demand.
6. Publish the report. Go to last part of section 10.1, Table of Contents on page 270 to
learn how to publish a report.
Now you have learn about how to use Pages on Demand function. Table of Contents,
Accordion, and Pages on Demand are functions to help you navigate from one subset of
report to another.
Pages on Demand function split the report into several pages. So if you really want to go
through all the records in the report this might the one you need. Also if you want to go to
subset of the report without knowing exactly where the location is, and you only know the
keyword, you can take advantage the search panel in Pages on Demand function.

10.4 Stack Measures


Sometimes you need to create a report with a lot of numeric fields and the report format
should enable you in comparing the value of one parameter to another. This is where Stack
Measures function can help you in formatting the report.
In the end of this section you will be able to create report with Stack Measures format as in
Figure 10-22 on page 280 below.
Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

279

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 10-22 Sample Report with Stack Measures Format

To learn how to use Stack Measures function and how to further understand it, follow these
steps below.
1. Create new report under Assignment 03 - Other Report Features and Formats
folder, and use CEN_ORDERS synonym.
2. Put these below fields under Query panel in a sequential manner:
a. Country, Region fields under Sort-by;
b. Product Type field under Across;
c. Quantity, Returns fields under Sum.
3. The result in Interactive Design View as in Figure 10-23 below.

Figure 10-23 Interactive Design View result

4. Next, create return percentage field using Compute field. Select menu Data Summary
(Compute).
5. Return percentage formula is (Returns / Quantity)*100. The filled Compute field as
Figure 10-24 below. Name the new field as RtnPct.

280

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

Figure 10-24 Compute Field for Return percentage

6. Change the title of RtnPct field to Return Percentage. To do this right click on the
RtnPct in Query Panel and choose Change Title as in Figure 10-25 on page 281.

Figure 10-25 Change Title menu

7. An Edit Title menu shows up. Change the title to Return Percentage, and click OK as in
Figure 10-26.

Figure 10-26 Edit Title for Return percentage

8. Run the report. You can find the sample report result as in Figure 10-27 below.

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

281

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 10-27 Run Report result

If you see the sample report, the layout of this report is not comprehensive enough
because all the measures are placed in the columns. It will be hard to compare one values
to another in this kind of format.
You can change the layout format of this report using Stack Measures function.
9. To activate Stack Measures, go to Format menu and expand Features group menu.
select Stack Measures. See Figure 10-28 on page 282 to locate the Stack Measures
menu.

Figure 10-28 Stack Measures menu

10.Run the report again. Notice the difference between report layout that use and doesnt use
Stack Measures function.

282

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

Figure 10-29 Sample Report using Stack Measures

So, if your report has many measures in it then Stack Measures is a good solution since
the measures will be placed in row instead in column.
11.Save the report and name it 3d - Stack Measures.
12.Publish the report. Go to last part of section 10.1, Table of Contents on page 270 to
learn how to publish a report

10.5 PDF
In this section you learn about how to generate PDF file from the report you created. So
whenever you run the report, you will get the PDF file generated for you.
1. To learn how to generate PDF file, you dont have to create a new report from scratch. Just
use the report you have created previously. For example, you can use report 1a Revenue Summary by Product Category you have made in Assignment 01.
2. First, copy 1a - Revenue Summary by Product Category from Assignment 01 to
Assignment 03 folder. To do this, right click on the 1a - Revenue Summary by Product
Category report and select Copy as in Figure 10-30 on page 283.

Figure 10-30 Copy Existing Report 1a

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

283

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

3. Next, go to Assignment 03 - Other Report Features and Formats, right click on it and
choose Paste. See Figure 10-31 for your reference.

Figure 10-31 Paste Existing Report to Assignment 03 Folder

4. Now you already have 1a - Revenue Summary by Product Category report in


Assignment 03 folder. To avoid confusion with the report in Assignment 01 folder please
rename the file name.
5. To do this, right click on 1a - Revenue Summary by Product Category report in
Assignment 03 folder and select Change Title. Rename the report name with 3e - PDF
Revenue Summary by Product Category. See Figure 10-32 on page 284 for your
reference.

Figure 10-32 Change Title for report

6. After you change the report name, open it using InfoAssist.


7. Next, go to Format menu, expand Output Types group menu and select PDF as in
Figure 10-33.

284

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

Figure 10-33 PDF menu

8. Run the report. You see that instead of web based, the report result is in PDF format. New
menu which is PDF specific also appears. See Figure 10-34 on page 285 for the sample
of report in PDF format.

PDF Specific Menu


Figure 10-34 PDF report

9. Save the report to make sure that PDF format you have done is saved.
10.Publish the report. Go to last part of section 10.1, Table of Contents on page 270 to
learn how to publish a report

10.6 Excel Formula


Now you have learn how to make PDF is an output format of your report. In this section you
learn about how to make Excel file as an output format of your report. Not only that, you can
actually know the formula of each field in your report.

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

285

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

1. To do this, copy 1c - Revenue Summary with Subtotals report from Assignment 01 to


Assignment 03 folder. See section 10.5, PDF on page 283 to learn about how to copy
and paste a report from one folder to another.
2. Rename the report to become 3f - Excel Revenue Summary with Subtotals.
3. Open the report using InfoAssist.
4. In InfoAssist, go to Format menu and expand Output Types group menu. Click drop down
button on Excel and choose Excel Formula as in Figure 10-35 on page 286.

Figure 10-35 Excel Formula menu

5. Now, try to run the report. You get pop up message asking whether you want to open the
file or save the file as in Figure 10-36. You can choose either one of the options.

Figure 10-36 Pop up message

6. After you open the Excel file, put the cursor to the first Revenue field. Notice that in the
Formula bar it contains the same value as in Revenue field as in Figure 10-37. Same thing
also happen if you put the cursor in the Gross_Profit field.

286

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

Figure 10-37 Revenue field in Excel file

7. Next, put the cursor in the Subtotal field of Revenue as in Figure 10-38 on page 287.
Notice that you can see Subtotal formula in the Formula bar. You can also see the formula
of Gross_Profit Subtotal field.

Figure 10-38 Revenue Subtotal field in Excel file

8. Close the Excel Window.


9. Save the report before you close the InfoAssist page.
10.Publish the report. Go to last part of section 10.1, Table of Contents on page 270 to
learn how to publish a report.

10.7 Active Reports


In this section you learn about how to change the report you have created to become Active
Reports.
In the end of this section you will be able to create Active Report as in Figure 10-39 and use
the functions in Active Report.

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

287

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

Active Report Menu

Figure 10-39 Sample of Active Reports and its drop down menu

Active Reports allows users to interact with their reports and work disconnected from the IBM
i environment. 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 sent by
e-mail to users.
1. In this section, you dont have to recreate the report from scratch, you can use 1c Revenue Summary with Subtotals report from Assignment 01 folder. First, copy the
report from Assignment 01 to Assignment 03 folder. See section10.5, PDF on page 283
to learn about how to copy a report from one folder to another folder.
2. Rename the report with 3g - Active Report Revenue and Profit Report.
3. Open the report in InfoAssist.
4. First, remove the Subtotal function in the report. To do this, click on the Product
Category field (since Subtotal is made based on Product Category). The ribbon change to
be Product Category menu specific.
5. Expand Break group menu, click on Subtotal drop down menu, and choose More
Options. In the Subtotal menu, change it to None. See Figure 10-40 on page 289.

288

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

Figure 10-40 Remove Subtotal field

6. Click OK after you change it to None.


7. Next step is change the report format. Go to Format menu, expand Output Types group
menu, and click Active Report. See Figure 10-41 to find the Active Report menu.

Figure 10-41 Active Report menu

8. Still under Format menu, expand Features group menu and click on Active Report
Options as in Figure 10-42.

Figure 10-42 Active Report Options menu

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

289

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

9. In the Active Report Options menu, do these things below:


a. change Records Per Page to All;
b. change Hover Color to Orange;
c. change Visualization Bars: positive to blue, and negative to red;
d. change Password to abc123
To change the number of Records Per Page, go to General tab. Find Records Per Page under
Page Options. See Figure 10-43 on page 290.

Figure 10-43 Change Records Per Page

To change Hover and Visualization Bars color, go to Colors tab. See Figure 10-44 on
page 291 for further information of the color you should change.

290

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

Figure 10-44 Change Color menu

Next, to change the report to be password protected, go to Advanced tab as in Figure 10-45
on page 292.

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

291

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 10-45 Add Password Protection to the report

Note: If you leave the Password field to blank, then when you run the report you will not be
asked to provide any password.
10.Now, try to run the report and see the result.
11.On the first page, instead of looking at the report, you see the password field page since in
the Active Report Options you also set the password. Sample of Password field page
shown in Figure 10-46.

Figure 10-46 Password Field Page

12.After you correctly input the password, you can see your active report as in Figure 10-47
on page 293.

292

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

Figure 10-47 Sample of Active Report

Notice that on the top left side of the report you see that the report only contains one page.
This is because you have configure to put all the records in just one page.
Next, try to access the active report menu using the drop down menu. You see that
everytime the cursor move to any of the menu, the menu background color change from
blue to orange.
13.Refer to Figure 10-48, to check the visualization function, click on the drop down button
right beside Revenue. Select Visualize.

Figure 10-48 Visualize menu

14.The visualization bars appears right beside each revenue records as in Figure 10-49.

Figure 10-49 Visualization Bars for Revenue

15.Do the same thing for Gross_Profit field to shows the visualization bars. See Figure 10-50
on page 294 for sample active report with visualization bar.

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

293

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 10-50 Visualization Bars for Revenue and Gross_Profit

Notice that in this case all the visualization bars are blue colored. It is because all value of
Revenue and Gross_Profit are positive. Can you find the negative value?
16.Save the report, and close InfoAssist page.
17.Next, go to DB2 Web Query page and run the 3g - Active Report Revenue and Profit
Report report.
18.Publish the report. You can do it before you go through all Active Reports functions, or
after you finish to learn other Active Reports functions.
Go to last part of section 10.1, Table of Contents on page 270 to learn how to publish a
report.
19.Go through some Active Reports functions as in below sections.

10.7.1 Sorting
Active Report has sorting features where you can sort the report based on certain field. You
can also sort the report in ascending or descending way.
The first time you run the report, it is sorted ascending based on Product Type. Try to change
the report by sorting it based on other fields.
Sort Ascending based on Product Category
Click on the drop down menu in the right side of Product Category and select Sort
Ascending. See Figure 10-51.

Figure 10-51 Sort Ascending based on Product Category menu

The report is now sorted based on Product Category in ascending way. See Figure 10-52 on
page 295 for your reference.

294

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

Figure 10-52 Report Result Sort Ascending based on Product Category

Sort Descending based on Revenue


Click on the drop down menu in the right side of Revenue and select Sort Descending as in
Figure 10-53.

Figure 10-53 Sort Descending based on Revenue menu

The report is now sorted based on Revenue in descending way. Notice the red box in
Figure 10-54.

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

295

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 10-54 Report Result Sort Descending based on Revenue

10.7.2 Filtering
The report you use in this section is Revenue and Profit report for all products that is owned
by Century Electronics. Sometimes you, or the executives, doesnt want to see the whole
report. Maybe you just want to see Audio and Video revenue report since you are working in
that division.
Active Reports has Filter function where you can filter the report so you can read only the
parts you want to read.
Filter Report to Audio and Video Revenue Report Only
Now you learn how to use Filter function where the report only shows Audio and Video
revenue report.
First, click Product Type drop down menu and select Filter Equals as in Figure 10-55.
Notice that under Filter menu there are so many conditions you can choose. Equals is just
one sample of condition.

Figure 10-55 Filtering Based on Product Type

Next you find the Filter Selection menu. On the right-most field select Audio and Video. After
you finish fill in the Filter Selection based on your requirement, click Filter as in Figure 10-56
on page 297. Notice that now your report only contains Audio and Video Revenue and Profit
report. You can minimize the Filter Selection menu by clicking on the (-) sign since clicking on
the (x) sign means close the Filter Selection menu and clear up all the filters.

296

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

Figure 10-56 Filter Selection menu to choose Audio and Video

10.7.3 Charting
In many situation pictures sometimes describes better than text or numbers. Active Reports
has Charting function where it can create several types of charts based on the report you
have made. In this example you learn how to create some types of Gross Profit chart based
on Product Type.
First chart you make is Gross Profit Pie chart based on Product Type.
Click on the Gross Profit drop down menu. Select Chart Pie Product Type as in
Figure 10-57 on page 297.

Figure 10-57 Create Gross Profit Pie Chart menu

After you select the menu, a new window showing the pie chart result appears as in
Figure 10-58.

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

297

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 10-58 Gross Profit by Product Type Pie Chart

Notice that the Pie Chart colors is almost the same and you probably confuse which part of
pie chart is belong to which Product Type. You can put the cursor on top of the pie chart and
you can see further information provided. In Figure 10-58 example, the cursor is placed on
the top of Video section.
In the chart window you can also change the type of chart. Says that you want to change the
chart type from pie to bar chart. Just click on the bar icon on the top left side of the chart
window and the chart will automatically change from pie to bar chart as in Figure 10-59.

Figure 10-59 Gross Profit by Product Type Bar chart

10.7.4 Calculate: % of Total


When executives reads reports they often wants to know the total revenue and gross profit,
which product that has the highest revenue or gross profit, or what is the average revenue and
gross profit.

298

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

You dont have to modify the report by adding those function (since probably in this point you
already know how to add those functions). Active Reports has Calculate function which can
help you to deal with some calculating functions without changing the report resource.
In this section you learn how to use Calculate function, specifically the % of Total function.
Using this function you can know what is the percentage of revenue or gross profit of each
product name.
To do this, click on the drop down menu of Revenue and select Calculate % of Total.
Refer to Figure 10-60 for the menu selection.

Figure 10-60 Calculate % of Total Menu

After you click on the menu, a new field appears right next to Revenue field showing the
percentage of each Revenue value compared to total Revenue as in Figure 10-61.

Figure 10-61 Percent of Total Revenue field

You can try to create % of Total to Gross Profit.

10.7.5 Rollup
Another Active Reports function you can learn is Rollup function. Rollup function can
summarize the total revenue and gross profit based on Product Type/Product
Category/Product Name.
Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

299

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

In this sample, you learn how to create a rollup for Gross Profit based on Product Type.
As usual, to do this click on the Gross Profit drop down menu and select Rollup Product
Type as in Figure 10-62.

Figure 10-62 Rollup menu

After you click on the menu, a new window appears showing the summary of gross profit
based on Product Type. You can see the report sample in Figure 10-63 on page 300.

Figure 10-63 Gross Profit Based on Product Type Rollup result

10.7.6 Rollup Result Converted to Chart


You can change the Rollup result which is numeric, to chart. To do this, use the Rollup you
have done in step 10.7.5 on page 299. Notice on Figure 10-63 there are many chart icons at
the top of Rollup result. Click on the Pie chart icon.

300

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

Figure 10-64 Pie Chart from Rollup result

Notice that the Figure 10-64 result is the same as you created in Figure 10-58 on page 298.

10.7.7 Chart Tool


You have learn how to create a report chart using Chart menu. But Active Reports actually
also come with another function named Chart Tool. In Chart Tool you have more flexibility to
create the chart.
Using the usual Chart menu you cannot create Revenue and Gross Profit chart which is
placed in the same chart, but you can do this using Chart Tool.
To use this Chart Tool, click on any fields drop down menu and select Chart/Rollup Tool.
See Figure 10-65 on page 301.

Figure 10-65 Chart/Rollup Tool option

After clicking on the Chart/Rollup Tool Option, a Chart/Rollup Tool window shows up where
you should configure the chart you want to create.
Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

301

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

For example, you want to create Revenue and Gross Profit chart based on Product Type. So
in the Chart/Rollup Tool window drag Product Type to Group By box, and drag Revenue and
Gross_Profit to Measure as in Figure 10-66.

Figure 10-66 Fill in Group By and Measure

After you fill in the Group By and Measure, click on the Charts button to select the type of
the charts. In this example we use Column Depth Chart (see Figure 10-67 on page 302).
Click OK after you finish selecting the chart type.

Figure 10-67 Chart Type options

You can see the chart result as in Figure 10-68 below.


302

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

Line Chart

Figure 10-68 Column Depth Chart Result using Chart/Rollup tool

Now try to change the Column Depth Bar chart to Line chart by clicking on the Line icon.
Notice the location of Line icon in Figure 10-68.

Figure 10-69 Line Chart Result using Chart/Rollup tool

10.7.8 Export Chart to Excel


Another thing you can do with Active Report is you can export the chart you have to excel
format. For example, you want to export all records in the report to excel format.
To do this, click on the drop down menu of any field, then select Export XML (Excel) All
Records as in Figure 10-70.

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

303

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 10-70 Menu to Export Report to Excel format

After you click on the All Records menu, an ActiveX pop up window asking to allow
interaction appears. Click Yes. See Figure 10-71 to see the ActiveX pop up window.
To learn further about ActiveX, you can refer to section10.7.11, Note for Active Report on
page 309.

Figure 10-71 ActiveX pop up window

Next you can find that the Microsoft Excel application is automatically opened, and it shows
your report in Excel format. In Figure 10-72 on page 305 you can see the sample Excel file
result.

304

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

Figure 10-72 Sample Excel file result

10.7.9 Pivot Tool


For typical data entry, the data usually appears in flat tables which consists only columns and
rows. The table in this sample Active Report is the sample of flat table. The benefit of using
Pivot table is it can help quickly summarize the data and highlight the desired information.
Active Reports also has Pivot Tool function to help you create the Pivot table. But the Active
Report you have right now is not enough to create a nice pivot table. Therefore you need to do
some small changes in the Active Report.
Open the report in InfoAssist, and add Country field as primary sort-by field in the report.
Save, then run the report. You will see the report as in Figure 10-73 on page 305 below.

Figure 10-73 Active Report with Additional Country field

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

305

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

And now you are ready to use the Pivot Tool. The purpose of making pivot table in this tutorial
is to get the information of total gross profit for each product type on each country.
First, click on drill down menu in any field, and select Pivot Tool as in Figure 10-74 on
page 306.

Figure 10-74 Select Pivot tool

After you select the Pivot Tool menu, a pop up window appears where you can configure the
Pivot table. Drag and drop columns:
 Country to Group By;
 Product Type to Across;
 Gross Profit to Measure.
See Figure 10-75 for reference.

Figure 10-75 Configure the Pivot table

Click OK after you finish do the configuration. You can see the sample result as in
Figure 10-76 on page 307 below.

306

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

Figure 10-76 Pivot Table Sample result

10.7.10 Add Comments


Sometimes in your report you need to add some note or comments in certain column. For
example in the Revenue report there are some revenue value that still need to re-validated
since not all store has sent the report to you. Active Reports enable you to add comments
specific in each field of your report.
To add the comment, follow these steps below.
1. Right click on the field where you want to add some comments in it. In this example you
add comments to the first Revenue result. Choose Comments (Figure 10-77 on
page 307).

Figure 10-77 Add Comments menu

2. A new window pops up. In this window you can type the comments you want to write. Click
Add Comment after you finish typing the comment.

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

307

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 10-78 Comment field

3. Notice that in the field where you add the comment in it, there is an asterisk sign in the
field.

Figure 10-79 Asterisk sign

4. You can actually show the comment in the report instead of just showing the asterisk sign.
To do this , click on the drop down menu and select Comments Expand.

Figure 10-80 Expand Comment menu

5. You can see the result as in below.

Figure 10-81 Revenue comment

308

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch10.fm

10.7.11 Note for Active Report


There are several things you need to know when running Active Reports. Active Reports use
ActiveX controls. Based on your browser security settings, you might see warning messages,
and you might be asked whether you want to allow blocked content.
So, first of all, you must be using a browser that supports ActiveX technology. This means that
only Internet Explorer can be used if you want to save your Active Reports to your hard drive.
Other supported browsers has no native ActiveX technology capability.
Second, you must make sure that your Internet Explorer browser settings are configured to
enable ActiveX for Internet Explorer. To set this up correctly:
In the browser, from the menu bar, select Tools Internet Options.
In the Internet Options window, click the Security tab.
On the Security tab window, click Custom Level.
In the Security Settings window, scroll through the menu and select the Enable radio
button for the following menu choices:
Run ActiveX Controls and Plugins
Script ActiveX Controls Marked Safe for Scripting
Initialize and Script ActiveX Controls not Marked as Safe for Scripting
5. Click OK to exit and save.
6. Click OK again to exit the Internet Options window.
7. Close and re-open the browser.

1.
2.
3.
4.

ActiveX is now enabled and you can save your Active Reports.

10.8 Active Flash


Beside Active Report, you can also change your report to be Active Flash format. The
difference is Active Report is a web based report, while Active Flash is a Flash based report.
Follow these steps below to change your report to become Active Flash report.
1. First, copy and paste 3g - Active Report Revenue and Profit Report to the same folder
(Assignment 03 folder).
2. A new window pops up informing that the item is already exist as in Figure 10-82. This
message shows up because you paste the report in the same folder. Choose Create New.

Figure 10-82 Message Appears when duplicating the report

Chapter 10. Assignment # 3: Implementing Other Report Features and Formats

309

8063ch10.fm

Draft Document for Review August 30, 2013 2:37 pm

3. Rename the report to avoid confusion with the original Active Report you have made
before. Change it to 3h - Active Flash Revenue and Profit Report.
4. Open 3h - Active Flash Revenue and Profit Report in InfoAssist.
5. Click on Format menu bar, and in Output Types menu ribbon select Active Flash.

Figure 10-83 Active Flash menu button

6. Save the report.


7. Go to DB2 Web Query page and run the report. Notice that it is almost the same as Active
Report. It has the same drop down menu as Active Report, but there are several sub menu
that is not exist in the Active Flash Report (eg: Comments menu).

Figure 10-84 Active Flash Report result

8. Publish the report. Go to last part of section 10.1, Table of Contents on page 270 to
learn how to publish the report.
9. Try to go through the functions you have tried in section 10.7, Active Reports on
page 287.

310

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch11.fm

11

Chapter 11.

Assignment # 4: Charting
This chapter describes how to create charts using the InfoAssist tool
InfoAssist 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 to histograms and area charts, stock charts, gauges for
key performance indicators, and much more. You can find additional details about the
graphing facility in the help text.
In this chapter we continue with the same Century database used in the previous tutorials.
And we have plan to import these charts we create in this chapter to a Dashboard we will
create in Chapter 15, Assignment # 8: Building Documents/Dashboards on page 455.
In this chapter we complete the following tasks:
 Create a simple chart that contains multiple pie charts, revenue and gross profit by
product type.
 Create a bar chart that shows OTD (On Time Delivery) by product type
 Create a vertical stacked area chart that shows orders backlog by period
 Create a gauge chart that shows OTD (On Time Delivery) overall
Prerequisite: To do this chapter you need to have Metadata for ORDERS table and
decompose ORDERDATE field. If you havent create and decompose it, please go to
Chapter 7, Creating and editing metadata - Century Database on page 191

Copyright IBM Corp. 2012. All rights reserved.

311

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

11.1 The Assignment


In todays environment, end users need more than just reports - they also need graphs and
charts to visually represent complex data and make it easier to comprehend and identify
trends, problems, and areas of strength within a company. Century Electronics users are no
different - so for this assignment, Executive Dan would like for you to create a series of charts
to allow users to easily comprehend and analyze the data.

11.2 Pie chart: Revenue & Gross Profit by Product Type


For the first exercise of this assignment, Executive Dan would like pie charts that show both
revenue and gross profit by product type. The end result will be charts like the ones shown in
Figure 11-1 below.

Figure 11-1 Final Result of Pie chart : Revenue / Gross Profit by Product Type

Follow steps below to create the chart.


1. In the Reporting area, create folder Assignment 04 - Charting. In this tutorial, the
folder is created under Century Electronics folder. To create new folder, right click on
Century Electronics folder, select New Folder
2. Right-click the Assignment 04 - Charting folder.
3. Select New Chart as shown in Figure 11-2 on page 313. This will open InfoAssist.

312

IBM i DB2 Web Query for i Implementation Guide

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 11-2 Menu to Open or create chart

4. Select CEN_ORDERS synonym as shown in Figure 11-3.

Figure 11-3 Data Source Selection menu

5. Click OK.
After you choose the CEN_ORDERS table, you see the list of all fields on the Data panel at
the left side. Be notified that in Data panel synonyms are divided into two groups:
Dimensions, and Measures/Properties.
6. Select Format tab -> Chart Types Group -> Pie chart as shown in Figure 11-4 on
page 314.

Chapter 11. Assignment # 4: Charting

313

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 11-4 Selecting Pie chart

7. Drag and drop Product Type to Slices as shown in Figure 11-5.

Figure 11-5 Moving Product Type from Data panel to Query panel

8. Next, Drag Revenue and Gross Profit from Data panel to Measure(Sum) in Query panel
as in Figure 11-6.

Figure 11-6 Moving Revenue and Gross Profit from Data panel to Query panel

314

IBM i DB2 Web Query for i Implementation Guide

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Note: To do this chapter you need to have the define field for Gross Profit. If Gross Profit
field is not created, please go to 8.5, Creating Define and Compute fields in the Synonym
on page 241

9. Select Features icon as shown in Figure 11-7.

Figure 11-7 Selecting Features icon

10.Select 3D Effect icon as shown in Figure 11-8.

Figure 11-8 Selecting 3D effect icon

11.Select Run and check the result as in Figure 11-1 on page 312.
12.Save your report as 4a - Pie Chart : Revenue & Gross Profit by Product Type.
13.f you already feel confident and comfortable with the report, publish the report. To publish
the report, go to DB2 Web Query page and expand the Assignment 04 folder. Right click
4a - Pie Chart : Revenue & Gross Profit by Product Type report and select Publish as
shown in Figure 11-9.

Figure 11-9 Publish the report

Chapter 11. Assignment # 4: Charting

315

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Notice that soon after you publish the report, the font in the menu will change to bold. So
you can differentiate which report is already or not yet published.

11.3 Bar chart: OTD by Product Type


For the second exercise of this assignment, Executive Dan would like a bar chart that shows
On Time Delivery (OTD) measures. OTD analysis is broken down into the following three
categories
 Early - The actual ship date was 10 days or more before the requested ship date
 On time - The actual ship date was within 10 days of (before or after) the requested ship
date
 Late - The actual ship date was 10 days or more after the requested ship date
For each Product Type, he would like to see the percentage break down for each of these
three categories. Centurys goal is to achieve 85 percent on time delivery.
An example of this chart is shown in Figure 11-10 below.

Figure 11-10 Final Result of Bar Chart : OTD by Product Type

This kind of analysis is an ideal opportunity to leverage the power of SQL views. The
following view is provided for you in the QWQCENT schema. For each product type, it shows
both the counts and the percentages of each of the three categories, as well as the
companys goal of 85 percent on time delivery:
CREATE VIEW QWQCENT.OTDBYPRODUCT (
PRODUCTTYPE FOR COLUMN PRODTYPE
,
"ALL" ,
ONTIMECOUNT FOR COLUMN ONTIM00001 ,
EARLYCOUNT ,
LATECOUNT ,
ONTIME ,
EARLY ,
LATE ,
GOAL )
AS
WITH A AS
(SELECT PRODUCTTYPE, SHIPDATE, REQUESTEDSHIPDATE,

316

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch11.fm

DEC((DAYS(SHIPDATE) - DAYS(REQUESTEDSHIPDATE)),9,2) AS OTD


FROM QWQCENT.ORDERS O , QWQCENT.INVENTORY I
WHERE O.PRODUCTNUMBER=I.PRODUCTNUMBER),
B AS
(SELECT
CASE WHEN OTD <-10 THEN 'early'
WHEN OTD BETWEEN -10 AND +10 THEN 'on-time' ELSE 'late' END AS OTDSTATUS,
PRODUCTTYPE, SHIPDATE, REQUESTEDSHIPDATE, OTD FROM A)
SELECT PRODUCTTYPE, COUNT(*) AS ALL,
SUM(CASE WHEN OTDSTATUS='on-time' THEN 1 ELSE 0 END) AS ONTIMECOUNT,
SUM(CASE WHEN OTDSTATUS='early' THEN 1 ELSE 0 END) AS EARLYCOUNT,
SUM(CASE WHEN OTDSTATUS='late' THEN 1 ELSE 0 END) AS LATECOUNT,
DEC(SUM(CASE WHEN OTDSTATUS='on-time' THEN 1 ELSE 0 END)*100.00/COUNT(*), 5,2) AS ONTIME,
DEC(SUM(CASE WHEN OTDSTATUS='early' THEN 1 ELSE 0 END)*100.00/COUNT(*), 5,2) AS EARLY,
DEC(SUM(CASE WHEN OTDSTATUS='late' THEN 1 ELSE 0 END)*100.00/COUNT(*), 5,2) AS LATE,
85 AS GOAL FROM B GROUP BY PRODUCTTYPE

Attention: In this exercise, you create synonyms over the OTDBYPRODUCT and
ORDERHORIZON views. If you havent learned how to create synonym, please go to 7.1,
Creating metadata using the metadata creation wizard on page 192

Follow the steps below to create the synonyms.


1. Right-click the Assignment 04 - Charting folder and select Metadata New
2. In the new pane, on the left hand side in the Steps section select Synonym Or Samples,
and select DB2 CLI *LOCAL, and click Create Synonym bottom.
3. In the Select Synonym Candidates for DB2 pane (Figure 11-11 on page 317), select
Views and enter QWQCENT in the library field. Click Next as shown in Figure 11-11.

Figure 11-11 Create metadata

Chapter 11. Assignment # 4: Charting

317

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

4. The Create Synonym for DB2 CLI pane is displayed (Figure 11-12) and shows all the
different tables that reside on the QWQCENT schema. In this panel, set CEN_ in the prefix
field, then select tables OTDBYPRODUCT and ORDERHORIZON.
5. Click Create synonym.

Figure 11-12 Create metadata - Step 4

The metadata takes a few seconds to create, depending on how many items you selected.
After the processing is done, in the Status column, you see the message Created
successfully. The process of creating metadata is now complete.
6. Close the message box
Next, follow steps below to create the chart.
7. Right-click the Assignment 04 - Charting folder.
8. Select New Chart as shown in Figure 11-13. This will open InfoAssist.

Figure 11-13 Menu to Open or Create Chart

9. Select CEN_OTDBYPRODUCT synonym as shown in Figure 11-14 on page 319.


318

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch11.fm

Figure 11-14 Data Source Selection menu

10.Click OK.
11.Select Format tab -> Chart Types group -> Other icon as shown in Figure 11-15.

Figure 11-15 Selecting Other chart

12.Select Horizontal Percent Bars chart as shown in Figure 11-16 on page 320.

Chapter 11. Assignment # 4: Charting

319

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 11-16 Selecting Horizontal Percent Bars

13.Drag and drop Product Type to X Axis. Then drag and drop EARLY, ONTIME and LATE
to Data panel to Measure(Sum) in Query panel as in Figure 11-17 on page 321.

320

IBM i DB2 Web Query for i Implementation Guide

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 11-17 Moving fields from Data panel to Query panel

14.Right click on any the EARLY bar (blue colored bar), and select Series Color as shown in
Figure 11-18.

Chapter 11. Assignment # 4: Charting

321

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Audio

Product Type

Camcorders

Cameras

Office

Video
0%

20%

40%
EARLY

ONTIME

60%

80%

100%

LATE

Figure 11-18 Selecting Series Color

15.Select yellow.

Figure 11-19 Selecting Color

16.Follow the same steps, to change the color of ONTIME and LATE as in Figure 11-20.

322

IBM i DB2 Web Query for i Implementation Guide

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Audio

Product Type

Camcorders

Cameras

Office

Video
0%

20%

40%
EARLY

60%
ONTIME

80%

100%

LATE

Figure 11-20 Color image

17.Select Run and check the result as in Figure 11-10 on page 316.
18.Save your report as 4b - Bar Chart : OTD by Product Type.
19.Publish the chart. Go back to the last part of 11.2, Pie chart: Revenue & Gross Profit by
Product Type on page 312 to learn how to publish a report.

Chapter 11. Assignment # 4: Charting

323

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

11.4 Vertical Stacked Area: Orders Backlog by Period


Executive Dan would next like for you to create a chart that shows order backlog by period for
each product type. In his opinion, a vertical stacked area chart would be the best way to
present this kind of information. In this exercise you will create the chart shown in
Figure 11-21 below.

Figure 11-21 Final Result of Vertical Stacked Area : Orders Backlog by Period

Similar to the previous exercise, an SQL view is a great way to break this information down in
preparation for the chart. The following SQL view is provided for you in the QWQCENT
library:
CREATE VIEW QWQCENT.ORDERHORIZON (
PLANTCODE FOR COLUMN PLANT_CODE ,
PRODUCTTYPE FOR COLUMN PRODTYPE
,
SORTPERIOD ,
PERIOD ,
PERQTY ,
PERDOLLARS )
AS
WITH A AS
(SELECT PLANTCODE, PRODUCTTYPE,
CASE
WHEN ORDERDATE < CURRENT DATE THEN '1'
WHEN ORDERDATE > CURRENT DATE + 6 MONTHS THEN '3'
ELSE '2'
END AS SORTPERIOD,
CASE
WHEN ORDERDATE < CURRENT DATE THEN 'Past'
WHEN ORDERDATE > CURRENT DATE + 6 MONTHS THEN 'Future'
ELSE YEAR(ORDERDATE) || '-' || SUBSTR(DIGITS(MONTH(ORDERDATE)),9,2) END AS PERIOD,
QUANTITY, LINETOTAL
FROM QWQCENT.ORDERS O , QWQCENT.INVENTORY I
WHERE O.PRODUCTNUMBER=I.PRODUCTNUMBER )
SELECT PLANTCODE, PRODUCTTYPE, SORTPERIOD, PERIOD, SUM(QUANTITY) AS PERQTY,
SUM(LINETOTAL) AS PERDOLLARS

324

IBM i DB2 Web Query for i Implementation Guide

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

FROM A
GROUP BY PLANTCODE, PRODUCTTYPE, SORTPERIOD, PERIOD

Prerequisite: To complete this exercise you need the synonym for the ORDERHORIZON
view. If you havent create it, please go to 11.3, Bar chart: OTD by Product Type on
page 316

Follow steps below to create the chart.


1. Right-click the Assignment 04 - Charting folder.
2. Select New Chart. This will open InfoAssist.

Figure 11-22 Menu to Open or Create chart

3. Select CEN_ORDERHORIZON synonym.

Figure 11-23 Data Source Selection menu

Chapter 11. Assignment # 4: Charting

325

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

4. Click OK.
5. Select Format tab -> Chart Types group -> Other chart.

Figure 11-24 Selecting Other chart

6. Select Area tab and Vertical Stacked Area chart.

Figure 11-25 Selecting Vertical Stacked Area

7. Select the Data tab and Detail (Define) icon. A new menu pops-up.

Figure 11-26 Selecting Detail (Define)

8. Type Field name as PlotPeriod as in Figure 11-27 on page 327


9. Type A20 in the format field as in Figure 11-27 on page 327.
10.In the Detail Field, create the PlotPeriod formula by double click SORTPERIOD, input || -
||, then double click PERIOD. The filled result as in Figure 11-27 on page 327

326

IBM i DB2 Web Query for i Implementation Guide

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 11-27 Define field for PlotPeriod

11.Click OK.
If you see Interactive Design View, nothing is changed in the view. Check the Data panel
under Measures/Properties. You find new field named PlotPeriod.
12.Drag and drop Product Type to Legend (Series).
13.Drag and drop PlotPeriod to X Axis.
14.Drag PERDOLLARS to Data panel to Measure(Sum) in Query panel as in Figure 11-28
on page 328.

Chapter 11. Assignment # 4: Charting

327

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 11-28 Move fields from Data panel to Query panel

15.Right Click X Axis, select rotate, then select 45 as in Figure 11-29 on page 329.

328

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch11.fm

Figure 11-29 Selecting Rotate

Attention: This is a date sensitive chart because you are using the CURRENT DATE
register in the SQL view. If the chart does not show any data, it is probably because the
date columns in the ORDERS table have values that do not contain the current year.
For information on how to update your tables with more current dates, see The
QWQCENT Library on page 164

16.Right click PlotPeriod and select Change title.

Figure 11-30 Selecting Change title

17.Edit title from PlotPeriod to Period.

Chapter 11. Assignment # 4: Charting

329

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 11-31 Editing title

18.Right click PERDOLLARS and select Change title.

Figure 11-32 Selecting Change title

19.Edit title from PERDOLLARS to DOLLARS.

Figure 11-33 Editing title

20.Select Run and check the result as in Figure 11-21 on page 324.
21.Save your report as 4c - Vertical Stacked Area : Orders Backlog by Period.
22.Publish the chart. Go back to the last part of 11.2, Pie chart: Revenue & Gross Profit by
Product Type on page 312 to learn how to publish a report.

330

IBM i DB2 Web Query for i Implementation Guide

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

11.5 Gauge chart: OTD overall


For the last chart in this assignment, Executive Dan requested a chart that shows the overall
company-wide OTD percentage. Century Electronics uses the following categories to
measure and analyze performance in this area:
 Poor - Less than 60%
 Average - from 60% to 79%
 Good - Greater than or equal to 80%
As stated earlier, Centurys goal in this area is 85% on time delivery.
A gauge chart is a popular and efficient way to present a single measure along with various
bands to represent poor, average, and good performance. A red band is typically used to
show the poor range, yellow to represent the average range, and green displays the good
range. You can even identify a goal and show that as a band in the gauge as well.
In this exercise, you create a gauge chart, OTD overall. An example is shown in Figure 11-34
below.

Figure 11-34 Final Result of Gauge Chart : OTD overall

Prerequisite: To complete this exercise, you need a synonym for the OTDBYPRODUCT
view. If you havent created it, please go to 11.3, Bar chart: OTD by Product Type on
page 316

Follow steps below to create the chart.


1. Right-click the Assignment 04 - Charting folder.
2. Select New Chart. This will open InfoAssist.

Chapter 11. Assignment # 4: Charting

331

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 11-35 Menu to open or create chart

3. Select CEN_OTDBYPRODUCT synonym.

Figure 11-36 Data Source Selection menu

4. Click OK.
5. Select Format tab -> Chart Type group -> Other icon.

Figure 11-37 Selecting Other chart

6. Select Special tab and Gauge chart.

332

IBM i DB2 Web Query for i Implementation Guide

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 11-38 Selecting Gauge chart

7. Drag and drop ONTIME to Measure (Sum).

Figure 11-39 Move Product Type from Data panel to Query panel

8. Right Click ONTIME on Query Panel, select More, select Aggregation Functions, then
select Average as in Figure 11-40 on page 334.
Chapter 11. Assignment # 4: Charting

333

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 11-40 Selecting Average

9. Right click AVE.ONTIME and select Change title.

Figure 11-41 Selecting Change title

10.Edit title from AVE.ONTIME to OTD Actual.

Figure 11-42 Editing title

Next, we set a Gauge Options.


11.Right Click chart on Interactive Design View, select More Gauge Options as in
Figure 11-43 on page 335. A new menu pops-up.

334

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch11.fm

Figure 11-43 Selecting More Gauge Options

12.Select Bands tab.

Figure 11-44 Selecting Bands tab

13.Edit Minimum Value to 1.0, Maximum Value to 59.0 as in Figure 11-45 on page 336.

Chapter 11. Assignment # 4: Charting

335

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 11-45 Band setting (Band 1)

14.Select Band 2 on Band list box.

Figure 11-46 Selecting Band list box

15.Edit Minimum Value to 60.0, Maximum Value to 79.0. Click Border Color bottom and
select yellow. Next select Color bottom on fill area and select yellow as in Figure 11-47
on page 337.

336

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch11.fm

Figure 11-47 Bands setting (Band 2)

16.Select Band 3 on Band list box


17.Follow the same steps, to change Minimum and Maximum Value, Border Color, Fill
Color as in Figure 11-48.

Figure 11-48 Bands setting (Band 3)

18.Select Band 4 on Band list box


19.Follow the same steps, to change Minimum and Maximum Value, Border Color, Fill
Color as in Figure 11-49 on page 338.

Chapter 11. Assignment # 4: Charting

337

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 11-49 Bands setting (Band 4)

20.Select Band 5 on Band list box


21.Follow the same steps, to change Minimum and Maximum Value, Border Color, Fill
Color as in Figure 11-50.

Figure 11-50 Bands setting (Band 5)

22.Click General Options tab, change Color and Border Color on Gauge Needle as in
Figure 11-51.

338

IBM i DB2 Web Query for i Implementation Guide

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 11-51 Changing Gauge Needle Color

23.Select Below on Gauge title position as in Figure 11-52.

Figure 11-52 Selecting Gauge Title position

24.Click Axis Scale & Labels tab, change Minimum values as shown Figure 11-53

Figure 11-53 Axis Scale and Labels

25.Check the result as in Figure 11-54 on page 340

Chapter 11. Assignment # 4: Charting

339

8063ch11.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 11-54 Interactive Design View

26.Select Run and check the result as in Figure 11-34 on page 331.
27.Save your report as 4d - Gauge Chart: OTD overall.
28.Publish the chart. Go back to the last part of 11.2, Pie chart: Revenue & Gross Profit by
Product Type on page 312 to learn how to publish a report.

340

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

12

Chapter 12.

Assignment #5: Adding filters to


reports and charts
A DB2 Web Query filter is a feature that allows you to generate WHERE clauses in your
reports. This enables you to include the data you want, and to exclude the data you do not
want to appear in the report. In this chapter, you will learn how to do the following:





Set up simple filters


Set up advanced filters
Use filters previously created in metadata
Use the Info Mini option to set up slicers to allow end users to filter rows at runtime
Prerequisites: Before starting this chapter, make sure the following steps have already
been completed:
 Chapter 7, Creating and editing metadata - Century Database on page 191


Copyright IBM Corp. 2012. All rights reserved.

341

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

12.1 Simple filters - Revenue Simple Filter report


The first report in this assignment is a simple filter. Executive Dan has requested a report to
summarize revenue by product type and product category. Each user will be able to select the
countries and product types for which they want data, so you will set two simple filters, both of
which allow users to select multiple values. We want to produce a report like that shown in
Figure 12-1.

Figure 12-1 Simple filters report

For this assignment we will be creating a new sub-folder within our Century Electronics main
folder, named Assignment 05 - Adding filters to report:
1. In the DB2 Web Query home page right click on the Century Electronics folder and select
New Folder as shown in Figure 12-2.

342

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

Figure 12-2 Create folder

2. In the New Folder pane specify the name for this new folder, Assignment 05 - Adding
filters to Report as shown below.

Figure 12-3 Specify Folder Title

3. Open folder Century Electronics and right click on Assignment 05 - Adding filters to
Report,, select New Report as shown in Figure 12-4 on page 344.

Chapter 12. Assignment #5: Adding filters to reports and charts

343

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 12-4 Create a new report

4. Info Assist opens up, select synonym CEN_ORDERS as your data source and click on
OK (Figure 12-5 on page 345).

344

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

Figure 12-5 Select data source

5. Create a simple report dragging PRODUCTTYPE, COUNTRY and REVENUE in the


Interactive design view or in the Query pane to obtain the result shown in Figure 12-6
on page 346.

Chapter 12. Assignment #5: Adding filters to reports and charts

345

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 12-6 Create basic report

6. Your end users may appreciate getting totals both on a country and a product type basis,
so we enable the corresponding functionalities. In the Home ribbon select Column Totals
and Row Totals as shown in Figure 12-8 on page 347, item #1. If these items do not
appear in your Home ribbon, you can enable them click on the Report icon highlighted in
Figure 12-7.

Figure 12-7 Info Assist - report options

346

IBM i DB2 Web Query for i Implementation Guide

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

2
1

Figure 12-8 Basic report - add totals

7. We now want to give our report a title. To do so select the Header and Footer symbol,
highlighted in Figure 12-8 on page 347, item #2. In the Header and footer pane type the
title for this report as shown in Figure 12-9 on page 348, here we use Revenue by
Country and Product Type, then increase the font size (1), align it to the left (2) and
change its color to blue (3).

Chapter 12. Assignment #5: Adding filters to reports and charts

347

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 12-9 Insert report title

8. Switch the panel to report footer - see Figure 12-10 #1 - type in text, here we use Data
on &DATEDMYY at &TOD, aligh text to the left (#2) and change color to blue (#3). When
you are done click OK.
Note: Here we use two variables:
 &DATE to get the current system date when this report gets executed, formatted as
DMYY
 &TOD to get the current time of day when this report gets executed
Please refer to Table 26-1 on page 782 for more details on date and time system
variables.

348

IBM i DB2 Web Query for i Implementation Guide

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

1
2

Figure 12-10 Insert report footer

9. Save your report as 5a - Revenue by Country and Product


10.We are now ready to insert a filter (i.e. a WHERE clause) on COUNTRY. To do this right
click on the COUNTRY field and select Filter, as shown in Figure 12-11 on page 349.

Figure 12-11 Add filter on COUNTRY

Chapter 12. Assignment #5: Adding filters to reports and charts

349

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

11.The filter panel opens up (Figure 12-12 on page 350). Here you can set the comparison
operator - EQUAL in our example - see item #1 - and the kind of prompt you want to give
to end users at runtime, select Prompt using Data Values (Dynamic) - see item #2.
There are four different prompt options:
a. No Value Prompt - this sets the choices in advance, hardcoding a prefilled static
WHERE clause in the report. The enduser is not presented with a prompt
b. Prompt using Data Values (Dynamic) - this creates a prompt filled with data values
retrieved dynamically from data source at runtime. The runtime user makes choices on
a dynamic list. If new lines are inserted in the underlying table with more choices, the
prompt is always updated to present ALL values available in the database.
c. Prompt using Selection (Static) - a list of possible choices is built up within the report at
developement time, the enduser is presented with this static list at runtime so if new
values are inserted in the database these values will never be part of the possible
choices.
d. Prompt using Text Input (Simple) - at runtime the enduser is presented with a blank
field where to type in the desired choice. This setting can lead to errors and waist of
computing power (Canada is not the same as CANADA nor canada in database).
2

Figure 12-12 Simple filter

12.The filter pane gets updated to reflect you choice for a dynamic prompt. In Figure 12-13
you can see that it s already connected to the field on which the WHERE condition has
been set (see VARIABLE #1), COUNTRY in our case, and it is possible to change the text
that is presented at runtime (see PROMPT #2), here we use Country:. Select the Allow
Multiple Values for Prompt to make sure more than one item can be selected. When
you are done click on OK.

350

IBM i DB2 Web Query for i Implementation Guide

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 12-13 Setting dynamic prompt for COUNTRY

13.Repeat the process for field PRODUCTTYPE. The Info Assist development environment
should look like Figure 12-14, with both COUNTRY and PRODUCTTYPE in the filter pane.

Figure 12-14 Filter pane

Chapter 12. Assignment #5: Adding filters to reports and charts

351

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

14.Save your report with name 5b - Revenue Simple Filter.


15.When running your report you are presented with two propmts where you have to select
the COUNTRY and PRODUCTTYPE values for which you want to run the report, as
shown in Figure 12-15 on page 352. Hold the Ctrl key to select multiple values and select
RUN.

Figure 12-15 Simple filter, Prompt at runtime

12.2 Advanced Filters - Revenue Advanced Filter report


For the next report in this assignment, Executive Dan would like a simple report to summarize
revenue by product type and product category. Each user will be able to select the countries
and product types for which they want data, so we will set a simple filter with multiple choices.
We want to obtain a report like that shown in Figure 12-16. In this report we want all revenue
information regarding just one or more product types, for the a selected country for all years
and for just the selected year for all countries. The corresponding SQL WHERE clause would
be WHERE (T2."PRODUCTTYPE" = 'Audio') AND ((YEAR(T1."ORDERDATE") = 2011) OR
(T3."COUNTRY" = 'Canada')).

352

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

Figure 12-16 Advanced Filters report

To produce this report we can start from the previous basic 5b - Revenue Simple Filter:
1. If you had closed Info Assist and report from the previous exercise login to DB2 Web
Query, double click on folder Century Electronics and subfolder Assignment 5 then right
click on report 5b - Revenue Simple Filter and select Edit. If Info Assist and this report
are still open from previous assignment just procede to step 2.
2. In Info Assist drag the ORDERDATE_YEAR field to the BY aggregation item in the Query
pane as shown in Figure 12-17 on page 353.

Figure 12-17 Add ORDERDATE_YEAR field

3. Right click on one of the filters already set and select Open Advanced Filter
(Figure 12-18 on page 354).

Chapter 12. Assignment #5: Adding filters to reports and charts

353

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 12-18 Editing filters

4. You are presented with the advanced filter panel, shown in Figure 12-19. Here we want to
add a condition on ORDERDATE_YEAR, grouping it with the pre-existing condition on
COUNTRY. To do so select the COUNTRY condition (#1) and then GROUP (#2).

2
1

Figure 12-19 Advanced filter panel

5. Make sure the COUNTRY condition is selected then select Insert Before as shown in
Figure 12-20 on page 355.

354

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

Figure 12-20 Advanced filter, setting new condition Step 1

6. You are presented with a small pane where to set up the new condition. Position on
<Field> and select ORDERDATE_YEAR then select OK.

Figure 12-21 Advanced filter, setting new condition Step 2

7. Position on <Value> and set up Type to Parameter, Description to Year: then select
Dynamic, select the ORDERDATE_YEAR field and click on OK (Figure 12-22 on
page 356).
Note: Please notice that this pane gets built dynamically while you make the various
choices, initial look is not what presented here - you will get to this appearance after all
selections have been made.

Chapter 12. Assignment #5: Adding filters to reports and charts

355

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 12-22 Advanced filter, setting new condition Step 3

8. When you are done the advanced filters panel should look like Figure 12-23 on page 356.
Select OK to confirm your choices.

Figure 12-23 Advanced filters

9. Save your report as 5c - Revenue Advanced Filter and run it. It should look like
Figure 12-24.
356

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

Figure 12-24 Advanced filters report

Chapter 12. Assignment #5: Adding filters to reports and charts

357

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

12.3 Filter in chart: : revenue trend graph with a variable date


range
Filters can also be applied to charts. In this exercise, Exective Dan would like a simple line
chart that spans two years (includes all our data). He would also like to allow the report
runner to specify the time range in which he or she is interested (Figure 12-25).

Figure 12-25 Trending report with a variable date range

12.3.1 Creating a line graph


Follow steps below to create the revenue report.
10.Right-click the Assignment 05 - Adding Filters folder.
11.Select New Chart. This will open InfoAssist.
12.Select CEN_ORDERS synonym (Figure 12-26 on page 359).

358

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

Figure 12-26 Data Source Selection menu

13.Click OK.
14.In the next window, click the Format tab. On the Format tab (Figure 12-27), under chart
types group, select Line.

Figure 12-27 Selecting Line chart

15.To show product revenue trending by month, you must plot one point for every month for
each product. To do this, convert the date field from year, month, and day to a field with
just the year and month.
a. Click the Data tab.
b. Click the Detail (Define) icon (Figure 12-28).

Figure 12-28 Defining a new field

Chapter 12. Assignment #5: Adding filters to reports and charts

359

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

c. In the Define field creator window (Figure 12-29), complete these steps:
i. For Field, type MthYr.
ii. In the pane below Field, where you define the formula for the new field, type
ORDERDATE, which is the name of the date on which MthYr is based.
iii. In the Format field, type TMYY.
T means that the month or day immediately following will be represented as
uppercase text. A single Y means that you want to display a two-digit year, but YY
means that you want to display a four-digit year.
An example of a MthYr value is Jan, 2011. If we want to place the year first, we
specify a format of YYTM. DB2 Web Query is powerful when it comes to working
with date and time fields. See Date and time system variables on page 782 for
many of the different ways that you can work with date and time fields. Click OK.

Figure 12-29 Creating a date field of month and year

d. On the Query Pane (Figure 12-30), drag MthYr to the Field value plotted on X axis (our
main X axis) pane, and drag Revenue to the Measure(Sum) pane under Field value
plotted on Y axis. Then drag Product Type to Legend (Series).

Figure 12-30 Creating a line graph with multiple lines

360

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

16.Since an entry on an axis of Jan, 2011 is obviously a date, remove the heading or label
for MthYr from the graph (Figure 12-31):
a. Under Field value plotted on X axis, highlight MthYr.
b. Right Click there, and select Delete the label MthYr.

Figure 12-31 Removing the X axis field label

Chapter 12. Assignment #5: Adding filters to reports and charts

361

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

17.Change the X axis to rotate the text and make it look better. Right Click X Axis, select
rotate, then select 45 as in Figure 12-32

Figure 12-32 45-degree x axis labels

18.Enable the 3D effect and make it look better. Select Format tab and select 3D Effect icon.

Figure 12-33 Selecting 3D Effect icon

19.Select Series tab, select Marker icon and select None. If not change on Interactive Design
View, once select another one (for example Square), next select None.

Figure 12-34 Selecting Marker con

362

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

20.Run your report. Figure 12-35 shows the result of running this report.

Figure 12-35 Two-year product revenue trend lines

21.Save your graph as 5d - Line chart: Revenue trend graph.

12.3.2 Adding a user-specified date range parameter


Up to this point, we plotted one point for every month/year combination in our data. This is not
practical because the history grows in size. Next we select a specific range to display. In this
example, we allow the user to specify an ad hoc date range.
22.Drag ORDERDATE to the filter pane.
23.In the filter pane (Figure 12-36), complete these steps:
a. Select Greater than or equal to.
b. Select Prompt and Prompt using Text Input (Simple).

Figure 12-36 Selecting prompt using Text Input (Simple)

Chapter 12. Assignment #5: Adding filters to reports and charts

363

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

c. Enter FROM_DATE to Variable; field, and enter Star Date (YYYYMMDD) to Prompt: field for
your users. Click OK.

Figure 12-37 Entering variable and prompt field

24.Again drag ORDERDATE to the filter pane.


25.In the filter pane (Figure 12-38), complete these steps:
a. Select Less than or equal to.
b. Select Prompt and Prompt using Text Input (Simple).
c. Enter TO_DATE to Variable; field, and enter End Date (YYYYMMDD) to Prompt: field for
your users. Click OK.

Figure 12-38 Setting filter

364

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

26.Save and run your report. Figure 12-39 shows the results of running this report.

Figure 12-39 Trend graph with variable date range

27.Try various date combinations.

Chapter 12. Assignment #5: Adding filters to reports and charts

365

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

12.4 Filter in metadata - Europe Revenue and Profit report


Century Electronics sells their products to store worldwide. Executive Dan anticipates that
many of the reports that will be requested in the future will be for stores in on European
countries. When the time comes, you can certainly create filters in each of these reports
(WHERE COUNTRY IN (France, Germany, Spain) - and in this case the same rule has to
be re-coded in each report. But a better solution (and best practice) is to exploit the power of
metadata and create the rule just once in the synonym and enforce it in all of the reports. To
set a filter in metadata you can use the web interface or the Developer Workbench tool. Both
techniques are explained in *** insert xref to ch. 3.9 creating filters ***. In this example we will
be using Developer Workbench. If you do not have this licenced tool please refer to
instructions provided in *** insert xref to ch. 3.9 creating filters *** on how to do it with the web
interface.

12.4.1 Define filter in synonym


We will create a Europe rule that defines which countries are part of Europe and in the
report just say we want it to be validated as true.
1. Open Developer Workbench, select the system on which to work and validate with your
userid and password. Please remember that the user must be part of the DevWorkbench
group (use Administration -> Security Center in the web interface to set up). Select
Data Servers -> EDASERVE -> Applications -> century_electronics, right click on the
cen_orders synonym and select Edit in synonym as shown in Figure 12-40.

Figure 12-40 Define Filter in Developer Workbench - Step 1

2. Right-click the master file name segment that contains the field that you would like to filter
on and select Insert Filter, as shown in Figure 12-41 on page 367, or alternatively
selecting the funnel symbol highlighted. In this case, we want to filter on the Country field,
which exists in our STORES segment.

366

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

Figure 12-41 Define Filter in Developer Workbench - Step 2

3. In the Filter Calculator window (Figure 12-42) go to Column, type Europe, and define it as
an I1 (integer one long) column. This means that we can test if for true or false in our
reports. Double-click COUNTRY under the STORES segment to add it to the filter.
Change the Relations to IN because we must provide multiple countries for the value.
Click on the list button on the value field.

Chapter 12. Assignment #5: Adding filters to reports and charts

367

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 12-42 Creating a filter

4. You are presented with the list of distinct values available in your data. Double-click the
european countries (France Germany and Spain) or use the > button to move the
selections to the right-hand side in the Value(s) Selection window (Figure 12-44). Click OK
to close the Value(s) Selection window

368

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

Figure 12-43 Choosing values

5. In case of need you can add more elements typing in directly in the VALUE box - you know
that your company is going to open new stores in Portugal and want your metadata to be
ready for that occurency, so you add OR Portugal to the list of values to be checked. Click
OK to close the Filter Calculator window.

Chapter 12. Assignment #5: Adding filters to reports and charts

369

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 12-44 Creating a Filter detail

We are now ready to use our Europe filter, since we have been asked to provide a Revenue
and Gross Profit report for the european countries. The report is shown in Figure 12-45 on
page 371.

370

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

Figure 12-45 Europe Revenue and Profit report

12.4.2 Using predefined filters in a report


To produce this report we can start from the previous basic 5a - Revenue by Country &
Product:
1. If you had closed Info Assist and report from the previous exercise login to DB2 Web
Query, double click on folder Century Electronics and subfolder Assignment 5 then right
click on report 5a - Revenue by Country & Product and select Edit. If Info Assist and
this report are still open from previous assignments just procede to step 2.
2. In Info Assist position to the Format ribbon and select Stack Measure in Features
group.(Figure 12-46).

Figure 12-46 Stack Measure

3. Find the Profit field and drag in to the SUM aggregation item in the Query pane, as shown
in Figure 12-47.

Chapter 12. Assignment #5: Adding filters to reports and charts

371

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 12-47 Add Margin field to report

4. In the data pane locate your Europe filter and drag it in the filter pane (Figure 12-48 on
page 372).

Figure 12-48 Add Filter to the report

5. A pop up opens up where you can set the check to true or false. If TRUE is selected
then you will get only european countries, if FALSE is selected only countries not listed in
the filter will appear in the report. Leave in to true and select OK (Figure 12-49).

Figure 12-49 Setting filter to true

6. This report now includes only the countries that are defined in the Europe filter. Save it as
5e - Europe Revenue and Profit and run it. The output should look like .

372

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

Figure 12-50 Revenue and Profit for european countries

Chapter 12. Assignment #5: Adding filters to reports and charts

373

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

12.5 InfoMini - Slicers - InfoMini Rev & Cost report


For the next request, Executive Dan throws you a curve ball. He would like a report that
summarizes revenue and costs by product type with the capability to be filtered on all or any
of the time elements and on a geographical bases. The users must have the capability to
setup the compare operators at runtime (i.e. decide if they want equal, not equal, greater than
.....) and have to be prevented from choosing no data combination (i.e. country=France and
city=Honolulu no Honolulu city in France 0 records returned from query). In
Figure 12-51 you can see an example of the requested report.

Figure 12-51 InfoMini report with slicers

Info Assist provide the InfoMini funtionality that can easily help in accomplishing this task.

12.5.1 Defining dimensions in synonym


In InfoMini slicers you can put any field - however, if you have defined dimensions in your
synonym and you use them in InfoMini slicers, the various fields in the dimension are
automatically connected to each other. For more information on dimensions please refer to
***insert xref to ch 3.9 Defining dimensions ***.
Note: Developer Workbench, a DB2 Web Query optional feature, is a prerequisite for
creating OLAP-enabled reports. Developer Workbench is the only interface for defining the
hierarchies that are required by OLAP at the time this redbook was written. Eventually a
Web based interface for building dimensions may be available.
Since we want to use the Date and Store Location dimensions in our report, we are going to
define the corresponding dimensions in our synonym:
1. Start Developer Workbench.

374

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

2. Expand WebFOCUS Environments system name Data Servers


EDASERVE Applications Century Electronics.
3. Right-click the cen_orders.mas table and select Edit in Synonym Editor (Figure 12-52).

Figure 12-52 Developer Workbench, edit synonym

Chapter 12. Assignment #5: Adding filters to reports and charts

375

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

4. In the Synonym Editor select the Dimension Builder icon in the tool bar, highlighted at # 1
in Figure 12-53. You are presented with the Dimension Builder pane, highlited at #2.

Figure 12-53 Developer Workbench - Dimension Builder

5. Right click on Dimension and select Insert New Time Dimension. as show in
Figure 12-54.

Figure 12-54 Dimension Builder, New Time Dimension

6. You are presented with a list of the segments defined in your sysnonym (Figure 12-55 on
page 377). Select the segment that holds the date field you want to use. In our example
we user ORDERS, with its ORDERDATE field. Click OK.

376

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

Figure 12-55 Time Dimension Candidate

7. You are presented with a panel where you can set if you want to choose individual fields
(where the basic date components are already decomposed) or if you want one single
field to be decomposed into basic elements (Figure 12-56). Here we take the second
choice. Select Next.

Figure 12-56 Date Dimension - Decompose date field

8. You will notice that a full time decomposed dimension is populated, as shown in
Figure 12-57 on page 378.

Chapter 12. Assignment #5: Adding filters to reports and charts

377

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 12-57 Time Dimension

9. Richt click on the original label, select Rename and rename it to suit your needs, here we
use Order Date Hierarchy. Repeat the process for the second level title (Figure 12-58).

Figure 12-58 Rename Hierarchy

10.Right-click Dimensions and select Levels Hierarchy as shown in Figure 12-59 on


page 379.
There are two types of hierarchies. One is based on levels and the other is based on
parent-child relationships. We use level hierarchies. The level hierarchy is the example
that we have used so far, that is, country, regions, state, and city are a level hierarchy.
For more information about the different types of hierarchies see the Developer
Workbench help text.

378

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

Figure 12-59 Insert new dimension

11.Right click on the new hierarchy and select Rename (Figure 12-60). Here we use Product
Info. Repeat the step at the Dimension level.

Figure 12-60 Adding a hierarchy

12.In the left hand side of the Edit Synonym window select the segment in which the required
fileds are located, here we use INVENTORY. Hold the CTR key and select the field you
want to be in the dimension in the exact order you want them to appear (here the
sequence is Product Type, Product Category, Model, Product Name). Press the left
mouse button and drag all fields to the hierarchy on the right hand side of the panel - see
Figure 12-61 on page 380. In alternative you can drag each field, one by one.

Chapter 12. Assignment #5: Adding filters to reports and charts

379

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 12-61 Drag fields to hierarchy

13.Repeat the process from step 10 to add a Store Locations (segment INVENTORY fields
COUNTRY, REGION, STATE, CITY) and Manufacturing Locations (PLANT segment,
fields PLANTCOUNTRY, PLANTREGION, PLANTSTATE, PLANTCITY) dimensions.
Your dimension should look like Figure 12-62 on page 381.

380

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

Figure 12-62 Dimension built

You have now completed the all the definitions that are required in our tutorials for OLAP and
InfoMini usage. Typically, this is done once by the IT department. After this, any user with
authority to create reports can choose to OLAP-enable their report.

12.5.2 InfoMini Slicers report


To design the report presented in Figure 12-51 on page 374:
1. Open folder Century Electronics and right click on Assignment 5, select New Report
as shown in Figure 12-63 on page 382.

Chapter 12. Assignment #5: Adding filters to reports and charts

381

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 12-63 Create a new report

2. Info Assist opens up, select synonym CEN_ORDERS as your data source and click on
OK (Figure 12-64 on page 383).

382

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

Figure 12-64 Select data source

3. Create a simple report dragging PRODUCTTYPE, REVENUE and


COSTOFGOODSSOLD in the Interactive design view or in the Query pane to obtain
the result shown in Figure 12-65.

Figure 12-65 Basic report layout

4. Your end users may appreciate getting totals, so we enable the corresponding function
selecting Column Totals in the Home ribbon. In the same ribbon select Header &
Footer and type in Revenue & Cost by Product Type as your header and Data at
&DATEDMYY on &TOD as your footer. Format and align to your liking ().

Chapter 12. Assignment #5: Adding filters to reports and charts

383

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 12-66 Basic report appearance

5. Get to the Format ribbon and select the InfoMini icon as shown in Figure 12-67. Using the
little arrow on the side of the symbol you can toggle the various options - check the Slicers
Tab.
Format Tab - when selected users will get the choice to select the output format at
runtime,under the format tab.
Slicers Tab - when selected users will be presented with filters at runtime, under the
slicers tab.
Run Immediately - when checked report will be executed automatically when called by
user, with HTML format and no filtering. When unchecked users will be presented with
an empty pannel and may select output format and set filters before getting data from
the system.

Figure 12-67 InfoMini options

6. Select the Slicers ribbon. In the list of available fields locate the Date Dimension and
drag it in the slicers bar, where it says Drag Fields here to create slicers as shown in
Figure 12-68 on page 385.

384

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

Figure 12-68 Add Slicer

7. You will notice that all the fields that are part of the selected dimension are brought into the
slicer. Click on New Group to create a new slicer (Figure 12-69).

Figure 12-69 Slicers, Date Dimension

8. In the list of available fields locate the Product Dimension and drag it in the slicers bar, in
the new group that was previously created. Your slicers should now look like Figure 12-70.
You can add to slicers dimensions (all field in the dimension will be available for filtering) or
fields on an individual basis. This provides the developer with a very easy and quick way of
definign filtering capabilities in a report.

Figure 12-70 Slicers, Date and Product Dimensions

9. The various filters that have been generated dragging a whole dimension are
automatically connected to each other. Imagine the user sets a filter for QUARTER=1 when listing MONTH to set up a second condition, he/she will be presented with months 1,
2 and 3 only, as shown in Figure 12-71 on page 386.

Chapter 12. Assignment #5: Adding filters to reports and charts

385

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 12-71 Connected filters in slicers

10.Run your report. You will be presented with an empty panel with two tabs, Format and
Slicers. Select Slicers (1) and experiment with the various filtering options you are given.
Clicking on the = sign before each field (2) you can get the various comparison operators
and select what you need (see Figure 12-72). After making your selections click on Run
(3) to execute the report.
3
1
2

Figure 12-72 Setting up slicers at runtime

11.Save your report as 5f - InfoMini Rev & Cost.


Please notice that combining traditional filters and InfoMini slicers can lead to results difficult
to understand by endusers.
Filters set in reports are ALWAYS honored and implented at runtime, but they do no influence
a slicers pulldown set on the same field.
In our report we set up a filter on field ORDERDATE_YEAR (WHERE YEAR = 2012) as
shown in Figure 12-73 on page 387.

386

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

Figure 12-73 Filter on ORDERDATE_YEAR

Then we enable InfoMini Slicers and add the Date Dimension (that includes field
ORDERDATE_YEAR) to it. At runtime the user gets a list of all years that are in the data
(Figure 12-74 on page 388), regardless of the fact that some of these values may be filtered
by a condition in the report. This happens because the list gets populated with a SELECT
DISTINCT on the underlying table, regardless of the actual SELECT statements that will be
composed at report runtime.

Chapter 12. Assignment #5: Adding filters to reports and charts

387

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 12-74 InfoMini filter + slicer

Hence at runtime the user can get a list of all years that are in the data and execute selecting
data that get cuts out by the filter condition. This results in an empty report, as shown in
Figure 12-75.

Figure 12-75 No data report resulting from Filter + slicers

388

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

In Figure 12-76 you can see the underlying SQL statement. You will notice ANDed conditions
(YEAR(T1."ORDERDATE") = 2011) AND (YEAR(T1."ORDERDATE") = 2012) in the
WHERE clause. These two conditions will always lead to an empty data set.
SELECT YEAR(T1."ORDERDATE"), T2."PRODUCTTYPE", SUM(T1."LINETOTAL"),
SUM(T1."COSTOFGOODSSOLD")
FROM QWQCENT/ORDERS T1, QWQCENT/INVENTORY T2
WHERE (T2."PRODUCTNUMBER" = T1."PRODUCTNUMBER")
AND (YEAR(T1."ORDERDATE") = 2011) AND (YEAR(T1."ORDERDATE") = 2012)
GROUP BY YEAR(T1."ORDERDATE"), T2."PRODUCTTYPE" ORDER BY YEAR(T1."ORDERDATE"),
T2."PRODUCTTYPE" FOR FETCH ONLY
Figure 12-76 Underlying SQL Statement

Note: Developers should avoid having filters on fields that are used in slicers or at least
understand their behaviour or undesired results can be obtained in reports.

Note: Please notice that fields used in slicers conditions are always ANDed among
themselves.
If you need to OR conditions, you will have to use standard filters.

Chapter 12. Assignment #5: Adding filters to reports and charts

389

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

12.6 Info Mini - Formats - InfoMini Rev & Cost Format report
We have presented our last report to the end users, and they complained that they also asked
to be able to select the output format at runtime but this option is not in our 5f - InfoMini Rev
& Cost report. So we must add this capability to the report.
1. If you had previously closed your report open it again with the Edit option. Select the
Format ribbon, position on the InfoMini icon and click on little arrow at its right. Check the
Format tab as shown in Figure 12-77.

Figure 12-77 InfoMini Format tab

2. Run the report. You will now get two different tabs, Format and Slicers, as shown in
Figure 12-78 on page 391. Select the Format tab (1) and experiment with the various
output formats you are presented with. Here we present an Active Flash output (2).
Remember that after selecting the format you have to click on Run (3) to actually get your
report executed.

390

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch12.fm

3
2
1

Figure 12-78 Formats and Slicers

3. Save your report as 5f - InfoMini Rev & Cost Format and close it.

Chapter 12. Assignment #5: Adding filters to reports and charts

391

8063ch12.fm

Draft Document for Review August 30, 2013 2:37 pm

12.7 Publish your folder


Now that we have created the requested reports we want to make them available to our
runtime users. This can be done on an individual bases (report by report) or at the subfolder
level.
Publish subfolder Assignement 5 right clicking on it and selecting PUBLISH.

392

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch13.fm

13

Chapter 13.

Assignment #6 : Detail/print
reports
In this chapter perform the following:






Create summary and detailed reports.


Create a chart.
Convert a report to a chart.
Drill down to another report or a chart depending on defined conditions.
Drill down to another report without any condition.
Prerequisites: Before starting this chapter, make sure the following steps have already
been completed:
 Create synonym over the ORDERS table
 Edit ORDERS synonym and define joins to INVENTORY, PLANT, and STORES tables.
If you have not completed these steps, please go to Chapter 7, Creating and editing
metadata - Century Database on page 191.

Copyright IBM Corp. 2012. All rights reserved.

393

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

13.1 A graphical structure of the application


In this chapter we show you how to create different reports and one chart by using
InfoAssist. We use the Century database that ships with the DB2 Web Query in the
QWQCENT library. You can find instructions for creating the metadata/synonym that defines
this database to DB2 Web Query in Chapter 7, Creating and editing metadata - Century
database.
The basic report shows the profit margin for each product category. According the value of the
margin we define conditions for Good Profit and Poor Profit. Depending on Good Profit or
Poor Profit we drill down to another report or a chart as shown in Figure 13-1.

Poor Profit

6a - Basic SummaryReport

PRODUCTCATEGORY

6b - SummaryReportProductCategory

Good Profit

PRODUCTCATEGORY

6d - ChartGoodProfit

PRODUCTNUMBER

6c - DetailReportProductNumber

Figure 13-1 A graphical structure of the application

13.2 Creating the basic Summary report with InfoAssist


(6a - Basic Summary Report)
The basic summary report is used to show the revenue and profit margin of all Product
Categories. Depending on the value of the Margin it is qualified as Good Profit or Poor Profit.
If it is Good Profit, you can drill dow to a chart which shows the Margin over the last twelve
months.
If it is Poor Profit, the drill down will be to anothwer report with all products of the Product
Category. From this summary report it is possible to drill down to a detail report which shows
every single order of a product.

13.2.1 Create an Initial Summary Report


To begin creating a summary report:

394

IBM i DB2 Web Query for i Implementation Guide

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

1. In the navigation area, under DB2 Web Query, expand top folder Century Electronics.
a. If not created yet, create it by right-clicking DB2 Web Query.
Select New Folder Title Century Electronics and click OK.
b. Create a new sub folder under Centrury Electronics and name it Assignment 06 Detail and Print Reports as shown in Figure 13-2.

Figure 13-2 Selecting the folder Assignment 06 - Detail and print report

2. Utilizing the techniques described in earlier chapters, create a new report in folder
Assignment 06 - Detail and print reports.This report has the following specifications:
Based upon the synonym cen_orders
Report header: Good and Poor Profit by Product Category
Report footer: Created on &DATE at &TOD
By fields:

Product Type

Product Category

Sum fields:

Revenue (with commas and floating currency)

Cost of Goods Sold (with commas and floating currency)

Profit (with commas and floating currency)

Margin

Traffic lighting on Margin

Yellow background if Margin > 80

Red background if Margin < 30

Add Column Totals


Add Subtotals to the Product Type column
When you are finished your report should look the example shown in Figure 13-3.

Chapter 13. Assignment #6 : Detail/print reports

395

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 13-3 Basic Summary Report

3. Save the report as 6a - Basic Summary Report

13.3 Creating a summary report with parameter


(6b - Summary Report Product Category)
Next we will create a summary report which should be called by the basic report after a drill
down. Have a look at 13.1, A graphical structure of the application on page 394. There you
will find that this report can be selected and run when the profit of a product category is poor
(Margin is less than 30). In the basic program product types with poor profit have a yellow
background so far. This will be increased to a drill down in chapter 13.7, Creating drill downs
and putting it all together on page 411.
For now it is important to know that a parameter Product Type will be passed to our new
report.. This report must be able to receive this parameter and then show all product numbers
included in this product category.
1. Utilizing the techniques described in earlier chapters, create a new reportin folder
Assignment 06 - Detail and print reports.This report has the following specifications
Based upon the synonym cen_orders
Report header: Good and Poor Profit by Product Category:
<PRODUCTCATEGORY.
Report footer: Created on &DATE at &TOD
By fields:

Product Number

Product Name

Sum fields:

396

Revenue (with commas and floating currency)

IBM i DB2 Web Query for i Implementation Guide

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Cost of Goods Sold (with commas and floating currency)

Profit (with commas and floating currency)

Margin

Traffic lighting on Margin

Yellow background if Margin > 80

Red background if Margin < 30

Add Column Totals


Add filter for Product Category.

Select Prompt using Data Values (Dynamic).

Do not select Multiple Values for Prompt

Specify prompt text: Enter Product Category:

Notice that we used a variable in the report header: <PRODUCTTYPE. As shown in


Figure 13-4, this will force the program to replace the variable by the value of
PRODUCTTYPE that was selected by the user and used to filter the report.

Figure 13-4 Use of a variable in the header

2. Save the report as 6b - Summary Report Product Category.


3. Run the report.

Chapter 13. Assignment #6 : Detail/print reports

397

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 13-5 Runninmg a parameterized report

Because we selected a dynamic prompt when we created the filter, a drop down list box is
added to the report to select a Product Category.
This report can now be run as a stand alone report or as a report which is called from another
report as a drill down.Drill down will explained later.

Figure 13-6 Report with paramter and header with a variable

13.4 Creating a detail report with parameter


(6c - Detail Report Product Number)
The third report will list all products that belong to a product category with poor profit. The
filter is created from the field Product Number.

398

IBM i DB2 Web Query for i Implementation Guide

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

1. Utilizing the techniques described in earlier chapters, create a new reportin folder
Assignment 06 - Detail and print reports.This report has the following specifications
Based upon the synonym cen_orders
Specify two variable in the report header: <PRODUCTNUMBER, <PRODUCTNAME.
Report footer: Created on &DATE at &TOD
By fields:

Order Date

Order Number

Plant Name

Plant Country

Sum fields:

Revenue (with commas and floating currency)

Cost of Goods Sold (with commas and floating currency)

Profit (with commas and floating currency)

Margin

Traffic lighting on Margin

Yellow background if Margin > 80

Red background if Margin < 30

Add Column Totals


Add filter for Product Number.

Select Prompt using Data Values (Dynamic).

Do not select Multiple Values for Prompt

Specify prompt text: Enter Product Category:.

Once again, notice that we used variables in the report header. As shown in Figure 13-7,
this will force the program to replace the variable by the values of PRODUCTNUMBER
and PRODUCTNAME selected by the user and used to filter the report.

Figure 13-7 Add header with to variable fields


Chapter 13. Assignment #6 : Detail/print reports

399

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

2. Change the report type from Sum to detail.


In our example reports we always used the default setting Sum. These reports were
aggregated or summed on the fields which were defined as Sort fields. The Print option in the
Query panel turns off the aggregation and produces a detail listing.This means that each row
returned from the ORDERS table will be represented by a line in the report.
Right-click on Sum in the Query panel and select Print (Figure 13-8 on page 400).

Figure 13-8 Change report type Sum to Print

3. Save it as 6c - Detail Report Product Number


4. Run the report. Your report should prompt for Product Number (Figure 13-9 on page 401).

400

IBM i DB2 Web Query for i Implementation Guide

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 13-9 Report with autoprompt Product Number

Chapter 13. Assignment #6 : Detail/print reports

401

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

13.5 Converting a report to a chart


It is very easy to convert a report to a chart. First we will create a report out of Product
Category, Profit, and Margin. With just a mouse click it can be converted to a chart.
1. Create a new report.
2. Add these fields to it:
Product Category
Margin (Drop as sum)

Figure 13-10 New Report to be converted to a chart

3. Select the Home ribbon and expand the Format group i(if necessary) or select the Format
ribbon and expand the Destination group (if necessary).
4. Click the Chart button which can be found in both groups (Figure 13-11).

Figure 13-11 Select Chart button

5. Your report is converted to a chart.

402

IBM i DB2 Web Query for i Implementation Guide

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 13-12 Chart created from a report

6. If you want you can save the report. But this is not compulsary for our tutorial.
Note: After the report was converted to a chart, the tab Reports at the bottom of the
window was updated (see Figure 13-13). Both, report and chart are still available.

Figure 13-13 List showing both, report and chart

In the next section we will refine this chart so that it will suit to our application.

Chapter 13. Assignment #6 : Detail/print reports

403

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

13.6 Creating a chart


(6d - Chart Good Profit)
We will use the chart from section 13.5, Converting a report to a chart on page 402 which
was created out of a report.
 As we want to use it for a drill down from our first report 6a - Basic Summary Report, if the
profit is good for a special Product Category, we must add a filter (autoprompt) for this
field.
 The default chart is a bar chart. We want to show the margin and profit trending by month
over multiple years in a Line chart. For this purpose we need a define field for MonthYear,
which can be extracted out of the field Order Date. And we have convert the type of the
chart to a bar chart.
 Margin and Profit have different dimensions, so we will add a second Y-axis with another
dimension.
1. The chart which was created before should be opened.
2. Save it as 6d - Chart Good Profit.
3. Add a define field Order_MonthYear with a format of MtYY.
Note: There are many ways to format the date June 2012. Two of the possible choices for
this chart are:
 MtYY which means Jun, 2012
 YYM which means 2012/06

Figure 13-14 Create a define field Order_MonthYear

4. Remove Product Category from the X-Axis in the Query panel.

404

IBM i DB2 Web Query for i Implementation Guide

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 13-15 Delete a field from the X-Axis

5. Add the define field Order_MonthYear to the X-Axis. Drag and drop it to the X-Axis. Your
Query panel should look like in Figure 13-16.

Figure 13-16 Query panel

6. Change the chart type to Line. Select the Format ribbon, expand the Chart Types group,
and select Line.
7. Add Product Category to Legend (Series).
8. Run the query.
Note: It is good practice to run the query after every update to see it it really effects what
you wanted to reach. Do not forget to save it.
Do not worry, it the result looks a bit odd. After the next step it will look better..
9. Add an autoprompt filter using Product Category.
10.Run the chart and select a Product Category.
Now the chart will look better (Figure 13-17 on page 406).

Chapter 13. Assignment #6 : Detail/print reports

405

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 13-17 Chart with parameters

As you can see from Figure 13-17 the date is too wide horizontally for the X-Axis legend. This
is why not every month is listed. It is possible to rotate the date shown on the legend.
11.Right-click on a date in the legend.
12.Select Rotate and 45 (see Figure 13-18 on page 407).

406

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch13.fm

Figure 13-18 Rotate the date legend

13.Run the chart.


14.Add a header to the chart.:
 Select the Home ribbon
 Open Report group
 Select Header & Footer
 Select Page Header
 Enter Good Profit (Margin > 80)
 Click OK

Figure 13-19 Add header to the chart

Chapter 13. Assignment #6 : Detail/print reports

407

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Your chart should look now like in Figure 13-20 on page 408.

Figure 13-20 Chart for Good Margin

15.Remove Order_MonthYear from the legend: Right-click on the text and select Delete.
Now we will add a trend line for Profit. This can be done by creating a second Y-Axis and put
the Profit on it. The dimension of Propfit will be different from the one Margin. So think of it
just as a trend line, without comparing the absolute values of Profit and Margin.
If we want to add a second Y-Axis, we have to select another type of chart named Vertical
Dual-Axis Absolute Line.
16.Select the Format ribbon, expand the Chart Types group, and select Other.
17.On the Other Chart Types Menu select the second category Line and then Vertical
Dual-Axis Absolute Line (see Figure 13-21 on page 409).

408

IBM i DB2 Web Query for i Implementation Guide

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 13-21 Select another chart type

In the Query panel a new Y2 Measure is added.


18.Drag and drop the Profit field from the Data list to the Y2 Measure (Figure 13-22).

Figure 13-22 Query panel with a second Y-Axis

19.Run the chart (Figure 13-23 on page 410).

Chapter 13. Assignment #6 : Detail/print reports

409

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 13-23 Chart with Profit and Margin

20.Save the chart as 6d - Chart Good Profit

410

IBM i DB2 Web Query for i Implementation Guide

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

13.7 Creating drill downs and putting it all together


Now the time has come to put all reports and the chart together.It is very easy to create a drill
down and to pass one or more parameters. But be careful when adding the name of a
parameter. It must correspond exactly to the name of the parameter, which the called program
expects.
Have a look at 13.1, A graphical structure of the application on page 394 to see the three
different drill downs. There are two conditional drill downs from the first report 6a - Basic
Summary Report:




If the profit is good, chart 6d - Chart Good Profit is loaded.


If the profit is poor, the second report 6b - Summary Report Product Category is loaded.
For both drill downs parameter PRODUCTCATEGORy is passed.

 The third drill down is initiated by the second report without a conditon:



The third report 6c - Detail Report Product Number is launched. whatever condition exists.
As a parameter the value of PRODUCTNUMBER is passed.

Note: A parameter can be passed via an autoprompt when the query is called directly (as
we did in our report and chart). It can be passed when one report links or drills down to
another. It can be also passed from an HTML page. .

13.7.1 Conditional drill downs from the Basic report


1. Edit our first report 6a - Basic Summary Report.
2. Right-click the Margin column.
3. Select More, then Traffic Light-Conditions.
4. Select Margin Good Profit and click Drill Down (see Figure 13-24 on page 411).

Figure 13-24 Select to create a drill down

A new window will open.

Chapter 13. Assignment #6 : Detail/print reports

411

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 13-25 Find the report to be drilled down to

5. Select Report and Browse.


All the reports and charts which were created in folder Assignment 06 - Detail and print
report will be listed.

Figure 13-26 Queries in folder Assignment 06 - Detail and print report

6. Select chart 6d - Chart Good Profit and click Open.

412

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch13.fm

Figure 13-27 Select a query from the list

The selected query and the path to it is added for a drill down. Now we have to select a
parameter which is passed to the selected query.
7. From the drill down window select the Add Parameter icon (see Figure 13-28).

Figure 13-28 Add a parameter

8. Enter parameter name PRODUCTCATEGORY and select Product Category from the
list box.

Chapter 13. Assignment #6 : Detail/print reports

413

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 13-29 Enter parameters name and value

Note: The name of the parameter must be exactly the same as it was used for the
autopormpt filter of the drilled down query. The name is even case sensitive.
9. Click OK twice and you will be back to Traffic Light Condition for Margin window.
Now we will add the second drill down for Poor Profit.
10.From the Traffic Light Condition for Margin window select the condition for poor profit and
click the Drill Down button.
11.Please follow steps 4.) to 10.).
 Select the second query 6b - Summary Report Product Category as the drilled down
report.
 Select the same parameter PRODUCTCATEGORY as before.
12.Click OK.
13.Save the report
14.Run the report.
Have a look at the margin column. The values with good and poor profit are shown with
background colour yellow and pink. These fields are underlined indicating a hyperlink.

414

IBM i DB2 Web Query for i Implementation Guide

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 13-30 Report with drill down function

When you click on a Good Profit link the chart should be created showing the margin and
the profit of the selected Product Category.
When you click on a Poor Profit link the second report should be created showing all
products of the selected Product Category.
Note: When you select a drill down and it does not show the query with the selected
Product Category, instead it shows an autoprompt for the category, please check the
spelling of the parameters name.
This should be your result when everything is fine (Figure 13-31 on page 416):

Chapter 13. Assignment #6 : Detail/print reports

415

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 13-31 Basic report and drilled down report and chart

13.7.2 Non-conditional drill down from the second to the third report
In the previous section we showed you how to create conditional drill downs and pass a
parameter. In this section we will use a simple non-conditional drill down. The way of adding a
drill down and passing a parameter is nearly the same as showed before. The only difference
is the entry point.
1. Edit the second report 6b - Summary Report Product Category.

416

IBM i DB2 Web Query for i Implementation Guide

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

2. Select column Margin.


3. Check if the ribbon Field-Margin is shown.
4. Click the Links group if not opened (see Figure 13-32 on page 417).

Figure 13-32 Open the Links group

5. Click Hyperlink button in the Links group.


The Drill Down window opens.
The following steps are similar to the ones in step 5 on page 412.
6. Select Report and Browse.
7. Find and select 6c - Detail Report Product Number.
8. Add PRODUCTNUMBER as a parameter.

Chapter 13. Assignment #6 : Detail/print reports

417

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 13-33 Add a report and parameter to the drill down

9. Click OK.
10.Click OK.
11.Save the report.
12.Run the report.
The result of the drill down is shown in Figure 13-34 on page 419.
Note: We did not use a conditional drill down. This is why all fields in the Gross Profit
Margin column are underlined, which is a hint for a hyperlink.

418

IBM i DB2 Web Query for i Implementation Guide

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 13-34 Drill down for the third report

13.7.3 Publish the reports/chart


Finally you have to publish your reports and chart so that other users are able to see the
reports and run them.
1. Right-click each report/chart and select Publish.

Chapter 13. Assignment #6 : Detail/print reports

419

8063ch13.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 13-35 Publish all reports

Note: If you publish only the first reports which calls the other reports/chart by a drill down,
you will not be able to drill down (see Figure 13-36 on page 420).

Figure 13-36 Message if report/chart is called by a drill down without being published

Better you get the result which is shown in Figure 13-37 on page 421

420

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch13.fm

Figure 13-37 The final result of your drill down application

Congratulations! You have finished Tutorial Chapter 13, Assignment #6 : Detail/print


reports on page 393.

Chapter 13. Assignment #6 : Detail/print reports

421

8063ch13.fm

422

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ch14.fm

14

Chapter 14.

Assignment #7: Implementing


OLAP
Online analytical processing (OLAP) is best known as the technology that allows a user to
slice and dice data or drill down into data. DB2 Web Query makes it easy to provide users
with a sophisticated drill-down, slice and dice interface without the report developers having
to do anything at all. You will have a better understanding of this concept by the time you finish
this tutorial. After taking a standard report created with InfoAssist, 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 user to slice and dice or pivot
their data and perform a variety of local analysis on the original report.
Tables must have any embedded hierarchies predefined via the Developer Workbench. After
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, 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. 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. If a user simply had to click 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.

Copyright IBM Corp. 2012. All rights reserved.

423

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

14.1 Assignment
In this assignment you will provide a solution that goes above and beyond Executive Dans
requirements. You will OLAP enable a report. By doing so, a fairly simple summary report
turns into a powerful query in which report runners can drill down, slice and dice data, and
analyze data in ways they never considered before. A before and after example is shown in
Figure 14-1 below.

Figure 14-1 A simple report (before and after OLAP is enabled)

424

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch14.fm

14.2 OLAP terminology


Before you begin, it is important to understand some of the various terms associated with the
OLAP erminology. Table 14-1 covers basic OLAP terminology to explain the concepts that we
use in this chapter.
Table 14-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 contains multiple models and each model contains multiple part
numbers or SKUs.

Drill down

An action that involves going from one level in a hierarchy to the next lower level. For
example, if a user drills down on country, he sees the different regions that make up the
country. If he then drills down on region, the states that compose the region are
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 takes
precedence in an OLAP report over drilling down through the hierarchy.

Hierarchy

The structure or sequence of each of column within the dimension. In the example,
above the geography dimension is a hierarchy of country, region, state, and city.

Hyperlinks

A column that is displayed in blue in a report. The user can click the 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.

Measure

Numeric fields that you want 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 is the specific intersection or slice of the data in
which you are interested. Normally, these fields are summed or totalled, but they do not
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 is
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

To move a field from a column to a row or vice versa. For example, year might be one
of the by fields where the different years are listed down the side of your report. If you
wanted the various years across the top of your report instead, you pivot the field or
heading Year. You can do this in multiple ways in an OLAP report including dragging the
field or using the control panel to pivot your data.

Chapter 14. Assignment #7: Implementing OLAP

425

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

14.3 Tuning on OLAP option in InfoAssist


The first report is a simple summary that shows revenue by product type. Next you will enable
OLAP with this report.
Prerequisite: If you create OLAP reports, you should define dimensions for OLAP
Analysis. reports. Prior to reading this section, you must read 12.5.1, Defining
dimensions in synonym on page 374.

14.3.1 Creating an Initial Report


1. Create Assignment 07 - Implementing OLAP folder.
2. Right-click the Assignment 07 - Implementing OLAP folder.
3. Select New and Report. This will open InfoAssist.
4. Select CEN_ORDERS sysnonym.
5. Click OK.
6. Double-click the Product Type.
7. Double-click the Revenue.

Figure 14-2 Move Product Type and revenue from Data Panel to Interactive Design View

8. If the Report group is not already expanded, click the Report icon on the ribbon to open it.

Figure 14-3 Selecting Report icon

9. Click Column Totals in the expanded Report ribbon(Figure 14-4 on page 427).

426

IBM i DB2 Web Query for i Implementation Guide

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 14-4 Selecting Column Totals

Editing Format a Column


10.Click the Revenue field. You are going to format this field with commas and dollar signs.
When you select the Revenue field, the ribbon becomes field-specific. Some of the
groupings may already be expanded depending on the width of your screen. In this case,
you may need to expand the Format group.(Figure 14-5)

Figure 14-5 Editing Format

11.Select the comma.(Figure 14-6)

Figure 14-6 Adding a comma

12.Select the currency symbol down arrow and then choose Floating
currency.(Figure 14-7)

Chapter 14. Assignment #7: Implementing OLAP

427

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 14-7 Adding the currency symbol

Using Aggregation Functions


You are going to add a count of the number of orders for each product type to the report.
13.If compressed, expand Dimensions in the Data panel.
14.Drag Order Number to the left of the Revenue column, then Select Drop as Sum.
(Figure 14-8)

Figure 14-8 Dropping as Sum

15.Right-click Order Number, in the report, to open the field-specific submenu.


16.Select More, then Aggregation Functions and then select Count. (Figure 14-9)

Figure 14-9 Selecting Aggregation Functions as Count

428

IBM i DB2 Web Query for i Implementation Guide

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

17.To create a new heading in the Query panel, right-click CountOrderNumber to see the
field specific submenu.

Figure 14-10 Selecting Change Title

18.Select Change Title and type the new title Count.Click OK.

Figure 14-11 Changing Title

19.Click Save, save the report with the name 7a - Revenue summary.
20.Run the report. You have completed your initial summary report.

Figure 14-12 7a - Revenue summary

21.Close the report 7a - Revenue summary to return to the Interactive Design View.
We will continue to use this report as the basis for our next report.

14.3.2 To enable an OLAP report (How to Use Auto Drill & Analysis)
22.Select the Format ribbon and expand the Navigation group if it is compressed.
23.Open the report 7a - Revenue Summary

Chapter 14. Assignment #7: Implementing OLAP

429

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

24.Click Auto Drill & Analysis.

Figure 14-13 Selecting Auto Drill & Analysis

25.Run your report. Do not save this version

Figure 14-14 Run your report

26.The Product Type is automatically highlighted and underlined; this indicates that you can
drill down on this column.
27.Click Audio.
In the CEN_ORDERS master file, Product Category was below Product Type in the
Product dimension. You are now drilling down to the Product Categories within Audio.
Note: If you dont remember the dimension, you should read 12.5.1, Defining
dimensions in synonym on page 374.

Figure 14-15 Drilling down to Product Category

28.Close the results display.


Auto Drill & Analysis has much more power than the simple example you just executed. Look
at the drop down options on the Auto Drill button. Dimensions grouped in tabs, for example,
can turn a small report into a powerful analytical tool.
29.Select Dimensions grouped in tabs.

430

IBM i DB2 Web Query for i Implementation Guide

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 14-16 Selecting Dimensions grouped in tabs

30.Under the More options, select Dimensions and Measures.This gives you the maximum
drill-down capabilities. When creating your own reports, you can choose to drill down on
the dimensions only and not the measures.

Figure 14-17 Selecting Dimensions and Measures

Chapter 14. Assignment #7: Implementing OLAP

431

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

OLAP options: The Enable OLAP options control how users can interact with an
OLAP report and access OLAP tools:
 OLAP panel is not accessible (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.
 OLAP panel is accessible (Show Panel in Report): includes a small OLAP
symbol in the lower left to more obviously allow the user to open the OLAP
Control Panel. And when you click the square button over a dimension, you open
the OLAP Control Panel.
 Dimension filtering enabled (Show filters on top/bottom): adds the OLAP
Selections pane to the top (or bottom) of the report. This option is acceptable
with a few dimensions and a few levels in each hierarchy. It tends to look messy
when you have too many levels within different dimensions. Try it to see the
difference between showing dimensions and hierarchies as filters or as tabs.
 Dimensions grouped in tabs (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 that we use.
 Hide access to the OLAP panel (Columns with panel): looks the same as OLAP
panel is not accessible, but when you click the square button over a dimension,
you open the OLAP Control Panel.
Automatic drill options:
 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 down to the lowest level of all displayed hierarchies.
 None: The user cannot drill down to a lower level in the hierarchy within the
report itself.
31.Click Save, save the report with the name 7b - Revenue OLAP report.
You have now OLAP enabled your report. To summarize, we took a basic report and selected
an output option to enable OLAP. This simple selection automatically gives you an enormous
amount of analysis capabilities, as you will see in the next section.

14.4 Working with an OLAP enabled report


To begin working with the OLAP-enabled report as explained in this tutorial, run your 7b Revenue OLAP report. Figure 14-18 shows this report.
Notice the addition of a completely new panel at the top of the report. This is called the
Selection pane. It includes tabs for every dimension described for any of the tables that are
part of the orders cluster. You also have the capability to work with the measures and to
create graphs directly from the report.
There are three ways to work with your OLAP data:
 From the report itself
 From the Selections pane
432

IBM i DB2 Web Query for i Implementation Guide

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

 From the Control Panel


In the report shown in Figure 14-18, you cannot see the control panel. In this example, the
control panel starts as hidden or closed. You can open it by clicking the OLAP button or by
clicking the blue square to the left of the Product Type heading.

Figure 14-18 7b - Revenue OLAP report

14.4.1 Slicing, dicing, and drilling down for more details


Looking at the report in Figure 14-18 on page 433, 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.
Tip: When working with an OLAP-enabled report, there are multiple ways to accomplish
the same end result.
To use the arrows and buttons to drill down for more details, follow these steps:
1. Because revenue was previously unsorted, neither half of the arrow is dark and the prompt
reads sort Revenue. Click the sort arrow to the left of Revenue (Figure 14-19).

Figure 14-19 Sorting a measure

2. Now that you have sorted by revenue, hover over the column again. Notice that the bottom
half of the arrow is dark. Click this arrow and sort the column in descending sequence
(Figure 14-20).

Chapter 14. Assignment #7: Implementing OLAP

433

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 14-20 Sorting from highest to lowest

Right-click the column heading Revenue and select Visualize (Figure 14-21).

Figure 14-21 Revenue context menu

As we saw in Active Reports, selecting Visualize displays bars to help you quickly note
trends or easily compare two columns. See Figure 14-22.
Note: Positive numbers are visualized with blue bars, while negative numbers are
visualized with red bars.

Figure 14-22 Revenue visualization

3. Click the Store Location tab.


The Store Location tab has a drop-down tab for each element in the hierarchy, proceeding
from the top of the hierarchy to the bottom.
By default, each of the drop-down lists contains all the unique values for that column. For
example, initially every region in the world is available under the Region tab.

434

IBM i DB2 Web Query for i Implementation Guide

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

4. To start to filter and drill down on your data, click the Country drop-down list and select
United States (Figure 14-23).
Tip: You can select multiple values using the Ctrl or Shift keys.

Figure 14-23 Selecting a hierarchy

5. Click the Region drop-down list. Notice that the only regions displayed are for the United
States. Select the North region (Figure 14-24).

Figure 14-24 Continuing to filter within hierarchy

6. The filters in the Selection pane do not take effect until you click Run. Review your current
totals and click Run (Figure 14-25).
Your report now shows the revenue and number of orders for the North region in the
United States.

Figure 14-25 Run your filtered report

7. Notice that immediately to the right of COUNTRY and REGION is an equals sign (=). Click
the = button. Each time that you fill in a value you filter your data by creating a WHERE
clause. Instead of selecting COUNTRY equal to United States, we can select all countries
except the United States by changing the button to not equal. Click the button multiple
times to cycle through your choices.
8. Click Reset to reset the report back to its initial state. You can also use the back arrow on
the browser to go back one page at a time.

Chapter 14. Assignment #7: Implementing OLAP

435

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

9. Click the Product Info tab (Figure 14-26).

Figure 14-26 Drilling down on Product Type

10.Drill down within the report, not by using the hierarchy tabs. Click Audio.
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
(Figure 14-27).

Figure 14-27 Drilling down on Product Category

436

IBM i DB2 Web Query for i Implementation Guide

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

11.Drill down on Amplifiers/PreAmps/Tuner to see the products that compose the Amplifier
category.
Again notice that the drop-down lists have been filled in for you. You can go back and forth
this way between the body of the report and the tabs at the top. See Figure 14-28.

Figure 14-28 Results of Product Category drill down

12.Continuing to analyze our data, drill down to see only the Amplifier sales that occurred in
January 2011. Click the Order Date Hierarchy tab.
13.For ORDERDATE_YEAR, select 2011. You can then select the quarter or go straight to
ORDERDATE_MONTH and select 1 (Figure 14-29).

Figure 14-29 Selecting values in non-consecutive levels

14.Click Run. Figure 14-30 shows the results of running this report.

Figure 14-30 Slice of your data (January 2011)

15.Click Reset to start back at the beginning with an unfiltered report.


16.Try drilling down on a measure or total field. Drill down on the Revenue column for Office
products (Figure 14-31).

Chapter 14. Assignment #7: Implementing OLAP

437

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 14-31 Drilling down on a measure

After drilling on the revenue for office products, the Office product type is expanded to its
subcategories and products. The revenue and Count are now grouped at a much more
detailed level (Figure 14-32).

Figure 14-32 Results of drilling down on a measure

17.Reset your report now so that all drill-downs are removed.

438

IBM i DB2 Web Query for i Implementation Guide

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

18.The next request from our users is to generate a report that shows revenue by product
type by year.
Drag ORDERDATE_YEAR from the Selections pane into the area of the report where you
want it (that is, across the top). The plus symbol (+) shows that you are in a valid area in
which to drop the field (Figure 14-33).

Figure 14-33 Dragging and dropping dimensions

19.Right-click Count and select Hide (Figure 14-34).

Figure 14-34 Hiding a field

20.We now have a pivot table (Figure 14-35).

Figure 14-35 Pivot report

Chapter 14. Assignment #7: Implementing OLAP

439

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

21.Click Save and select Save the data in an Excel 2000 file with formulas to save the new
Excel file (Figure 14-36). You can also see what happens when you save to a PDF and an
Active Report output formats.

Figure 14-36 Saving an OLAP report

22.We get the Excel format report (Figure 14-37).

Figure 14-37 Excel 2000 file with formula

23.Our users have changed their minds and decided that they do not want a pivot table.
Instead they want to see the year and product type to the left of Revenue.
Drag ORDERDATE_YEAR from the Sort across portion of the report to the Sort by
section (Figure 14-38).

440

IBM i DB2 Web Query for i Implementation Guide

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 14-38 Pivoting a column

In addition to dragging from the Selection pane area, there are other methods to display
additional columns in the report as explained in the following steps.
24.Right-click ORDERDATE_YEAR and select Unhide (Figure 14-39). You see a list of
columns that were either part of the initial report or that are in one of the hierarchies.
These are the columns that are available for display.

Figure 14-39 Unhiding columns

25.Try the same process for the Revenue field. Right-click Revenue and select Unhide.
Notice that you see that only numeric fields are available.
26.Click the down arrow for the Measures tab (Figure 14-40):
a. You will see a list of all the measures that are available to you in this report. Notice that
Count has no check mark. This is because we hid it. To display Count, select it again.

Chapter 14. Assignment #7: Implementing OLAP

441

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

b. Select Revenue. Notice that you can cycle through the different options for displaying,
visualizing, and hiding the measure. We visualize Revenue, display Count, and Run
the report again.

Figure 14-40 Measures tab

442

IBM i DB2 Web Query for i Implementation Guide

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

27.Click the down arrow for the Graph tab (Figure 14-41):
a. Select Revenue.
b. Click the icon to the right of Revenue to cycle through the graph types until you come to
pie charts.
c. Click Run.
d. Make the pie chart window larger by dragging down the horizontal break line between
the graph and the report.

Break line

Figure 14-41 Graphing an OLAP report

Chapter 14. Assignment #7: Implementing OLAP

443

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

Notice that there is one pie chart for each year that was your major sort by axis. See
Figure 14-42.
Tip: To control the scope of the graph, use the drop-down lists in the Selection pane.
For example, if you only want a graph for 2011 revenue, you can select the year 2011
from the ORDERDATE_YEAR drop-down list.
If the measures in the original report were drill-down capable, then the graph can be drilled
into.

Figure 14-42 Graph drill down

Drilling down on the graph generates the same report as though you drilled down on the
Revenue field in the original report.
28.Experiment with the various options for drilling down and filtering your report. When you
are finished, click Reset to restore the report to its original values.
Tip: If our report has multiple measures that can be graphed, you can graph them on the
same chart. You can select each measure for graphing and choose a different graph type.
For example, if our report contains profit, you can superimpose a line graph on a bar graph
with the line representing the profit and the bar representing revenue.

444

IBM i DB2 Web Query for i Implementation Guide

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

14.4.2 Manipulating the data using the OLAP Control Panel


Up to this point, we have manipulated the OLAP report through the Selection pane at the top
of the report and directly through hyperlinks in the report itself. Now we use the third method
for interacting with the data, which is the OLAP Control Panel.
1. Click the OLAP button at the bottom of the Selections pane to open the OLAP Control
Panel. Alternatively, you can click the blue square next to Product Type.
Tip: If your OLAP Control Panel shows the selection criteria pane, click OK to return to
the view shown in Figure 14-43.

Figure 14-43 OLAP Control Panel

Although the most frequently used functions are available directly from an OLAP report,
the Selections pane, or both, several functions can be performed only from the OLAP
Control Panel. The OLAP Control Panel can do everything that can be done from the
OLAP report and the Selections pane and more.
The following unique OLAP functions, among others, can be performed only from the
OLAP Control Panel:

Selection of a Top or Bottom n rows report


Ability to group numeric data by percentile (or decile, quartile, and so on)
Advanced row selection criteria
Stacking of multiple measures vertically in a report as opposed to horizontally

Chapter 14. Assignment #7: Implementing OLAP

445

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

2. We want to see our data in columns by quarter:


a. Expand Date Dimension.
b. Click the Drill Across box. When selected, it is surrounded by a blue rectangle.
c. Click the ORDERDATE_QUARTER field. It should appear in the Drill Across box. See
Figure 14-44.
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 columns.
d. Click Run.

Figure 14-44 Specifying data in columns by quarter

446

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch14.fm

e. Double-click Quarter Q1 to drill down to ORDERDATE_MONTH (Figure 14-45).

Figure 14-45 Cross-tab drill down

3. Often when you have multiple measures and sort across columns, the report can become
wide and unwieldy. Open the OLAP Control Panel and select Stack Measures
(Figure 14-46). Click Run.

Figure 14-46 Stack Measures option

Chapter 14. Assignment #7: Implementing OLAP

447

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

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
(Figure 14-47). Although this is technically accurate, it probably is not what the user wants
to see.

Figure 14-47 Stacked measures report

448

IBM i DB2 Web Query for i Implementation Guide

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

4. From the OLAP Control Panel, expand Date Dimension and select Values for
ORDERDATE_YEAR (Figure 14-48).
Note: For most dimensions, when you click Values, you see the list of values from your
table. The date components are prefilled in with general dates. If you expand
ORDERDATE_MONTH, you see that the actual month names (that is, June) are filled in
for ease of use for the user.
5. For ORDERDATE_YEAR, select 2011.

Figure 14-48 Filtering an OLAP report

6. At this point you can click Run. However, for demonstration purposes, click OK to see the
full Selection Criteria pane.

Chapter 14. Assignment #7: Implementing OLAP

449

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

7. In the Selection Criteria pane (Figure 14-49), notice that Q1 is prefilled in for ORDERDATE
QUARTER because we drilled down and selected Q1 prior to opening the control panel.

Figure 14-49 OLAP filtering

If you use the scroll bar on the right, you 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.
If you want to filter on Product Type, you have two choices. You can click the down arrow
next to Product Type or you can click Select. In both cases, you see a list of all the unique
values for Product Type. Using the Select button takes you to a second window. This is
easier to use when you are selecting multiple values.
Again, when filtering, you can modify the operand for each filtered column. Here we do not
filter on Product Type.
Click Run.

450

IBM i DB2 Web Query for i Implementation Guide

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 14-50 shows the output of running the report.


Note: Best practice states that you should always display any filters in effect on a
report. DB2 Web Query has the capability from the OLAP Control Panel to document
your filters at the beginning or end of your report.

Figure 14-50 2011 only report

8. If you are still on the Selection pane in the OLAP Control Panel, click OK to return to the
initial layout. Notice that you can click Selection Criteria in the bottom right of the Control
Panel to return directly to the Selection Criteria layout.

Chapter 14. Assignment #7: Implementing OLAP

451

8063ch14.fm

Draft Document for Review August 30, 2013 2:37 pm

9. In the Measures pane (Figure 14-51) select the Revenue check box. Then click the
Revenue name.

Figure 14-51 Measures pane

10.In the Revenue pane (Figure 14-52), if we want to see a Top 3 analysis report:
a.
b.
c.
d.
e.

452

Select the Sort check box.


Select High to Low.
Select the Rank (1, 2, 3...) check box.
For Highest, select 3.
For Measure Calculations, keep the default of None.

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch14.fm

Figure 14-52 Top 3 OLAP report

Notice that if you expand Measure Calculations you can ask to see the Revenue
column in multiple ways. For example, you can 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.
Tip: If you want to see a report that shows your bottom Products by revenue, sort from
low to high and then rank and select your top three.

Chapter 14. Assignment #7: Implementing OLAP

453

8063ch14.fm

454

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ch15.fm

15

Chapter 15.

Assignment # 8: Building
Documents/Dashboards
This chapter will discuss techniques used to create documents that contain groups of reports
or charts, sometimes referred to as dashboards or scorecards. Such documents can serve as
a means of providing centralized reporting. These documents can be used to present
information to clients for monitoring daily business activity, viewing key metrics, spotting
trends or as a trigger to initiate actions for business improvement.
Prerequisites: Before starting this chapter, make sure the following steps have already
been completed:
 Chapter 7, Creating and editing metadata - Century Database on page 191
 Chapter 8, Assignment #1: Summary Reports on page 205 because we will use 1a Revenue Summary by Product Category and 1c - Revenue Summary with
Subtotals reports which are created in this chapter.

Copyright IBM Corp. 2012. All rights reserved.

455

8063ch15.fm

Draft Document for Review August 30, 2013 2:37 pm

15.1 Documents and Dashboards


In this section we will conceptually define dashboards and explore documents created with
DB2 Web Query, using the sample data provided with the product.

15.1.1 Prerequisites
The exercises to be performed in the following section utilize data from the QWQCENT library
which installs with the DB2 Web Query product. Before going further with this chapter, you
should create a folder under the Century Electronics folder and name it: Assignment 08 Building Documents and Dashboards. Place your work from this chapter into this folder.

15.1.2 What is a Dashboard?


A driver uses the instrumentation in a vehicle to monitor speed, fuel levels, engine
temperature or the general health of the vehicle. Increasingly, with modern GPS equipment, a
driver will also monitor progress towards the destination. In the same way, a dashboard
developed with DB2 Web Query may be used to monitor key metrics associated with the
performance and objectives of a business.
In the past, Query/400 and other information reporting tools were frequently used to prepare
end-of-the-month reports about business performance and goal achievement. Staying with
the car analogy, this could be likened to using the rear view mirror. Using such reports, we
know where we have been but perhaps not how we are moving forward toward the business
goals. Today businesses wish to look forward as well as backward. Dashboards and key
performance indicators (KPI) are a way to present periodic and/or real-time analysis of
business achievement. Furthermore, with the advent of tablet computers and smart phones,
many business leaders seek to place dashboards on these popular devices.

15.1.3 Developing KPIs


Every business is different but KPIs in general might take the following forms:
 Current status of a metric
 Trend analysis of a metric over time
 Geographic analysis to see performance by regions
 Comparison of a metric to the same metric in a prior period
 Forecasting of a metric into the future

15.1.4 Business leader requests


Executive Dan has heard from his colleagues at the country club that BI dashboards a top
priority for many of todays CIOs. Consequently he is eager to have a dashboard for use by
the Century Electronics executive staff and their sales teams. His vision is to create a sales
information dashboard to expose elements of profitability, delivery performance, and order
status.
In Figure 15-1 we show an example of a dashboard containing several measures of sales
performance for the Century product types. This dashboard is developed as a document in
456

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch15.fm

DB2 Web Query and shows various charts and reports giving several different views of
Product Type information.

Figure 15-1 Example Document containing charts and report

15.1.5 Creating a dashboard document with InfoAssist.


There are several ways within DB2 Web Query to group charts or reports together into a
document or dashboard. These ways are:
 Create a new document and within it, create one or more charts or reports.
 Create a chart then import it into a new document using Insert, and Existing chart
 Create charts or reports and then use the BI portal Pages feature to allow users to
combine various charts or reports on a page for themselves.
There is no single right approach. The approach you implement will depend upon choices
made in your organization combined with the abilities of your developers and users. We
recommend you choose the one that best fits your circumstances.
There may be some benefits and reuse of charts by creating the chart externally and
incorporating the completed chart into a document.Using this technique will enable users and
developers to more easily incorporate a chart in more than one document or page.

15.1.6 Viewing business data on popular devices


The proliferation of tablets and smart phones provides the opportunity for mobile users to
receive and utilize business information on the go. In Figure 15-2 on page 458, you can see
the same document shown above when used as a PDF document on a couple mobile
devices. Other chapters for this guide will discuss mobility options in more detail.

Chapter 15. Assignment # 8: Building Documents/Dashboards

457

8063ch15.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 15-2 A Web Query document dashboard PDF viewed on mobile devices

15.2 Creating a document, adding an internally defined chart


In this section, we start from a blank canvas of a new document and create a chart inside that
document. This document will form the basis for a dashboard containing several reports or
charts. In this first example, the chart is defined as a part of the document and when
complete, will not show as an object in the folder where the document resides.

15.2.1 Starting a new document


Follow the steps outlined here to create a new document and define a chart internally to that
document.
1. Create a new folder under Century Electronics folder named Assignment 08 - Building
Documents and Dashboards. To do this, right click in Century Electronics folder and
select New Folder. Click OK after you fill in the folder name field.
2. On the Web Query main menu, right click on the target folder and select New and then
Document as show in Figure 15-3 on page 458

Figure 15-3 Starting a new document

458

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch15.fm

3. InfoAssist will open in a new window and prompt you for the name of a data source within
the metadata created for the QWQCENT library. Locate the synonym named
CEN_ORDERS which well use to create a chart depicting the margin percentage for the
various product types. Select CEN_ORDERS and press OK as shown in Figure 15-4 on
page 459

Figure 15-4 Selecting data source

4. After selecting CEN_ORDERS, InfoAssist will present a blank canvas area on the main
window. Press Home and select HTML as the output type as shown in Figure 15-5.

Figure 15-5 Selecting output type

15.2.2 Adding a chart


1. Press Insert and select Chart to add a chart to the canvas as shown in Figure 15-6 on
page 460.

Chapter 15. Assignment # 8: Building Documents/Dashboards

459

8063ch15.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 15-6 Inserting a chart

15.2.3 Manipulating fields for the chart


1. Once the chart widget is on the canvas, you can begin to drag fields to the query area to
populate the X and Y axis. In our example, we need to manipulate the data slightly to get
the best presentation. We will create two additional fields from the input data. Press Data
on the menu to bring up the Detail and Summary icons as shown in Figure 15-7 on
page 460. Press Detail or Summary to create a new field as discussed below. Also, please
note that the topic of when to select detail versus summary has been covered in more
depth elsewhere in this Redbook.

Figure 15-7 Location of Detail and Summary under Data

2. Whenever you calculate a field, a computation box will appear. In this box, you can work
with the fields from your data source as well as a variety of built-in functions. These
functions enable you to transform data from one data type to another, convert character to
460

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch15.fm

numeric, perform date arithmetic, extract portions of dates or times, concatenate character
data fields and many, many other useful processes.
a. MarginPct will be calculated in this report as a Summary (COMPUTE) field to generate
a total margin percentage for the aggregate data for each Product Type. As shown in
Figure 15-8 use the equation: MarginPCT = (Revenue - CostofGoodsSold) /
CostofGoodsSold. Double click each data field to add it to the compute box and then
formulate the correct equation.Press OK when the formula is complete.When you
compute a field at the summary level it usually moves automatically to the query
measures area.

Figure 15-8 Calculating Margin from revenue and cost of goods sold

Note: Please be aware that computations done in the report are only viewed in the subject
report. For a computation to be viewed globally in all reports, the best practice is to enter
the calculation within the metadata. In this way, calculations are centralized, correctly
performed with mistakes minimized, and formulas do not need to be re-done in each
report.
b. Period will be calculated as a Detail (DEFINE) field for use on the x-axis in the format
YYYY-MM so that year and month are more readable and sortable. As shown in
Figure 15-9 on page 462 use the equation: Period = EDIT(Orderdate_Year) || - ||
EDIT(Orderdate_Month). For the Period, use the EDIT( ) function as shown to
convert the number fields for year and month to alpha fields with leading zeros. This is
similar to the DIGITS function in SQL. Concatenate the YYYY to MM by using the
double vertical bars || and insert the dash - character between the parts.

Chapter 15. Assignment # 8: Building Documents/Dashboards

461

8063ch15.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 15-9 Calculating Period from Order date fields

Note: For more documentation on the Web Query built-in functions, refer to either the help
on the Web Query login screen or the help in the Developer Workbench. Either source has
extensive online help, definitions and examples of function usage.
3. Adding the computed fields to the chart is a simple drag and drop. Highlight your chart and
notice the Query area has sections called Measure, X-axis, and Legend. Drag the fields to
the query area as defined below and when done, your query area should look like
Figure 15-10.
a. Drag Period over to X-axis and drop it there
b. Drag ProductType to Legend and drop it.
c. Verify that MarginPCT is already listed under measures in the query area.

Figure 15-10 Completed Query area

15.2.4 Making layout changes to improve the look of the chart


1. Your chart will reformat to depict the data you have added but we want to show a line chart
and your chart is probably still showing a barchart. To change from bar to line, press
Format and Line on the ribbon menu. Then press Run and see if your chart looks like that
in Figure 15-11 on page 463

462

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch15.fm

Figure 15-11 Selecting a Line chart

2. We are almost done but a couple of steps will make the resulting graph more pleasing to
view.
a. First click Layout Orientation and change from Portrait to Landscape as shown in
Figure 15-12.

Figure 15-12 Orientation options

b. Next click one of the dates (example 2012-01) on the date axis of the chart. A bold box
will appear around the dates. Right-click on a date and select Rotate 45 from the
menu.

Chapter 15. Assignment # 8: Building Documents/Dashboards

463

8063ch15.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 15-13 Rotating axis labels to 45 degrees

c. Finally, click on the blank area of the canvas, then press Insert Text Box on the
menu. A box will appear and your screen will look as shown in Figure 15-14.

Figure 15-14 Inserting descriptive text into canvas

Drag the text box away from your chart area so you can size it to be wider and shorter in
height than its default size. Type by double-clicking as indicated and type the words Average
Margin by Period. Change the text color to blue, using the menu above the text field. Using
the field handles, drag the text description to a position just above the chart.

464

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch15.fm

Figure 15-15 Completed line chart

d. Add one more Text Box to the canvas and type the words Product Sales Information
Dashboard. Again, using the text box menu, make the text bold, color blue and change
its font size to 18. Center this text on the canvas above your chart and the other
descriptive text.
e. Press Run to see your completed chart in action. Your result should look like
Figure 15-16

Figure 15-16 Run view of completed Document with internal line chart

Chapter 15. Assignment # 8: Building Documents/Dashboards

465

8063ch15.fm

Draft Document for Review August 30, 2013 2:37 pm

Congratulations on completing this document. As we move along in this chapter, you will see
how to drop additional charts or reports into the document, creating a dashboard of useful
information.
Save the document to your Century folder, naming it 8a - Document Dashboard.

15.3 Adding existing reports and charts to a document


When a number of charts and reports have already been developed, it is easy to add them to
an existing document to make a compound document, which we may refer to as a dashboard.
When the dashboard is opened, all the reports or charts contained within it are executed to
provide current data views. When adding existing objects to a document, please note that the
term Existing Report is used to mean any Web Query procedure (technical term is a FEX
file), whether it generates a chart or report when executed.
In this section, we will build on the previous example, using our document which already
contains one chart within it. We will add several more charts to create a dashboard. Use the
following steps to add an existing chart inside your document.

15.3.1 Opening the existing document


Locate your document from the previous section and open it for editing by right-clicking the
document and selecting Edit from the menu as shown in Figure 15-17.

Figure 15-17 Opening an existing document

15.3.2 Inserting an existing report


When you initially open the document, you will see the chart you previously created and the
data source information related to that chart. You can see this in Figure 15-18.

466

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch15.fm

Figure 15-18 Document with initial chart

The first chart may be highlighted with handles showing. If so, click the canvas outside of the
chart area to turn off these handles as shown in Figure 15-19 on page 468.

Chapter 15. Assignment # 8: Building Documents/Dashboards

467

8063ch15.fm

Draft Document for Review August 30, 2013 2:37 pm

Click here

Figure 15-19 Click outside chart area of canvas

Do the following to add a previously created chart to your document.


1. Click somewhere in the blank area, outside any charts
2. Press Insert and then press Existing Report. The existing report option will prompt you
to select an existing procedure. Open folder Assignment 04 - Charting and select the
gauge chart named 4d - Gauge Chart: OTD overall as shown in the Figure 15-20 and
press Open to add the chart and make the data source available.

468

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch15.fm

Figure 15-20 Selecting existing gauge chart into the document

3. The following Figure 15-21 on page 470 shows the new chart widget added to the screen.
Drag the gauge widget away from the initial chart and place it somewhere in the white
space of the canvas. Right-click on the gauge, selecting Size and Position to adjust the
size to 2 inches by 2 inches, then press OK.

Chapter 15. Assignment # 8: Building Documents/Dashboards

469

8063ch15.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 15-21 Adjusting size of the gauge chart

4. The chart is ready to Run but we also need to insert a text box as a label above the new
chart. Press Insert Text Box and move the resulting box above the gauge chart.
Change the label to be blue and type the text On time Delivery overall in the box. Size
the box as appropriate so that it is above but not overlapping the chart. Align the charts
and their titles by selecting each object and moving it to the desired position. Press Run to
see your work execute and it should appear as in Figure 15-22 on page 470.

Figure 15-22 Completed document with Gauge added

470

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch15.fm

5. Save your document to your folder by pressing the save icon as shown in Figure 15-23.

Figure 15-23 Saving your document

Tip: Whenever you have multiple objects on the canvas, it is natural to wish to align them in
some way. Using the Layout and Align menu options, you can select multiple objects with
Shift-Click and align them to the top, right, left, or bottom to achieve the desired look and
feel in your document.
Lets review what you have accomplished. You should have a document with two charts
inside, aligned in the top row, with titles above each and an overall title at the top. The Margin
chart is defined internally and the On-Time Delivery chart is defined externally, then simply
added as an existing report. In the following section we will add more charts to this document
dashboard.

15.3.3 Inserting more charts or reports into an existing document


In this section we will repeat the steps used in the prior section to add three more charts and
a report to the canvas. Open your document again and locate the three objects highlighted in
the following Figure 15-24.
Remember, the steps are:






Press Insert
Press Existing Report
Drag the inserted chart to the desired location
Set the size of the chart using either its handles or with the layout menu size fields
Add a text box to describe your chart, color it blue and set the font size and align the text
adjacent to your chart. Use the same font for all descriptive text.

Figure 15-24 Existing Reports to be added to the document

One by one, using Insert and Existing Report, select each procedure to add them to your
canvas.The resulting canvas should look something like that shown in Figure 15-25 on
page 472. Initially, all charts overlay the upper left one. We need to spread them out but we
dont really have enough room to fit all these charts on the page, do we? The solution is to
either make the charts smaller, or make the canvas larger. By changing from Letter to Legal,
the charts can be spread across the document more evenly.

Chapter 15. Assignment # 8: Building Documents/Dashboards

471

8063ch15.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 15-25 Reports added to screen - work in progress

On the menu, press Layout Size and switch Letter to Legal giving additional space on the
right of the canvas. Drag your charts into position and add the text to describe each. With the
object handles selected by pressing and holding keyboard Shift while clicking each object,
your result should look like the following example in Figure 15-26. You can better see whether
charts will overlap by showing the handles of each. Arrange them as best you can to avoid
overlap and save your work at this time.

472

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch15.fm

Figure 15-26 Nearly completed document with added charts

By adding a final report, your dashboard will be completed and should appear similar to the
picture earlier in this chapter. In your open document, press Insert Report. This will
generate a box on the canvas requesting you to drag and drop fields to the canvas as seen
in Figure 15-27. In the Data panel on the left of your screen, locate fields under the
CEN_ORDERS data area, selecting Product Type, Revenue and Returns. Hold the CTRL key
while selecting these three fields. Once they are selected, drag them to the canvas. Dropping
them on the box there should capture all three fields for your report.

Chapter 15. Assignment # 8: Building Documents/Dashboards

473

8063ch15.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 15-27 Building a new report inside the document

Also drag the fields ORDERDATE_YEAR from the Data area to the Across section of the
Query area. The three fields ProductType, Revenue and Returns will populate the box in the
order they were selected and Orderdate will be on the top as seen in Figure 15-28.

Figure 15-28 Manipulating the Query area to control report output

Now do the following few steps to complete your report:

474

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch15.fm

1. Drag your report box to the lower left of the canvas so it does not overlap any of the other
objects. Leave space for a title above as you did before.
2. Arrange the report so that you leave space for it to become wider when executed with all
the data existing in the database.
3. Using the alignment steps discussed earlier, align the two items in the bottom row.
4. Insert a blue title above your Revenue report with the words Revenue and Returns by
Product type.
5. Optionally, you can choose to add a company logo to the document. Press Insert
Image to place a logo on the canvas. Images for logos must first be uploaded to the
reporting server before being used in the designer. To do this, simply copy or move your
image to the same application folder which contains your metadata (synonyms).
6. Press Run to view your report which should resemble the Figure 15-29.
7. Save your work again.

Figure 15-29 Completed document - Dashboard

Congratulations! You have created a dashboard for Product Sales Information. You should
publish this from the DB2 Web Query BI Portal so that other users can view it.

Chapter 15. Assignment # 8: Building Documents/Dashboards

475

8063ch15.fm

476

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

16

Chapter 16.

Assignment #9:
Exploring/comparing other
dashboard options
In other chapters we introduced the concepts of documents and how they can be formatted in
ways to create grouping of business information or dashboards. DB2 Web Query has
additional options to create dashboards and documents of a more complex nature. In this
chapter we provide examples of a few other techniques for presenting business data.

Copyright IBM Corp. 2012. All rights reserved.

477

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

16.1 Additional features of Web Query for documents


There are several approaches available in DB2 Web Query to create interactive documents
for use in dashboards. Depending upon your requirements, for example, you might wish to
allow the user to prompt for a key value, such as country or region, to enable selection of
metrics for one geography at the time. Or, you might want to give the user even more control
over what metrics they see, through use of several selection fields, date ranges, checkboxes
and other forms controls. Executive Dan liked the dashboard you created in the previous
assignment, but he was looking for something more in terms of more features and flexiblity
when selecting the data to query, providing more features that are available to run time users,
and . Century Electronics also has a number of analysts that rely heavily on Excel
spreadsheets. Executive Dan would like for you to determine if this tool could be integrated
with DB2 Web Query to deliver dashboards for that group of users.
In this chapter we will explore several examples of such interactions.
 A coordinated document - allows run-time selection of one element.
 A document using a combination box form control (drop down list) to control data selection
 The BI portal pages - user managed selection of reports, charts or documents via Pages
within the BI portal of Web Query
 HTML Launch pages - The HTML composer feature of DB2 Web Query Developer
Workbench is a powerful development environment used to create and customize
dashboards.
 The spreadsheet client, which enables DB2 Web Query content integration into an existing
Microsoft Excel spreadsheet.

16.1.1 Prerequisites
Before going further with this chapter, you should create a folder under the Century
Electronics folder and name it: Assignment 09 - Exploring and comparing other
Dashboard options. Place your work from this chapter into this folder.

16.2 What is a coordinated document?


A coordinated document is designed from a single grouping of metadata using one synonym
as a single data source. The requirement to have all reports and charts work off the same
data exists because the coordination feature seeks to make the data views act in unison when
a change is made to the coordinated field. Due to the coordinated feature, all reports are
internal to the document, meaning they are defined on the canvas, in the document.
Externally defined reports inserted as existing reports, would not participate in the
coordinated feature.
Suppose you need to create a dashboard to show sales information by country. The country
field would be the coordinating field and each chart or report in the document will specify
country under the Coordinated section of the Query area. At run time, the coordinated field
will appear across the top of the window as shown in Figure 16-1. As the user changes the
Country value, the reports and charts change simultaneously, showing the applicable country
information in each. This is a powerful technique depicted in the Web Query document
named 9a - Coordinated Document - Country.

478

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-1 Coordinated chart

The important steps to creating the above coordinated chart are as follows:
1. Open a new document.
2. Select the CEN_ORDERS data source. It will be shared by all charts and reports included
in this document.
3. Insert a report, line chart and two pie charts into your document, placing them as shown in
the example above. Click on the report and drag the appropriate dimension fields to the
query area and the Country field to the coordinated area.
4. For the remaining charts, drag the dimensions and measures to the respective parts of the
Query area and verify that Country is under coordinated for each chart.
5. Add any descriptive text and company logo information that is appropriate.
6. Click Format tab and select Active Report or Active Flash or Active PDF.
7. Save your document as 9a - Coordinated Document - Country.
All reports and charts will share the common dimensions and measures from CEN_ORDERS
as seen in Figure 16-2 and Figure 16-3 on page 480.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

479

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-2 Available Dimensions

Figure 16-3 Available Measures

The query area for the Revenue by Product Type report looks like Figure 16-4. The
important part of this figure is the presence of Country under Coordinated. This drives
Country to be used as a key selection field at the top of the screen and also causes the other
charts and reports to change when Country changes

480

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-4 Revenue by Product Type - report

Use the Figure 16-5 to establish the query area for the Revenue line chart.

Figure 16-5 Revenue History - line chart

Use the Figure 16-6 on page 481 to establish the query area for the Profit pie chart.

Figure 16-6 Profit Breakdown by Product Type - Pie chart

Finally, use the Figure 16-7 to establish the query area for the Warranty pie chart.

Figure 16-7 Warranty Analysis - Pie Chart

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

481

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Even though the Reports, Pie Charts and Line/Bar charts represent data differently, they will
all specify Country under coordinated and therefore react at the same time when the Country
value is changed.
Once you have completed one Coordinated document and saved it, you may easily extend
the concept to other measures. As an example of this, open your document 9a - Coordinated
Document - Country for editing, change the coordinating field from Country to Store Name.
Verify that Store Name has replaced Country in the Query area settings of each chart. Using
the menus Save As feature, give this document the new name 9b - Coordinated Document
- Store Name. Now you can run these documents to see sales information by either Country
or Store Name.

16.3 Creating documents with Form Control fields.


InfoAssist also has the ability to create what are called Active documents, where fields on the
canvas are linked to the charts and reports in the document. The term Active refers to the
output type. The active form controls will only appear in your document if you select Active
Report, Active PDF, or Active Flash as the output type.Or, stated another way, when using
form controls, the output type is limited to one of the Active report types.
In prior examples, we have used HTML output. When you add fields to the document, you will
see that the output type is constrained to one of the Active types as shown in Figure 16-8.

Figure 16-8 Active document output types and others no longer available

The form controls can control one or more reports and charts. The example in Figure 16-9 on
page 483 shows such a chart which mimics the Country chart previously created but does not
use the Coordinated feature. Instead the Country is selected from a drop down list and the
charts are linked with the changed value.

482

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-9 Selection example by Country

The reports and graphs are created inside the document and an active control combination
box from the InfoAssist menu is added to the document and associated with the charts and
reports. The selection of DB2 Web Query form controls available is shown in Figure 16-10.

Figure 16-10 Available controls to place on the canvas

Whenever the value of the drop-down list value for Country is changed, the reports linked to it
are reformatted to depict the new value. There is an important distinction between a
coordinated document and a document with form controls. A document can contain both
charts that are controlled, and charts that are NOT controlled. There may be some creative
reasons why you wish to do this. Perhaps a drop down list on the left side of your dashboard
controls charts there, while a drop down list on the right controls a different set of charts.
We will leave it to your imagination to create complex dashboards combining charts, reports
and form controls after reviewing the steps to create such a document.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

483

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

 Open the previously created document named 9b - Coordinated Document - Store


Name for editing and immediately save as to the new name 9c - Country Document
with Form Control Field.
 Click on the Revenue report.
 In the Query area, delete the Country field from under coordinated.
 Drag the country dimension from under CEN_ORDERS to the Revenue report and insert
it as the first, left-most field.
 Click the Insert menu and press Drop Down to add a combination box control to the
canvas. Move this to the top left of the screen. Your screen should now look like the
Figure 16-11. Note the combination box is visible, the report has country first and the
query area has country under the By section.

Figure 16-11 Formatted document with charts and form control inserted

 Select the combination box, right-click it and select Properties from the menu. You will see
a dialog enabling you to configure the combo box to control reports in your document.
Figure 16-12 shows the initial settings for this dialog.
 Turn off the check box marked Include all which removes the option of user seeing ALL in
the drop down list.

484

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-12 Combo box with first report selected as Table_1 and field as Country

 To configure the combination box to control your data, select the name combobox_1 on
the left under Prompts, select table_1 under Reports, and select Country under Fields.
Hold shift and click each of the names under the Candidates column. When you have
selected them all, use the movement arrow icon to move your reports and charts from left
to right, changing them from Candidates to Targets. This accomplishes the linkage to
make these four reporting objects react to the changes in the combination box, as you
change from one country to another. Figure 16-13 on page 485 shows the resulting
settings for this dialog.
 After using the selection arrows to move all charts from the Candidates area to the Targets
area, press OK to save these settings.

Figure 16-13 Combination box configured to control the table and charts

 Settings in the query area for each element are as follows in Figure 16-14. Pie charts may
need to change from the initial settings because pie charts have category and slices

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

485

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

whereas bar and line charts have the x/y axis. Verify the pie charts have Country and
Product Type under Category.

Figure 16-14 Left t to right - Revenue report, Revenue line chart, Profit pie chart, Warranty pie chart

Press Run to view your work. Your screen should look like the screen capture in Figure 16-15
on page 486, save your work.

Figure 16-15 Completed document with Country form control

Note: At the time of publishing, each time you first run this chart, the display defaults to
ALL, even though a country name shows in the drop down list. You must select a country
and the change action will show only the data for that country for this and subsequent
country selections.
486

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

What if we added another controlling field, such as Store Name? Some rearranging of the
screen, due to space constraints, would be required, however, you can see the point. We can
build reports of increasing complexity and offer users more self-service choices by adding
form controls for selection to the screen.

Figure 16-16 Example with two form controls - Country and Store name

The introduction of additional form controls that work together introduces the need for
cascading logic. Web Query handles this on the same screen where you configured
combobox_1 to control the various charts. At the top of the screen, when you have added
more than one form control to the canvas, you will see that a button for Cascades has
become available. Pressing this yields the screen shown in Figure 16-17, where you can
order the logic of related form controls. In this case, cascade1 is going to control both
combobox_1 and combobox_2 in that order. Pressing Prompt Sources & Targets returns to
the screen where you linked the controls to the graphical objects.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

487

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-17 Illustrating Cascades button availability for more than one form control

Tip: Please note that Drop Downs, Lists, Radio button groups, and Check box groups all
work similarly and require the same configuration to link them to charts or reports. When
used in combination, you will have to decide whether the cascading feature is required or
whether they operate independently of each other.

16.4 Self-service Dashboards using the BI Portal.


The Web Query home page acts as both a main menu and a portal. It is designed to allow
business analysts and developers to create BI resources and publish them for users to
consume. The portal provides a couple different ways for users to access these pre-created
resources. In this section, we will review these approaches for selecting previously created
reports. This section will not delve into security matters but remember that users will see only
those items for which they have been granted access and they also need appropriate
database security permissions in order to view data in Web Query reports and charts.
Access is obtained by logging in and selecting (or running) objects that have been published.
We will review selecting published reports, adding to favorites or mobile favorites groupings,
and building a personal portal of business information.

16.4.1 Favorites and Mobile Favorites.


When a user logs on to Web Query, a screen similar to that in Figure 16-18 is the first one
displayed. A client will use the DB2 Web Query area to develop BI content, creating folders
that contain published items, developer folders or maybe company level folders. Once content
is developed and published, users may then add this content to their Favorites and/or Mobile
Favorites areas for frequent access. The Recent Items are will also contain a list of those
reports previously used.

488

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-18 Web Query areas

Any report can be added to the Favorites by right-clicking it and selecting Add to Favorites (or
Add to Mobile Favorites) as shown in the menu in Figure 16-19 on page 489.

Figure 16-19 Adding a query to the Favorites areas

When the user expands any of these Favorite areas, they see items that they previously
saved there, as shown in Figure 16-20. A double-click action on the item will run the subject
query.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

489

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-20 Executing favorite chart

Favorites and Mobile Favorites work similarly by storing links to any reports that the user likes
and has decided to save for future viewing. This is a very handy feature which will be
demonstrated in more depth in the Going Mobile chapter.

16.4.2 Creating a Personal BI Portal


Another important feature of Web Query is the ability to create a user-named tab page
adjacent to the login page. This enables a user to select multiple reports and
combine/arrange them on a single screen. We will run through the steps to create a
dashboard on the fly using this technique. The steps are as follows:
1. On the web Query portal page, select the icon to the right of the Reporting tab as shown in
Figure 16-21 below. This will cause a new tab to be created named Page N, where N is
the next available page number. The page can be renamed as desired with a right-click
and Rename action.

490

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-21 Initiating a new tab page on the portal

2. Once the new page is added, you should select a page layout style. There are several
choices for page layout but if you think of the page as a piece of paper divided into
quadrants, you can drop a chart in each of the squares. The Page Layout option allows
you to specify how many squares you want on your page. What you select will depend
mostly on the size of your charts and reports. Right click on the new tab, select Page
Layout from the menu and from the resulting pop-up menu, select Four Columns as
shown in Figure 16-22 on page 491.

Figure 16-22 Selecting page layout

3. When you create the new page and a page layout, the Web Query Resources window will
be added to the right of your screen. From this panel, you can drag and drop your favorite
reports to the new page. Each time you do so, the resulting report box will snap into place
as shown in Figure 16-23. Adding a second third and fourth is just as easy.
4. When viewing your portal page, if the Resources window is not visible, you may select it by
clicking the Resources link on the upper right of your Web Query window.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

491

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-23 Adding first query to your portal page

5. Select three of your favorite reports and try this now. You will end up with a customized
portal page containing your charts displayed together as shown in Figure 16-24.
Depending upon your screen resolution, you might fit a number of items on the page
easily. A couple of points about the arrangement of these charts:

492

Web Query will remember this layout and generate this page each time you return
to your portal page. When you exit web query from your portal page, it will reopen to
the same place next time you log in.

You can minimize, maximize or hide each of these charts independently as needed
by right-clicking the icon that appears in the upper right of each chart as you roll you
mouse pointer over the header frame.

Rearrange the charts in your window by dragging the header bar to a new location
on the canvas of the window.

Use the portal tab menu to restore content that you previously hid via the Hide
menu option.

You can create more than one page to handle different companies, topics or
categories. Rename each tab by using the tab menu and selecting the Rename
action.

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-24 Completed portal with four charts

 To remove a chart from view, click the header menu and select Delete or Hide. This does
NOT delete the chart from Web Query, just removes it from your portal page as shown in
Figure 16-25.

Figure 16-25 The report header menu for managing your portal reports

As you can see, the BI portal pages enable an excellent self-service approach for making an
inventory of charts and reports available to consumers. The portal may allow a practice to
have your business analysts create reports, publish them and then notify the target audience
of their existence. Each user has the flexibility to select those reports that interest them, to
which they are authorized and then they can arrange them in a convenient format for daily
viewing.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

493

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Tip: While selecting a page layout containing One, Two, Three or Four columns causes the
snap into place behavior in the Portal, the Single Area selection enables you to manually
size and shape each chart and place them wherever you choose on the canvas.
In Figure 16-26 below, you can see the result of the Single area selection with various charts
arranged manually.

Figure 16-26 Choosing Single Area to allow manual chart arrangement in the portal

16.5 DB2 Web Query Developer Workbench


Developer Workbench provides an integrated development environment (IDE) for building
and maintaining a DB2 Web Query reporting environment. In addition to providing an HTML
composer editor to develop sophisticated reports, the Developer Workbench includes
additional tools to work with metadata. The Synonym Editor allows you to change the way in
which a field is displayed to the users. You can add descriptions, control data presentation
such as 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 users. You can predefine joins for the users or create business views that simplify
the structure and number of columns that the user sees. If you plan on using the online
analytical processing (OLAP) feature, you must define your hierarchies or dimensions with
Developer Workbench.
Using the metadata layer, Developer Workbench provides the ability to perform impact
analysis at both a file level and a field level. If you must make changes to a field, you can see
which reports and graphs use that field and the business views of which it is part.

494

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

16.5.1 Why would you use developer workbench?


Possible reasons include:
1. Editing metadata and profiling your data
2. Creating documents with customized style sheets, logos and formatting, perhaps to
conform to corporate standards for web-portal look and feel.
3. Going beyond what InfoAssist can presently handle in compound documents or
coordinated documents.
4. Using advanced features like incorporating Goggle Maps APIs in your document.
5. Combining data from many data sources in some unique way.
6. Importing SQL
Developer Workbench provides the capability to profile your data. Profiling allows you to see
patterns in the text characters. For example, profiling telephone numbers in the Stores table
might show us that five records have a format of nine numeric characters instead of 10. We
might want to know if these five records are a quality problem. Data profiling also shows the
minimum and maximum values in a column and identifies the outliers.
The SQL Wizard allows you to import SQL into Information Assistant.
One of the major tools within Developer Workbench is the HTML Composer component.
HTML Composer is specifically designed to create HTML pages that can contain compound
reports or dashboards. You can find a complete tutorial for this component later in this
chapter.
Before you begin using Developer Workbench, you must first perform several configuation
steps. These step are documented in Appendix D, Configuring Developer Workbench on
page 843.

16.6 Dashboard using HTML composer


HTML Composer is a component of Developer Workbench, and is specifically designed, as
the name suggests, to design HTML pages. HTML Composer does not create reports or
graphs, but rather references existing ones. You can create compound reports with
background style sheets and add company logos and other standard HTML components. The
design of the HTML page can be set to match your companys intranet standards.
Both HTML Composer and Info Assist can create compound reports. Info Assist is architected
for PDF and Active report output. It can also create other types of output such as HTML
pages. HTML Composer is architected for HTML pages. It can only create HTML pages. It
cannot create a PDF report. The products have different user interfaces. You have already
tried Info Assist. In this tutorial, you try HTML Composer. Then you can choose the option that
fits your companys needs the best.
In this tutorial, we design an HTML page that is a compound report with a single input
parameter. This style of report can be used as the basis for key performance indicator (KPI)
dashboards where the user might request the KPIs for a specific country, product type, and so
on. This type of report is often designed by IT and deployed to senior management and
executives within a company.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

495

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

16.6.1 Comparison between InfoAssist and HTML Composer


Before getting into the details of using the HTML composer, it is relevant to discuss why this
technology would be used instead of, or in conjunction with, InfoAssist. InfoAssist is designed
for developers, business analysts and users with proper skill set. HTML composer is perhaps
more of an IDE that suits the IT professional or advanced analyst. As we compare the
capabilities of the two development tools, each has strengths:

HTML Composer Advantages:


 Provides an interface to embed Java Script for field validation/transformation (data editing,
convert input to upper case) before hitting the server (good for performance)
 Advanced parameter chaining controls
 Nice features such as populate drop down with one field but actually pass another field to
the FEX procedure (select store name but pass store code to FEX for filtering)
 Faster population of dynamic prompt controls (drop down lists)
 Flexible user interface with more developer control of the presentation
 Can provide the user a nicer interface for entering parameters (date pickers). Analogous to
building CL commands to front end RPG/ CL programs (rather than have users call
programs and specify parameters somewhat blindly)
 Can use meta tags/java script to auto refresh at specified interval
 All in all, a more advanced tool with more controls, but again, the output generated is
HTML only

InfoAssist Advantages:
 Generates FEX procedures which can be invoked from the SDK/Application extension.
Only way to call a compound doc/dashboard from these interfaces. SDK cannot invoke
HTML launch page generated by HTML Composer.
 Easy to switch output types, specifying formats like Active Flash, PDF or Excel.
 Includes powerful Slicer capability without any programming by the report designer
 Probably a higher level of ease of use in the InfoAssist component
 No other software is required, no code required - a case of complexity vs. simplicity

16.6.2 Compound parameterized report (HTML1_KPI)


In the first exercise, using two graphs and one report, we add a common parameter and bring
them together on one HTML page for the user. Figure 16-27 shows the final output page.
Before going further with this chapter, you should verify that a folder under the Century
Electronics folder exists named: Assignment 09 - Exploring and comparing other
Dashboard options. Place your work from this chapter into this folder.

496

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-27 Compound report

16.6.3 Preparing the charts for the HTML composer


You can launch Info Assistant from either Developer Workbench or the DB2 Web Query home
page.In this tutorial, we do all our work from Developer Workbench.
In , Before you begin using Developer Workbench, you must first perform several
configuation steps. These step are documented in Appendix D, Configuring Developer
Workbench on page 843. on page 495 we introduce the two main functional areas of
Developer Workbench. The first leg of the explorer tree expands through Data Servers to
allow you to work with your metadata. The second branch expands down through the site
folder tree where your DB2 Web Query production and development resources are located.
Both the web-based DB2 Web Query home page and the Developer Workbench allow you to
work with the folders in your domains.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

497

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

In this section you will use the skills you learned from other chapters to create three reports.
All reports on our KPI page need to have product type as an input parameter, in order to have
the proper parameter linkage. We will create each of the reports to accept this parameter and
save them under the following titles:
1. 9d - Revenue Trend over time
2. 9e - Revenue by Product Type
3. 9f - Revenue report
Generic term report: 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 is a compound report.
1. Open Developer Workbench. You see WebFOCUS Environments under Developer Studio
Desktop. You may or may not see Windows Desktop.
2. Expand WebFOCUS Environments your environment Repository
Century_Electronics
Assignment_09_-_Exploring_and_comparing_other_Dashboard_options.
3. Right click on your Century Electronics folder and press New Procedure using
InfoAssist to launch the development tool.

Figure 16-28 Workbench tree

4. When InfoAssist opens, select the Build a Chart option. Use the following steps to format
the chart:
a. Select data source CEN_ORDERS, and create a line chart as shown in Figure 16-29.

498

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

b. Change the chart heading title from blank to Revenue Trend in blue with Tahoma 10
font.
c. Create field Period that concatenates the OrderDate_year and OrderDate_month with
a dash between, resulting in a character type field in format YYYY-MM. This formula
demonstrates use of the EDIT(numeric-field) function and double vertical bars ( || ) for
concatenation.
d. Drag the Period field to the X-axis, Revenue to Measures and Product Type to the
Legend positions in the Query area. Rotate the x-axis labels to 45 degrees for
readability
e. Create a filter on Product Type adding a dynamic parameter so that Product Type can
be passed into the report.
f. Save the report as 9d - Revenue Trend over time under your Chapter folder.

Figure 16-29 Revenue Trend specifications

5. Repeat the chart creation process for the next chart using the following information:
a. Select data source CEN_ORDERS, and create a bar chart as shown in Figure 16-30
on page 500.
b. Change chart heading title from blank to Revenue by Type - Country Comparison in
blue with Tahoma 10 font
c. Drag the Revenue to Measures, Country to X-axis, and Product Type to the Legend
positions in the Query area.
d. Rotate the x-axis labels to 45 degrees for readability.
e. Create a filter on Product Type adding a dynamic parameter so that Product Type can
be passed into the report.
f. Save the report as 9e - Revenue by Product Type under your Chapter folder.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

499

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-30 Revenue by Type - Country Comparison

6. Repeat the creation process once more for the Report and use the following information:
a. Select data source CEN_ORDERS, and create a report as shown in Figure 16-31 on
page 501.
b. Change chart heading title from blank to Gross Profit by Type in blue with Tahoma 10
font
c. Drag Revenue, CostofGoodsSold, and GrossProfit to Measures.
d. Drag Product Type and Product Category to By.
e. Right-click GrossProfit and select Sort Sort Descending. Note that this adds a
column for GrossProfit under By but places it at the top. Drag this column between
ProductType and ProductCategory.
f. Right-click on GrossProfit under By and enable Ranking as shown in Figure 16-31 on
page 501 below by selecting Sort Rank On. Also, if you find that you have two
GrossProfit columns, right-click the one next to Rank and hide it using Visibility Hide.
g. Right click again on GrossProfit and enable traffic-lighting by selecting More Traffic
Light Conditions and set the background to green when GrossProfit is greater than 25
million dollars.
h. Create a filter on Product Type adding a dynamic parameter so that Product Type can
be passed into the report.
i. Save the report as 9f - Revenue report under your Chapter folder.

500

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-31 Gross Profit by Type

7. Now that your three reports are created, you will be able to include them in a new
compound document created with Developer Workbench

16.6.4 Adding controls to the HTML Composer canvas


In this section we explain how to design the layout for an HTML document. When you open
the workbench, you will get a blank canvas on which to place form controls and reports.
Follow the steps below to begin this process and utilize the charts you created above in a
compound document.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

501

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-32 Initial Workbench pane

1. Open Developer Workbench.


2. Expand WebFOCUS Environments your environment Repository
Century_Electronics
Assignment_09_-_Exploring_and_comparing_other_Dashboard_options.
3. Right Click Assignment_09_-_Exploring_and_comparing_other_Dashboard_options
and select New HTML File (Figure 16-33 on page 502).

Figure 16-33 Initiating a new HTML file

4. Call your new HTML file by the name 9g_HTML_KPI_Compound and press Open. You
will see a a lot of icons on the tool bar and a blank canvas where you can design your
HTML page.

502

IBM i DB2 Web Query for i Implementation Guide

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-34 Workbench blank canvas

5. Using the following steps, create all the objects on the canvas page by using the row of
icons containing graphs, reports, images, field boxes:

Figure 16-35 Form Control icons in Developer Workbench

a. Drag a Group box to the canvas (1-in Figure 16-35) and place it in the upper right of the
canvas. Make it wide enough to accommodate a drop down list of Product Types and a
button next to this list. The advantage of the Group box is that is has a text field
incorporated to describe the purpose. You would change the text field to Product Types
and change the Font to Tahoma and blue.
b. Drag a drop down list (2) into the group box area.When you do this, the properties of
the box will appear next to the canvas. Click the Dynamic Radio button, click the radio
button for Embedded Procedure, and then select the source of the procedure by
clicking the button and picking CEN_ORDERS.mas from the list of procedures as
shown in Figure 16-36 on page 504. Select the ProductType fields for Value field and
Display field entries. Note that this is how you could specify a code for the Value and a
description of that code for the Display field, if needed. Finally, check the All option and
change the prompt text to All Products. This prepares your combobox to get available
values from the CEN_ORDERS ProductType field at run-time.
Chapter 16. Assignment #9: Exploring/comparing other dashboard options

503

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-36 Configured choices to prompt All Products and Product Types in Combobox

c. Drag a push button (3) into the group box area. Select the box text with your mouse
and change it from Button to Run.
d. Twice, drag a chart (4) into any empty space on the canvas.
e. Drag a report (5) into an empty space on the canvas.Your in-progress canvas should
appear as in Figure 16-37 on page 505.

504

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-37 Canvas after dragging objects to add procedures

f. In turn, right-click each of the three report areas you have dragged to your canvas.
Select Properties and give each box a name using Linechart, Barchart and
ProfitReport respectively. The properties dialog looks like Figure 16-38. While in here,
change the size of the two graphs to 250px high by 400px wide. Leave the size of the
report as it is from when you placed it on the canvas.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

505

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-38 Report container properties

16.6.5 Referencing external Procedures in the HTML composer


1. Now that we have form controls on the canvas, we need to configure them to work
together and point to previously created chart and report procedures. The following steps
will accomplish these tasks.
a. Right-click on each box and select the default menu option Reference External
Procedure, which will prompt you for which procedure is to be run. In this action, you
associate the container with the Web Query procedure to reference (*.FEX file) as
shown in Figure 16-39.

Figure 16-39 Selecting a FEX file to execute

b. When you select a procedure, you will be prompted, at least for the first one, to
associate it with the a control. The default (Figure 16-40) is to create NEW controls.
You do not wish to do this, as you have manually created the ComboBox control in
previous steps.
506

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-40 Default prompt for linking procedure to controls

c. Un-check the checkboxes related to creating a new control, change the selection value
from New single form to Do not create a form and pick your combobox
(Figure 16-41) as the preferred control.

Figure 16-41 Changed settings to link chart to control

d. As you connect each report box to a procedure that is going to populate it, you will see
data shown inside each box. Each box may be too small or too large, depending on the
size when you initially dragged it to the canvas. Not to worry, it is easy to resize them by
grabbing the handles and dragging the corner in or out, or by utilizing the properties

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

507

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

page. Also, the action of connecting the first box on your canvas to a procedure, will
cause a form with a button within it, to appear above the chart (Figure 16-42 on
page 508). This is because, by default, a form with a reset button is created. You can
delete this form, as neither item will be referenced on this page because we already
have our drop down and button created. In some cases, however, the reset button
might be useful.

Figure 16-42 Deleting the extraneous form control

e. The final step to tie this all together, involves linking the Run button to your three
reporting areas. You can configure the Run button by right-clicking and selecting
Create Hyperlink. On the resulting screen (figure), next to Reports to Execute, press
the new button three times. Then configure Action, Source, Target type and
Target/Template Name for each of your reports.Press OK to save this information. You
can get back to this information by right-clicking the Run button and selecting Hyperlink
Properties.

508

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-43 Configuring Run button to actuate reports

f. When complete your settings will activate all three reports by a press of the Run
button.Your completed hyperlink screen will look like Figure .

Figure 16-44 Hyperlink settings for button to report activation

Press the Run button on the Workbench. This causes the page you have developed to
execute in a new window. When your page opens, it will be blank until you press the Run
button you created on the canvas.
Press the Run button and you should see a load message (Figure 16-45) on your screen in
each of the boxes before seeing the actual data appear. Note that if you did not get the
linkage correct between the Run button and the various procedures, you might not get this
load message for one of your reports and might not see any data displayed, thus leaving one
of your reports or charts missing. Correct this by verifying your procedure name, and your
hyperlink values associated with your Run button.

Figure 16-45 Please Wait while Web Query runs the procedure and loads data

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

509

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Improving the layout of the HTML document


Once we have a functional page, the next step is to add a title, arrange the reports attractively,
include any logo that is desired and generally clean-up the page. For example, to make this
page look a little cleaner, we can remove the frames around each of the reports.
1. Drag an image control from the tool bar to the top left of the canvas. Locate a *.GIF logo
image that you uploaded to the century folder of Web Query earlier and select it. Size this
as appropriate.
2. Drag a text field to the top center of the page and type the text Product Type Indicators in
the resulting box. Highlight the words and set the font, size and color as show below.

Figure 16-46 Setting title text appearance

3. Highlight each of the three reports.


4. From the Properties pane on the right, change the Frame border setting to No.
5. 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 pane on the
right, set Auto Execute to True.

Executing the Run button


6. Save your report and then run it by clicking the Run icon (circled in Figure 16-47).

510

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-47 Run icon

Tip: You can return to the DB2 Web Query home page and run this dashboard. The
easiest method is for a developer to stay within Developer Workbench and test from there.
Do not forget that the page should be designed small enough to be viewed within the
context of the DB2 Web Query home page.
Your dashboard or KPI should look like the example in Figure 16-48.

Figure 16-48 Completed compound report in designer

When run, your report should appear like the example in Figure 16-49 on page 512 and
should correctly limit data shown to the selected ProductType from the drop down list.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

511

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-49 HTML page rendered in a new browser window

When you have finished your document, save it and make sure to go back to the folder in
Century Electronics to publish your example document so those requesting it can review the
results. By default, documents are Private to the creator until published, when they become
public.

16.7 DB2 Web Query Spreadsheet client


Even with the growing popularity and evolvement of Business Intelligence products such as
DB2 Web Query, Microsoft Excel continues to be one of the most common means used to
generate reports and analyze data. Excel users continue to stand firm when it comes to
replacing Excel with a BI reporting tool, despite the challenges involved with accessing data
within the Excel environment. DB2 Web Query has responded to these demands and
challenges with the Spreadsheet Client, a DB2 Web Query Add-in for Excel. Now users can
access and analyze all of their enterprise data without leaving their preferred environment.
The Spreadsheet Client allows Excel (2002 or higher) users to run DB2 Web Query reports
from within Excel and populate an identified cell range. This means that you can build
sophisticated charts, scorecards, and dashboards using Excel and use DB2 Web Query
reports to populate the cells that those components are based on. Users never need to go
into the web browser to access the power of DB2 Web Query.
Use of the Spreadsheet Client does require some configuration steps. See the chapter 15 Using the DB2 Web Query Spreadsheet Client of the DB2 Web Query Version 2.1 product

512

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

manual. This manual can be downloaded from the IBM developerWorks wiki using the
following URL:
https://www.ibm.com/developerworks/mydeveloperworks/wikis/home/wiki/W516d8b60d32c_
4fc5_a811_5f3d840bf524/page/Release%202.1%20Product%20Manual?lang=en
The spreadsheet client configuration section is located in Volume 1.
In this section we will build a dashboard of charts and reports from within the Excel tool. The
data for these reports and charts will be pulled down from DB2 for i tables using the DB2 Web
Query Spreadsheet Client. An example of the output from the spreadsheet client is pictured in
Figure 16-50 on page 513.

Figure 16-50 Sales Dashboard using Excel and Spreadsheet Client

16.7.1 Creating a Dashboard in Excel


In this section you create a new dashboard using Microft Excel. The dashboard will be
comprised of 3 charts and 1 report. Each of these dashboard elements will be based on new
DB2 Web Query reports that you create using the DB2 Web Query Spreadsheet Client and
InfoAssist.

Create DB2 Web Query reports


The first two reports that we create are going to be the basis for charts in Excel.
Consequently we want to hide these cell ranges (the data generated by the reports) to
Chapter 16. Assignment #9: Exploring/comparing other dashboard options

513

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

another worksheet. We put these reports on worksheet 2.To create the reports, take the
following steps:
1. Open Microsoft Excel
2. Click on Sheet 2 tab at the bottom of the spreadsheet
3. In cell A1, right mouse click and select Create Web Query Report shown in Figure 16-51
on page 514.

Figure 16-51 Create Web Query Report from within Microsoft Excel

A dialogue window opens and you are prompted to specify the Web Server Connection which
is the URL of the DB2 Web Query host server. This will be the string
http://your_system:12331
where your_system is the fully qualified domain name server (DNS) or IP address of the
IBM i system which has DB2 Web Query up and running.
4. As described above, specify the Web Server URL. An example is shown in Figure 16-52
on page 515.

514

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-52 Web Server URL

At this point, you need to be authenticated to the server as a valid DB2 Web Query user
profile. A logon window is presented so you can enter your IBM i credentials.
5. Enter your IBM i user profile and password and click Next
In this exercise, you are creating new reports using the InfoAssist tool. Consequently (just as
you did in the other assignments using InfoAssist), the first thing you must do is specify a data
source. A dialog window with the list of data source is presented.
6. Select the CEN_ORDERS synonym as shown in Figure 16-53 on page 516 and click
Finish.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

515

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-53 Select data source

The InfoAssist tool is presented as shown in Figure 16-54 on page 517. You may notice that
this is not the full version of InfoAssist. This is as designed: some of the features of the full
InfoAssist tool are not exposed from within the Spreadsheet client ibecause they are not
applicable from this interface.

516

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-54 InfoAssist from within the Spreadsheet Client

At this point, you should already be very familiar with the InfoAssist tool.
7. For the report definition, do the following:
a. Select Product Type field as the sort by field
b. Select Gross Profit and Revenue fields for the measure fields
The report should look the same as the example as shown in Figure 16-55.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

517

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-55 Gross Profit and Revenue Report

8. We only want to show data for the year 2011, so add a simple filter to this report based on
the field ORDERDATE_YEAR equal to 2011 as shown in Figure 16-56 on page 519.

518

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-56 Filter for order year 2011

9. Click the Save icon and close the InfoAssist window.


You return to the spreadhseet. In your worksheet the cell range A1 though C6 is
populated. DB2 Web Query ran the report and the results were automatically brought into
that cell range.

Figure 16-57 Results from report and pulled into cell range

10.Using the same steps as above, create another DB2 Web Query report in sheet 2 starting
at cell E1.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

519

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

11.Once InfoAssist is presented, create a new Define field called OrderMonthName. The
format is Mtr and it is based on the ORDERDATE field as shown in Figure 16-58.

Figure 16-58 Order Month Name Define field

12.For the report definition, do the following:


a. Select OrderMonthName for the Sort By field
b. Specify Quantity as the measure.
c. As you did for the first report, add a filter for ORDERDATE_YEAR = 2011
When you are finished, the report should look like the one shown in Figure 16-59.

Figure 16-59 Quantity by Month Name

13.Save the report and close InfoAssist.


Back in Excel, the two reports are run and the cell ranges populated. Sheet 2 should look
similar to the example shown in .

520

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-60 Two reports in sheet 2

Creating Excel Charts


You are now ready to create charts based on these two reports. You wil actually create three
graphs in Excel based on these two reports: two pie charts and one line chart.
14.Click on the Sheet 1 tab at the bottom to go to the first worksheet.
15.From the Insert tab, select Pie-->Exploded pie in 3-D as shown in Figure 16-61

Figure 16-61 Exploded 3-D pie chart

16.Right-click on the chart area and select Select Data as shown in Figure 16-62.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

521

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-62 Select Data for pie chart

17.While the cursor is in the Chart data range text box, go to Sheet 2 and select the range
A1 through B6. This is done by selecting cell A1, holding down Ctrl key, and selecting cell
B6. When you press the Enter key the selected range is brough into the Chart data range
text box. An example is shown in Figure 16-63.

Figure 16-63 Select range

As demonstrated in Figure 16-64, you should see Gross Profit as the Legend Entry (Series)
and the various product types under the Horizontal (Category) Axis Labels

522

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-64 Data range is defined

18.Click OK
19.Right click on the chart and select Add data labels as shown in Figure 16-64.

Figure 16-65

Data labels showing the actual values are added to the chart. In addition to actual values,
you can add percentage of total as a data label.
20.To customize the data labels, right click on the chart and select Format Data Labels
21.Under Label Options, add check to the Percentage check box and click Close as shown
in Figure 16-66.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

523

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-66 Add percentages to data labels

22.Your chart should look similar to the example in Figure 16-67.

Figure 16-67 Gross Profit pie chart

You have finished creating your first chart based on a DB2 Web Query report.
23.Following steps 14 through 16 above, insert another chart in Sheet 1.
24.This time the chart data range is A1 through C6. However, we do not want Gross Profit in
this chart so select it and remove it as shown in Figure 16-68 on page 525.

524

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-68 Remove Gross Profit

25.Click OK
26.As you did for the Gross Profit Pie chart, add data labels and format data label to show
percentages.
27.When you have finished your two pie charts should look like the example displayed in
Figure 16-69.

Figure 16-69 Gross Profit and Revenue pie charts

The last chart to create is a line chart in Sheet 1. This will be based on the OrderMonthName
and Quantity report.
28.From Insert tab, select Line-->Line With Markers as shown in Figure 16-70.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

525

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-70 Insert line chart

29.Right click on the chart area and select Select Data


30.The line chart should be based on the sheet 2 range E1 through F13 as shown in
Figure 16-71.

Figure 16-71 Line chart data range

When you are done, Sheet 1 should look like the example shown in Figure 16-72.

526

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-72 Two pie charts and a line chart

31.Next add a title to the dashboard. From the Insert tab on Sheet 1, select Text Box as
shown in Figure 16-73 on page 527.

Figure 16-73 Add Text Box for Title

32.Draw a box above the two pie charts and type Sales Dashboard. If you want, make the
font larger and bold. Your dashboard should look like the example provided in
Figure 16-74 on page 528.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

527

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-74 Sales Dashboard

Creating report for dashboard


The final addition to the Sales Dashboard is a report showing profit margins for each product
category. We want to include this report in the dahsboard and not hide it in sheet 2 - therefore
it will be created on a cell in sheet 1.
33.Create a new Web Query report on Sheet 1 cell K21.
34.Select your DB2 Web Query server and click Next
35.Select data source CEN_ORDERS and click Finish
36.For the report definition, do the following:
a. Select Product Category and Product Type for the Sort By fields
b. Specify Margin as the measure.
c. As you did for the other two reports, add a filter for ORDERDATE_YEAR = 2011
37.When you have finished, the report definition should look identical to the example in
Figure 16-75 on page 529.

528

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-75 Margin by Product Category report

38.Save the report and close InfoAssist.


Sheet 1 of the spreadsheet should look like the example provided in Figure 16-76.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

529

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-76 Sales Dashboard with 3 charts and 1 report

Conditional Formatting
Conditional formatting is a feature in Excel that provides some interesting visual effects. It
basically allows you to add visual effects to your report based on the values of the data. It is
very similar to what is referred to asTraffic Lighting and Conditional Styling in DB2 Web
Query.To implement conditional formatting, follow these steps:
39.Back in Excel, select the cells for the Margin values (M24 through M38),
40.From the Home tab, select Conditional Formatting and select the four colored arrow set of
icons under the Icon Sets option. This is demonstrated in Figure 16-77 on page 531.

530

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-77 Conditional formatting

This will automatically distribute the data into four categories (based on percentage) and
provide an appropriate icon for each category.
Note: You can customize the values for each of the categories by editing the formatting
rules. To do this, from the home tab, select Conditional Formatting-->Manage Rules

Summary Functions
In InfoAssist, you can include summary functions in your report (such as subtotaling and
grand totals). An alternative is to use the many powerful summary functions that Excel has to
offer. This is done by applying the summary functions to the data range returned by the DB2
Web Query report. The requirement for this particular report is to display the average margin
for all products.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

531

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

41.In the cell below the last row of data and in the Product Type column (cell L39), add the
text Average margin.
42.ISelect the cell below the last margin value row and column (cell M39)
43.From the Formulas tab, select AutoSum-->Average as shown in Figure 16-78.

Figure 16-78 Add Average Summary Function

Your report should look like the example in Figure 16-79

Figure 16-79 Average Margin

Data Range Properties


Each of the reports you have created in the spreadsheet using the DB2 Web Query
spreadsheet client can be modified to include features such as background refresh,
automatically refreshing at specified intervals, and preserving cell formatting. All of these

532

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

attributes can be defined via the Data Range Properties interface by taking the following
steps.
44.Select a cell in one of the reports, right-mouse click, and select Data Range Properties as
shown in Figure 16-80.

Figure 16-80 Open Data Range properties

45.Activate the each of the Refresh Controls and select Preserve Cell Formatting as shown in
Figure 16-81.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

533

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-81 Data Range Properties

An description is provided for each of the settings below:


Enable Background refresh
Allows the report to run and data to be refreshed in a background mode. This means
the user can continue to perform other tasks within the spreadsheet while the refresh
occurs. If this setting is not activated, the user must wait until the refresh is over before
performing other tasks in the spreadsheet.
Refresh every x minutes
The interval (in minutes) to automatically run the report and refresh the data.
Refresh data when opening file
The report is run and data is refreshed when the file is opened. This will require the
user opening the spreadsheet to log in to DB2 Web Query at the time the file is
opened.
Preserve cell formatting
Any Excel customization made to the cells (such as fonts, custom formatting, etc.) are
not overwritten when the data is refreshed .

Guided Ad Hoc Forms


Just as is the case with using InfoAssist from the BI Portal (BIP) interface, you must be an
explicit licensed user to be able to use this DB2 WebQuery development tool within Excel. For
those runtime only users who wouldl like to use the Spreadsheet Client, another option is to
use something called guided ad Hoc forms, an HTML page (pre-built by a licensed user using
the HTML Composer tool). This feature provides runtime users with a more structured

534

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

method of accessing and interacting with the data by using simple parameters to interact with
a predefined data source. Use of guided Ad Hoc Forms requires the following steps:
 Configure the environment
 Create a Guided Ad Hoc Form
 Use the Guided Ad Hoc Form
In this section, the steps for configuring, creating, and using guided ad hoc forms for the
Spreadsheet Client are provided. This section is not part of of the assignment, it is provided
for reference only.

Configuring Environment for Guided Ad Hoc Forms


To configure your environment for the usage of Guided Ad Hoc Forms, take the following
steps:
1. Sign on to DB2 Web Query as an administrator such as QWQADMIN
2. Under Administration link, select Administration Console as shown in Figure 16-82.

Figure 16-82 Administration console

The DB2 Web Query Admininstration Console is presented


3. In the left navigation pane, expand Configuration
4. In the left navigation pane, select Spreadsheet Client
The Spreadsheet Client Configuration page is preseneted
5. Make sure IBI_Quick_Data_Security is set to the value MR
6. Specify a valid Full Path that contains the folder where the Guided Ad Hoc Forms will be
created as shown in Figure 16-83. In our example, we use the value
IBFS:/WFC/Repository/Century_Electronic/Guided_Ad_Hoc_Forms

Figure 16-83 Spreadsheet Client Configuration page

Note: To obtain the fullpath for a particular folder, go to the the BI Portal and select the
folder. From the right-click menu, select the Show Path option. The full path will be
presented in a new dialog window within the browser. From here you can copy (Ctrl-C)
the full path to your clipboard and paste it elsewhere.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

535

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

7. Click Save
8. Close the Administration Console

Creating a Guided Ad Hoc Form


The next step is to actually create a form that run time users can use. To do this, take the
following steps:
1. Launch the DB2 Web Query Developer Workbench tool.
2. Connect to the server
3. Sign on to DB2 Web Query with a user profile that is licensed to use Developer
Workbench and has development rights to the top level folder containing the folder of the
structured ad hoc forms.
4. Under Repository, expand and find the folder which will contain the guided ad hoc
forms.An example is shown in Figure 16-84.

Figure 16-84 Folder with Guided Ad Hoc Forms

5. Select the Folder and from right-click menu select New-->Guided Report Form
6. Specify the name of your new ad hoc form, make sure it is an HTML file type, and specify
Create with Composer. An example is shown in Figure 16-85.

536

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-85 Name your guided ad hoc form

7. The steps for creating an HTML form have already been covered earlier in this chapter so
will not be repeated here. If you need to review this topic, see the previous example in
Chapter 16.6, Dashboard using HTML composer on page 495.
8. For our example, we have created a guided ad hoc form that references the report 5c Revenue Advanced Filter that was created in Chapter 12.2, Advanced Filters - Revenue
Advanced Filter report on page 352. Once created and run, this form looks like the
example shown in Figure 16-86.

Figure 16-86 Finished Guided ad hoc form

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

537

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Using the Guided Ad Hoc Form


Nowthat the environment for Guided Ad Hoc forms has been configured and a guided ad hoc
form has been created in the specific folder, your run time users can run these forms from
within Excel using the Spreadsheet client. To do this take, the following steps.
1. Open Microsoft Excel
2. Right click on a cell and select Create Web Query Report
3. Specify the correct Web Server URL
4. Enter your user profile and password
A dialog window is presented which prompts you for the report type. This is a noticeable
change from the environement before Guided Ad Hoc Forms were configured.
5. As shown in Figure 16-87,select the radio button for Use guided ad hoc form

Figure 16-87 Specify Report Type

6. Select the guided ad hoc form from the list displayed.


The selected guided ad hoc form is presented from within Excel.
7. Select the desired parameter values and click the Run button
As shown in Figure 16-88, the query runs and the results are displayed in the specified
cell range.

538

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch16.fm

Figure 16-88 Run results of guided ad hoc form request

Note: Users can change the values of the parameters and run the report again (and the
cells in the spreadsheet are repopulated with the results of that run request). Once you
close the HTML Form, you can reopen it by right clicking on the cell range and selecting
the Edit Query option. Be aware that selecting the Refresh option will NOT re-present
the form to prompt the user for parameter values - it will simply rerun the query using
the last input parameter values that the user specified.

The Finished Product


Thats it! You have completed the assignment of using Excel and the DB2 Web Query
Spreadsheet Client as the tools for delivering a Sales Dashboard. Your completed dashboard
should look like the example in Figure 16-89 on page 540.

Chapter 16. Assignment #9: Exploring/comparing other dashboard options

539

8063ch16.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 16-89 Completed Sales Dashboard using Excel and Spreadsheet Client

540

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

17

Chapter 17.

Assignment #10: Scheduling and


Distribution of reports
In this assignment we will go into detail about how to schedule a report for distribution, view
the various frequency options when scheduling a report, show how to get failure notifications,
create a distribution list for email, FTP and printer, enable a report for a capability known as
intelligent bursting, and view the log entries for a scheduled distribution.
Pre-requisites: To complete this assigment you need report 1a Revenue Summary by
Product Category and 1d - Revenue and Returns by Type, which were created in
Assignment 01 - Simple Reports. And we also need 5a - Revenue Simple Filter, which
were created in Assignment 05 - Adding filters to report.
In this assignment, we will schedule the existing reports and distribute them. It is a best
practice to save the schedules in a separate folder from where the reports locate. So
create a new folder named Assignment 18 - Scheduling and Distribution of reports
under folder Century Electronics. Under this folder, create three sub folders named
Schedules, Distributions and Reports run from Schedules. Under Distributions folder,
create folders named FTP, Email and Printer. Schedules folder will contain the schedules
that we are going to create later on. FTP, Email and Printer will contain different types of
Distribution List. And Reports run from Schedules folder will have the output of the report
that we are going to schedule and distribute via DB2 Web Query.
Also need to make sure that, the user we are going to use to create the schedule should be
Web Query Admin.

Copyright IBM Corp. 2012. All rights reserved.

541

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

17.1 Report Broker Overview


DB2 Web Query Report Broker is a feature in DB2 Web Query Standard Edition that builds on
the strengths of the Web-based query and reporting tool, DB2 Web Query. With Report
Broker you can automate the process of running your reports and schedule them for
distribution to individuals, distribution lists, printer destinations, or for storage in a Web Query
folder for shared online viewing or archival purposes.
The scheduling function and the ability to view and change existing schedules, create and
view distribution lists, view Distribution Server log entries, establish schedule blackout dates,
and other Report Broker services are all presented to a Web Query Admin. The user who is in
Analyst, Dev or Sched group of the top level folder where the report is created in is also able
to create the schedule.
Report Broker services are included in the DB2 Web Query online help. Report Broker help
text is context sensitive and will position you to the appropriate help for the corresponding
screen or topic. Look for icons with a question mark. Report Broker help text is available in the
same language translations as DB2 Web Query.
You can use CL commands to start and end Report Broker Distribution Server. All three CL
commands used to start or end of Web Query services (Start Web Query (STRWEBQRY),
End Web Query (ENDWEBQRY), and Work Web Query (WRKWEBQRY)) include the Report
Broker Distribution Server as part of the command default '*ALL'.
To see how the Report Broker Distribution Server fits into the DB2 Web Query architecture,
see Figure 1-1 on page 9

17.2 The Assignment


Executive Dan (being an executive himself) knows that many executives do not want to spend
time looking for and pulling their reports. Rather they would prefer to have the reports come
to them (pushed) in one centralized location: their email inbox. Executive Dan would like to
have all managers at Century never have to log in to DB2 Web Query to pull reports. He
would like all of their reports to be automatically distributed to them on a daily basis. That way,
when they open their email in the morning, all of the reports are there waiting for them.
For this assignment, you will utlize Report Broker, the DB2 Web Query scheduling and
distibution feature. You will set up schedules to run reports and have them emailed to the
management at Century Electronics.

17.3 Configuring Report Broker


Report Broker is part of DB2 Web Query Standard Edition. So if DB2 Web Query Standard
Edition is active on your system, then you can use Report Broker. But you must configure it
first before using it.
1. To configure it, you need to sign in DB2 Web Query as QWQADMIN. After that, go to the
Administration Console by selecting Administration Administration Console, as
illustrated in Figure 17-1.

542

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

Figure 17-1 Administration Console

2. In the left panel of Administration Console, click Configuration as shown in Figure 17-2
on page 544. Fill in the Default Mail From and Default Mail Reply Address. Also, fill in
the Mail Host field with your mail server name. You can set up SMTP on the system that
Web Query and Report Broker reside on, or you can also use an external mail server.
After setting these up, click Save.

Chapter 17. Assignment #10: Scheduling and Distribution of reports

543

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 17-2 Configure Report Broker

Note: You need to make sure that the following system values are correctly set up on
your IBM i system where Web Query and Report Broker reside on. Since we are
scheduling the report to be run at specific time, so to make sure the date time and the
time zone system values are set up correctly is important and that will avoid some
problems that are difficult to be found later.
 QDATETIME
 QTIMZON
 QTIMADJ
 QUTCOFFSET

544

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

17.4 Schedule a simple report and distribute via Email


Now we are going to schedule a simple report and distribute it to individuals via Email.
1. Log on to Web Query using your Username and Password.
2. Expand the Century Electronics Assignment 01 - Simple Reports folder. Right click
on report 1a - Revenue Summary by Product Category and select Schedule Email
as illustrated in Figure 17-3. This will open the Basic Scheduling tool.

Figure 17-3 Schedule the report

3. First we will see the DB2 Web Query Report Task as illustrated in Figure 17-4 on
page 546. It shows the path of the report, the name of the procedure, the server name and
the execution ID. These are not editable. We can select the output format of the report ,
the default format is HTML. In this section, well use this format so when we get the report
via Email, it will be an HTML file. Click Properties in the Basic Scheduling tool ribbon.

Chapter 17. Assignment #10: Scheduling and Distribution of reports

545

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 17-4 Set Task in Basic Scheduling Tool

4. Name the title 1a - Revenue Summary by Product Category via Email. The summary
field allows you to insert a description for the schedule. This is an optional field. Enter This
is a Web Query report of Revenue Summary by Product Category as the description.
Based on the type of the report being distributed, different format options will present
themselves. For this example, we will leave the Report Format as its default value, which is
HTML - Web Page. Click Recurrence as shown in Figure 17-5 on page 547.

546

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

Figure 17-5 Set Properties in Basic Scheduling tool

5. The Recurrence section determines when and how often the report is distributed. By
default the run interval is Once on a create and it is primed with the current date and time.
We are going to create a weekly schedule, which runs the report on every Tuesday and
Thursday from Jul, 24, 2012 to Dec, 31, 2012. As illustrated in Figure 17-6 on page 548,
click the Weekly radio button. Set the start time as Jul, 24, 2012 8:30PM and the end time
as Dec, 31, 2012 11:00PM. Check the Tue and Thu checkboxes and accept the default
Every 1 week value in the spinbox. Then click Distribution.

Chapter 17. Assignment #10: Scheduling and Distribution of reports

547

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 17-6 Set Recurrence in Basic Scheduling tool

6. In this example, we are going to distribute the report to 2 Email addresses. So select the
type as Email Address(es), as shown in Figure 17-7 on page 549. Enter the 2 Email
addresses in the To feilds, separated them with a comma (,) or a semicolon (;). And then
enter the From and Reply Address fields of the report. The Subject field of this report
distribution is primed with the name of the selected report being scheduled. Leave it as it
is or give it a more meaningful subject. By default, the report is sent as an attachment. You
have the option to add reports to the zip file by clicking Add Reports to Zip File. As this
report is small, we leave that box unchecked.

548

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

Figure 17-7 Set Distribution in Basic Scheduling tool

7. The Notification section allows you to specify if and when you want failure notification and
who should receive that notification. You can Always get a notification, Never get a
notification, or get one only On Error. If you designate notification, you will be required to
provide a Message To and Reply Email address and the subject. Note that the Subject
is populated with the subject of the original report. You should change the subject to
indicate the appropriate notification state.

Chapter 17. Assignment #10: Scheduling and Distribution of reports

549

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 17-8 Set Notification in Basic Scheduling tool

Tip: Use the Brief Message To option when you are sending notification to devices that
have limited memory, such as cell phones.
8. Click the Email Server button and check if the Email Server is already set up as shown in
Figure 17-9. If not we need to fill in the Mail Server Name field with the Email Server
name or IP. This step may not be needed if we have already configured Report Broker in
Administration Console. After setting these, click Save & Close button.

Figure 17-9 Check email server set up in Basic Scheduling tool

550

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

9. In the window that pops up as shown in Figure 17-10 on page 551, select Assignment 18 Scheduling and Distribution of reports Schedules and then click Save. Then the
Basic Scheduling Tool window will be closed.

Figure 17-10 Save the schedule

10.Then we will see the schedule is in the Schedules folder as shown in Figure 17-11 on
page 552.

Chapter 17. Assignment #10: Scheduling and Distribution of reports

551

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 17-11 View the schedule

At this point, the example is done. After the schedule is executed, Emails will be sent out and
those 2 individuals who we set in Distribution with the Email addresses will get a mail. The
mail will contain the output of report 1a - Revenue Summary by Product Category as an
html attachment.
After the schedule runs, we can double click on the 1a - Revenue Summary by Product
Category via Email schedule to open it, and then click Log Reports as shown in
Figure 17-12 on page 553. Then we can check the logs when it ran and see if it executed
successfully or not.

552

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

Figure 17-12 Log Reports

17.5 Schedule a report with parameters and distribute via Email


In the previous example we introduced how to schedule a simple report. Now we are going to
schedule a report which requires parameters. We will create an Email Distribution List,
schedule the report and distribute via Email to the Email Distribution List.

17.5.1 Create an Email Distribution List


1. We need to create an Email Distribution List first. Expend Century Electronics
Assignment - 18 Scheduling and Distribution of reports Distributions Email
and select New Distribution List as shown in Figure 17-13 on page 554.

Chapter 17. Assignment #10: Scheduling and Distribution of reports

553

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 17-13 Create Distribution List

2. Name the title Email DIstribution List 1 as illustrated in Figure 17-14 on page 555. Accept
the default Method value, which is Email in the combobox and then click Add New button
in the ribbon. After the Add New Member window shows up, type the Email address in the
Email Address field.
3. Click the Add New button again and add another Email address or add more according to
your own requirements.

554

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

Figure 17-14 Add New Member to the Distribution List

4. Click Save & Close button in the ribbon.

Figure 17-15 Save the Distribution List

5. Select Century Electronics Assignment - 18 Scheduling and Distribution of


reports Distributions Email folder and click Save button. Then the schedule is
saved in the Email folder.

Chapter 17. Assignment #10: Scheduling and Distribution of reports

555

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 17-16 Save the Distribution List in Email folder

17.5.2 Schedule the report


1. Expend the Century Electronics Assignment - 05 Adding filters to report and right
click on the 5a - Revenue Simple Filter report and select Schedule Email.

556

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

Figure 17-17 Schedule the report

2. Set the Properties, Recurrence, Task and Notification as we introduced in 17.4,


Schedule a simple report and distribute via Email on page 545 according to your own
requirements.
3. Click Distribution button in the ribbon as shown in Figure 17-18. Select Distribution List as
the value of Type and then click the To... button.

Chapter 17. Assignment #10: Scheduling and Distribution of reports

557

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 17-18 Set Distribution in Basic Scheduling tool

4. Expend the Century Electronics Assignment 18 - Scheduling and Distribution of


reports Distributions Email folder, select Email Distribution List 1 and click
Open.

558

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

Figure 17-19 Select Distribution List

5. We need to provide the parameters when scheduling the report since this report requires
2 paramters. Click the Parameters button in the ribbon as shown in Figure 17-20 on
page 560. In the Task Parameters window that pops up, click on the COUNTRY
parameter, select United States as the parameters value in the Value comobox. Then do
it the same way and select Cameras as the value of parameter PRODUCTTYPE. Click
OK.

Chapter 17. Assignment #10: Scheduling and Distribution of reports

559

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 17-20 Set Parameters

6. Click Save & Close button and save the schedule as 5a - Revenue Simple Filter via
Email in the Schedules folder.
After this schedule runs, the individuals who are in Email Distribution List 1 will get the
output of the report via Email. The output will only have the records whose COUNTRY is
United States and PRODUCTTYPE is Caremas.

560

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

17.6 Schedule a report and distribute via DB2 Web Query


Besides schduling the report and distribute via Email, we can also distribute scheduled output
via DB2 Web Query in the Basic Scheduling tool by specifying the repository folder location to
distribute the report output to.
1. Expand the Century Electronics Assignment 01 - Simple Reports folder. Right click
1a - Revenue Summary by Product Category and select Schedule DB2 Web Query
as illustrated in Figure 17-21. This will open the Basic Scheduling tool.

Figure 17-21 Schedule the report

2. After the Basic Scheduling Tool pops up, click Distribution as shown in Figure 17-22, and
then click Folder Location button.

Figure 17-22 Set Distribution in Basic Scheduling tool


Chapter 17. Assignment #10: Scheduling and Distribution of reports

561

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

3. As illustrated in Figure 17-23, browse to the folder location that we want to distribute the
report to after it runs. In this example, select Century Electronics Assignment 18 Scheduling and Distribution of reports Reports Run from Schedules folder and
click ok. Besides these settings, also set the Properties, Recurrences, Task and
Notification according to your own requirements. Click the Save & Close button.

Figure 17-23 Set Folder Location

4. Change the title of the schedule to be 1a - Revenue Summary by Product Category via
DB2 Web Query, expand Assignment 18 - Scheduling and Distribution of reports
folder, select Schedules foloder and then click the ok button. This will save the schedule.

562

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

Figure 17-24 Save the Schedule

5. After the schedule is executed according to the Recurrence settings that we made, the
report will be distributed in the Reports Run from Schedules folder, as we can see from
Figure 17-25 on page 564. When the report is distributed, the Distribution Server adds
Day, Date, and Time to the beginning of the Save Report As value specified in the Task
tab.

Chapter 17. Assignment #10: Scheduling and Distribution of reports

563

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 17-25 Reports run from Schedule

6. We can also run the schedule once as a test as shown in Figure 17-26 on page 565. Right
click on the schedule and select Run. This will also run the schedule and distribute the
report into the Reports Run from Schedules folder. We are also able to click the View
Log button to check the log when the schedule runs so that we know if the schedule
successfuly runs or some errors are happening.

564

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

Figure 17-26 Run the Schedule

Chapter 17. Assignment #10: Scheduling and Distribution of reports

565

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

17.7 Schedule a report and distribute via FTP


This section provides information about distributing scheduled output using File Transfer
Protocol (FTP).
1. Expend Century Electronics Assignment 18 - Scheduling and Distribution of
reports Distributions folder. Right click on FTP folder under Distributions and select
New Distribution List.

Figure 17-27 Create Distribution List

2. Name the title FTP Distribution List 1. Select the FTP value in the Method combobox.
Click the Add New button in the ribbon as shown in Figure 17-28 on page 567.

566

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

Figure 17-28 Add New Member

3. Set the Burst value to be Audio, select Plain text as the value of the Pattern combobox
and then set the FTP location to be Audio.pdf. Click OK.

Figure 17-29 Add new member

4. Click the Add New button again to add another member in the distribution list. Set the
Burst value to be Cameras, select Plain text as the value of the Pattern combobox and
then set the FTP location to be Cameras.pdf. Click OK.

Chapter 17. Assignment #10: Scheduling and Distribution of reports

567

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 17-30 Add New Member

5. Click the Add New button again to add the last member in the distribution list. Select Else
end as the value of the Pattern combobox and then set the FTP location to be
Others.pdf. Click OK.

Figure 17-31 Add New Member

6. Now we can see all the 3 members in FTP Distribution List 1 as illustrated in
Figure 17-32 on page 569. Click on the Save & Close button.

568

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

Figure 17-32 Save and Close

7. Select Century Electronics Assignment 18 - Scheduling and Distribution of


reports Distributions FTP. Accept the default value of the Title, which is FTP
Distribution List 1, and click Save.

Figure 17-33 Save the Distribution List

Chapter 17. Assignment #10: Scheduling and Distribution of reports

569

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

8. Then we can see FTP Distribution List 1 is created as shown in Figure 17-34 on page 570.

Figure 17-34 View the saved distribution list

9. Expend Century Electronics Assignment 01 - Simple Reports. Right click on the 1d


- Revenue and Returns by Type report and select Schedule FTP.

570

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

Figure 17-35 Schedule the report

10.Check the Burst Report check box. The burst feature enables you to instruct the reporting
server to create the report in sections so that the sections can be distributed separately.
Each report section is saved to a separate file. Select the PDF - Adobe PDF(*.pdf) as the
Report Format value as illustrated in Figure 17-36. Click Distribution button in the ribbon.

Chapter 17. Assignment #10: Scheduling and Distribution of reports

571

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 17-36 Select the report format

11.Select Distribution List in the type comobox, and then click the Name button as shown in
Figure 17-37.

572

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

Figure 17-37 Select Distribution type

12.Expend Century Electronics Assignment 18 - Scheduling and Distribution of


reports Distribution FTP and click on the FTP Distribution List 1 that is listed,
which we created previously. Click the OK button.

Chapter 17. Assignment #10: Scheduling and Distribution of reports

573

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 17-38 Select Distribution List

13.Fill in the Directory with the directory name on the FTP server that you want to save your
report into as shown in Figure 17-39 on page 575. You need to make sure that this
directory exists on the FTP server. Click Save & Close button.

574

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

Figure 17-39 Save the Schedule

14.The FTP Distribution Options window will show up which requires you to enter the
Account name and password for the FTP server if you are scheduling for the first time on
this server as shown in Figure 17-40. The credentials will be stored so it wont let you
enter these again for the next schedule on the same server.

Figure 17-40 Enter Credentials

15.Click Save & Close and save the schedule as 1d - Revenue and Returns by Type via
FTP in the Schedules folder.
16.At this point, the report is scheduled and when this schedule runs, Audio.pdf,
Cameras.pdf and Others.pdf will be FTPed to your FTP server which you just set. Since
we have bursted the report, Audio.pdf will only have the records whose product type is

Chapter 17. Assignment #10: Scheduling and Distribution of reports

575

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Audio, the Caremas.pdf will only have the records whose product type is Cameras and
the Others.pdf will have all the other records which are not Audio or Cameras.

17.8 Schedule a report and distribute via Printer


Report Broker also supports scheduling a report and distributing it via printer. When the
schedules runs, the output file of the report will be printed out.
The way to distribute the report via printer is very similar to how we did to distribute it via
Email. The difference is mostly in the Distribution set up of the schedule.
To distribute the report via Printer, in the Distribution set up of the schedule, we need to
specify the printer name, or a distribution list which contains several printer names.
 Distribution List. The report will be sent to all printers in the selected Distribution List. To
select a Distribution List, click the icon next to the Distribution List field as is shown in
Figure 17-41.
 Printer Name. Specify the printer using the format of queue@printserver. Queue is the
name of the printer queue. Printserver is the host name or IP address of the printer.
Report Broker can differentiate between the printer queue and the printer host name/IP
address due to the presence of the @ separator. Although Report Broker supports
specifying only the host name or IP address of the printer, we recommend specifying both
the printer queue and host name/IP address when distributing Report Broker output to a
printer. The maximum length of this field is 800 characters.

Figure 17-41 Distribution List

576

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

Figure 17-42 Printer Name

The report formats that support printing are DOC, PDF (when you configure Report Broker to
enable PDF to print and the printer has the appropriate driver), PS, and WP.

17.9 RUNBRSCHED command


There is a Run Report Broker Schedule(RUNBRSCHED) command which is provided in
Web Query 2.1.0. With this command, we can run an existing schedule on IBM i and the
output will go to the place that we set in the Distribution of the schedule.
RUNBRSCHED command requires 2 parameters, a Schedule ID and a Run Report with User
ID. Folling are the steps how we use this command.
1. Log on Web Query.
2. Expend Century Electronics Assignment 18 - Scheduling and Distribution of
reports Schedules folder. Right click on the 1a - Revenue Summary by Product
Category via Email schedule and click Properties as shown in Figure 17-43.

Chapter 17. Assignment #10: Scheduling and Distribution of reports

577

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 17-43 Properties of the schedule

3. In the Properties window that pops up, we may find the schedule has an id property which
is S8f45fc9bs5414s4075sb346sa631f1eeb6a1, as is shown in Figure 17-44 on
page 579.

578

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

Figure 17-44 ID of the Schedule

4. Log on the server which Report Broker resides on using the user profile that you made the
schedule, issue QWEBQRY/RUNBRSCHED and press F4. Paste the id of the schedule
into green screen as the value of Schedule ID parameter. Accept the default value of the
Run Report with User ID parameter, which is *CURRENT, since we are logging on using
the user profile that we made the schedule. We can also specify a different user profile if it
is authorized to the schedule.
5. Press Enter then the schedule will run and we will get the output in the place where we set
in the Distribution of the schedule.

Chapter 17. Assignment #10: Scheduling and Distribution of reports

579

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Run a Report Broker Schedule (RUNBRSCHED)


Type choices, press Enter.
Schedule ID . . . . . . . . . .

Run Report with User ID . . . .

F3=Exit F4=Prompt
F24=More keys

F5=Refresh

S8f45fc9bs5414s4075sb346sa631f1eeb6a1

*CURRENT

F12=Cancel

Figure 17-45 RUNBRSCHED on green screen

580

IBM i DB2 Web Query for i Implementation Guide

Character value

F13=How to use this display

Draft Document for Review August 30, 2013 2:37 pm

8063ch18.fm

17.10 Report Broker Console


To view Distribution Server log entries, establish schedule blackout dates, watch server status
and other Report Broker services are all presented to a Web Query Administrator.
Web Query Administrator can log on Web Query and select Tool Report Broker Console
as shown in Figure 17-46 to manage Report Broker.

Figure 17-46 Report Broker Console

The Web Query Administrator can view the Server Status by clicking the Server Status
button as shown in Figure 17-47.

Figure 17-47 Server Status

We can also click Job Logs button as shown in Figure 17-48 on page 582 and check the logs
after the schedule runs. Double clicking the Job Id, corrsponding Job logs will be opened.

Chapter 17. Assignment #10: Scheduling and Distribution of reports

581

8063ch18.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 17-48 Job Logs

It is very easy to set up Report Broker Blackout Dates. Click the Blackout Dates button as
shown in Figure 17-49 and click the blackout dates that you want to set in the calendar. Click
Save button. Then the Blackout Dates will be saved.

Figure 17-49 Blackout Dates

582

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch19.fm

18

Chapter 18.

Assignment #11: Going mobile


In this chapter we discuss how to make available reports, documents and dashboards to
mobile devices. We describe three approaches to mobile deployment which includes:
 Mobile Favorites from Optimized web pages.
 Native Appplication.
 E-mail Distribution.
Pre-requisites: To complete this assigment you need report 1a Revenue Summary by
Product Category that was created in Assignment 01 - Simple Reports

Copyright IBM Corp. 2012. All rights reserved.

583

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

18.1 Mobile Access Assignment


Like many companies, the sales workforce at Century has become more increasingly mobile
over the last decade. Both working from home and traveling to the various store locations
have become the norm for both sales regional managers and the sales force within each of
the regions. Consequently, the concept of Bring Your Own Device (BYOD) has become more
commonplace - managers and their sales force are using their own personal smart phones
and other mobile devices to access the companys critical business data stored on DB2 for i.
These devices could range from Apple iPads and iPhones to Android devices such as the
Motorola Xoom and Samsung Galaxy tablets. A final and rather large obstacle in the mind of
Exective Dan is that the IBM i and DB2 Web Query cannot fully deliver upon the requirements
demanded by these mobile users and their devices. Namely, he would like the entire Century
BI solution to be available from the various mobile devices used by the entire workforce. He
wants instant access to the live data - regardless of where the sales person might be or when
it is requested. In this assignment, you will use various techniques to deploy some of the
charts, reports, and dashboards you created in the previous assignments so that this content
is instantly available to the mobile workers and their devices.

18.2 Preparing Reports for Mobile Access.


In this section we show how to make your reports, Dashboards and Documents available on
your mobile device.
1. Log on to Web Query using your Username and Password
2. Expand the Century Electronics top Folder and Browse to Assignment 01 - Simple
Reports. From this folder Right click 1a Revenue Summary by Product Category and
select Add to Mobile Favorites as shown in Figure 18-1

584

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch19.fm

Figure 18-1 Adding report to Mobile Favorites

3. A pop up message will be displayed indicating that the Report was added to the Mobile
Favorite folder (Figure 18-2). Click OK to finish adding the report.

Figure 18-2 Mobile Favorite added

You can check all the reports that are available for Mobile access by expanding the Mobile
Favorites folder as shown in Figure 18-3

Figure 18-3 Displaying Reports for Mobile Access, Accessing Mobile Content using web browser

Chapter 18. Assignment #11: Going mobile

585

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

18.3 Accessing Mobile Content using the Web Browser


Now that we have added the report that we want to make available for Mobile access, we will
show how to access it from Mobile Devices. For this assigment we are assuming that you
either have a direct network connection to the reporting server or you can connect via VPN to
the local Network in your company from your Mobile Device.
The first approach to access mobile content that we want to show is the new DB2 web query
optimize web page designed for Mobile devices. Active Technologies for Mobile web apps
require Internet Explorer 8 or higher. Active technologies comply with Web standards and are
compatible with the Apple Safari browser. For Blackberry devices OS 6 or higher may be
required in order to render an active report or dashboard in HTML correclty.
Active Technologies check for the screen size of the device at a run time. If the height of the
screen is less than 500 pixels, Active Technologies assume that the report or dashboard is
running on a mobile device and the mobile user interface is used. The Optimize web page
access for mobile device keeps the same secure logon as the db2 web query main portal.
To acces the optimized web page for Mobile access follow these steps:
 On your Moblie device type the following URL: http://system:12331/webquery/mobile
where system is your DB2 web query server name or IP address. On this screen type your
userid and password and click or tap the Sign in button.

Figure 18-4 Optimized Mobile Access web page

 After login in you will see the report that we added to Mobile Favorites in the previous
section as shown in Figure 18-5. On this screen you can identify the following controls:
Sign off: circle in red, allows to log off the web page
Run: circle in green, allows to run reports.
e-mail: circle in blue, allows to send the link for this report to an e-mail account.

586

IBM i DB2 Web Query for i Implementation Guide

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 18-5 Diplaying Reports on Mobile Favorites

 To run the report tap or click the run control. The report will be display in the web page as
shown in Figure 18-6.

Figure 18-6 Running a report

You can run any report, document or dashboard using the procedure describe above.
Tip: Bookmark the web page URL for quick access.
 Click or tap Back to return to the main web page

Chapter 18. Assignment #11: Going mobile

587

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

18.4 Using Mobile Faves.


In this section we show another approach to deploy mobile content on apple devices.This
approach requires the installation of Mobile Faves app from the apple store. Mobile Faves is a
free Universal app for iPad and iPhone, that provides an easy way to natively display, store
and manage any web query mobile content in all supported formats. It also allows to view and
interact with Dashboards
By using this app you can:

Configure one or more db2 web query Servers and set up user security to access
Mobile Faves.

List available Mobile content and view it by tapping it in the list.

Store and view previously-run history for viewing offline, and for your future
reference.

Share a Mobile Fave with any email users you designate

This approach provides more features and faster acces than using the mobile web page
shown in the previous section.

18.4.1 Installing Mobile Faves


To install the Mobile Faves application on your apple device
1. Open Apple Store on your Apple device
2. Search for: Mobile Faves.

Figure 18-7 Searching Mobile Faves in Apple Store

3. Tap the Install icon. You will be asked to provided your Apple ID password. Once you
provide your password the installation will proceed. After the installation is complete you
will see the mobile faves application on your desktop as shown in Figure 18-8

Figure 18-8 Mobile Faves Application

588

IBM i DB2 Web Query for i Implementation Guide

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

18.4.2 Connecting to Reporting Server and running reports


1. Tap the Mobile faves icon located in your apple device desktop. If this is the first time that
you are running the application you will only see the Mobile Faves Home Server as
shown in Figure 18-9.
2. Tap Add Server located under the Mobile Faves Home. This opens the add Server
configuration Panel.

Figure 18-9 Add new Server Mobile Favorites

3. In te configuration Panel tap Host Tittle and type a descriptive name for your reporting
server. In our example we use ITSOP1.
4. Tap Host Alias and type webquery .This is the application Name.
5. For Host Name if you are using a DNS server type the Name of the DB2 webquery server
otherwise type the IP address. In our example we are using an IP address.
6. For Host Port you need to use 12331
7. Finally you need to provide a valid user name and password.
8. When you have finshed completing all the required information tap the Save button
located at the top rigth hand side of the screen.

Figure 18-10 Filling the Add Server Configuration panel

After you click the save button you will be able to see your new configured server as shown in
Figure 18-11. The newly created server contains the reports that we already added to the
Mobile Favorites Folder in the previous section.
9. Tap the server that we just added in our example we choose ITSOP1

Chapter 18. Assignment #11: Going mobile

589

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 18-11 ITSOP1 server added

10.Tap report 1a - Revenue Summary by Product Category to run it.

Figure 18-12 Running a report from Mobile Faves app

18.4.3 Adding Aditional Reports to Mobile Favorites.


1. First we will add a new folder for our assigment. Right Click Century Electronics Folder
and click New Folder. For Tittle type Assignment 12 - Going mobile as shown in
Figure 18-13

Figure 18-13 Creating a New Folder

Next we want to add an active report to the Mobile Favorites folder. To do this we use report
1a - Revenue Summary by Product Category. But first we need to change the output format
to Active Report.
2. Expand Assignment 01 - Simple Reports and rigth click report 1a - Revenue Summary by
Product Category select edit with... and click InfoAssist.

590

IBM i DB2 Web Query for i Implementation Guide

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 18-14 Editing a Report

3. Select the Format tab. If the Output types group is not expanded, Click the Ouput Types
icon on the ribbon to expand it.

Figure 18-15 Expanding Output types Group icon

4. Click the Active Report icon on the ribbon to change the output format of this report.

Figure 18-16 Changing output format to Active Report

5. Click the Application Main Menu and select Save as from the drop down list as shown in
Figure 18-17 on page 592.

Chapter 18. Assignment #11: Going mobile

591

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 18-17 Application Main Menu Save as button

6. On the left pane of the save as dialog box make sure to select Assignment 12 - Going
mobile. For report Tittle type 1a Revenue Summary by Product Category Active. Click
the Save button.

Figure 18-18 Saving active report

We also need to publish this folder and make it available for mobile acces so that Executive
Dan can have acces to it on his mobile devices.
7. Right Click Assignment 12 - Going mobile and click Publish.

592

IBM i DB2 Web Query for i Implementation Guide

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 18-19 Publising a folder

Notice that after you click the publish button the font type of the folder and all of its content
changed from plain text to bold. This is an easy way to make sure that your content has been
published.

Figure 18-20 Font type changed to Bold after Publish

8. Expand Assignment 12 - Going mobile and Rigth click report 1a Revenue Summary by
Product Category Active and click add to Mobile Favorites.
Once we have added the report to the mobile favorite folder we need to go back to the apple
mobile device and open the Mobile Faves app.
9. Tap the Mobile Faves application on your Mobile device.
10.Tap the Mobile Server you added in the previous section. In our case we tap the ITSOP1
server.

Figure 18-21 Displaying ITSOP1 server content


Chapter 18. Assignment #11: Going mobile

593

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

Notice that this time when you open the reporting server you see two folders. In the previous
section when you openned the reporting sever no folder structured was displayed.

Figure 18-22 Adding Additional reports

11.Tap Assignment 12 - Going mobile to display the reports that are available.
12.Tap the Report to run it.

18.4.4 Saving Reports for Offline View.


In this section we show how to save reports for offline view. By saving the reports you make
them accesibles from the app even when you dont have access to the network.
13.In the report that you just ran tap the Tools icon and then tap Save.

Figure 18-23 Saving Report for offline view

Please wait until the Save icon appears on the top left hand side.

Figure 18-24 Save report please wait

594

IBM i DB2 Web Query for i Implementation Guide

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

14.Change the Name of the report to 1a Revenue Summary by Product Category offline
and tap the save icon

Figure 18-25 Saving a report offline view

15.Tap the back icon -> default -> Mobile Faves.

Figure 18-26 Report save for offline view

Notice that a 1 is now presented next to the report representing that now you have one report
for ofline view.
16.To test that the report was saved for offline view disable the wifi connection on your mobile
device and run the report again . As shown in image Figure 18-27 notice that this time
both Mobile Faves Home and itsop1 servers have a n/a red sign indicating no connection
to the servers.

Figure 18-27 Ipad no wireless connection

Chapter 18. Assignment #11: Going mobile

595

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

17.Tap the server you configure in the previous section, then tap the report saved for offline
view. As you can see from Figure 18-28 at the top you have the name of the report being
executed which is actually pointint to the offline version.

Figure 18-28 Displaying Offline Report

18.5 Openning Reports Recevied via E-Mail


In this section we show how to open reports that have being e-mailed to you. For our example
we have sent via e-mail report 1a- Revenue Summary by Product Category Active from
Assigment 12 - Going Mobile folder.
 To open an attached report on your mobile device Tap and hold the attachment icon on the
e-mail. You have to wait until a drop down list is presented as shown in Figure .
 Tap Open in MobileFaves. This will automatically launch the Mobile Faves application
and it will open the report.
596

IBM i DB2 Web Query for i Implementation Guide

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 18-29 Openning attached e-mail in Mobile Faves

 Tap the back icon (Figure 18-30).

Figure 18-30 Tap back

 Tap the Default icon.

Figure 18-31 Tap default

 Tap Mobile Faves icon. This will take you to the intial Mobile Faves screen

Chapter 18. Assignment #11: Going mobile

597

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 18-32 Initial Mobile Faves pane

Notice that this time there is one category for Email channel in the Mobile Faves main page
and it has 1 in the right hand side. This means that you have one report to view in this folder.

Figure 18-33 Mobile Faves main page

18.6 How to use Active Technologies on Mobile Devices


Executive Dan is now excited that he can access reports on his mobile devices but now he
has prepared a list of thing he would like to be able to do, including:
 Sorting Data
 Filtering Data
 Calculate Data on existing report
 He wants to be able to build graphs.
Your challenge in this section is to teach executive Dan how interact with active reports on
moible devices. For this assigment we will be using the report we open in the previous section
Openning Reports Recevied via E-Mail
To Sort Data
 Tap Email channel and then tap your report to run it. In our example we are using the
report we created at the begining of the chapter.
At the top rigth hand corner of the report you will see the full screen icon. You can use this
icon to change views from the orginal active report view to full-screen Web app view mode.

598

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch19.fm

Figure 18-34 Running a report Mobile Faves

Note: you can rotate between landscape and portrait to get a tall or wide view of the
report or chart
 Tap Gross_Profit column heading. This will open a drop down list. From the list presented
tap Sort Descending.

Chapter 18. Assignment #11: Going mobile

599

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 18-35 Displaying Drop down list


.

Note: Taping on any column heading will display the drop down list.
From the drop down menu you can select all the actions that can be perform on the Active
Report.
Now we want to explain how to filter data on an active report.
 Tap the Product Type Column heading to display the drop down menu.
 From the drop down menu select Filter. Make Sure that Condition is set to Equals and
Values is set to Audio. Tap the Done icon.

600

IBM i DB2 Web Query for i Implementation Guide

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 18-36 Applying Filter Mobile Faves

As you can see from Figure 18-37 the report is now filtered by audio and it is sorted in
descending order by Gross Profit. Also Notice that a new tab called Filter opened.

Figure 18-37 Filtered Report Mobile Faves

 Close the Filter tab by tapping the x icon.


 Tap the Gross Profit Column heading.
 From the drop down menu select Calculate and the tap % of Total.

Chapter 18. Assignment #11: Going mobile

601

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 18-38 Calculating Data Mobile Faves

 To clear the column Tap Gross Profit, Tap Calculate and Tap % of Total
Next you want to show Executive Dan how to Build a Graph.
 Tap Gross Profit Column Heading and tap Chart.
 From the drop down menu Tap Chart Type

602

IBM i DB2 Web Query for i Implementation Guide

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 18-39 Selecting Chart Type

 Tap Column and select the Column type chart.

Figure 18-40 Selecting Column Type

 After you tap de Chart type you will be returned to the Chart Screen. Make sure that for
Chart Type you have Column and on aggregation you see Sum. On this screen tap
Product type. Your graphic should be similar to Figure 18-41

Chapter 18. Assignment #11: Going mobile

603

8063ch19.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 18-41 Gross profit by Product Type Graph Mobile Faves

Notice that at the bottom of the graphic you have an additional toolbar. Each of the icons on
the toolbar allows to modify the current graph. For example you can change your graph type
to a pie chart or a line. Try each one of the icons to see how your graph is modify.

604

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch21.fm

19

Chapter 19.

Assignment #14: Stored


procedures in action
This chapter describes the use of stored procedures to access DB2 data from Web Query.
Stored Procedures are a powerful programming tool used to perform batch updates,
encapsulate complex business logic (in SQL or other languages) or process business
transactions.
In this chapter, we will review a couple examples of how stored procedures can be used in
conjunction with DB2 Web Query to extend the reporting capabilities.

Copyright IBM Corp. 2012. All rights reserved.

605

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

19.1 Getting the most from your data with Stored Procedures.
A stored procedure is a program or procedure in a service program that can be called by an
application using the SQL CALL statement. Stored procedures can be written in the SQL
procedural language, or you can use existing programs or service program procedures
(written in RPG, COBOL, JAVA, and so on) and register them to the database as stored
procedures.
When it comes to DB2 Web Query data sources to base their reports on, many developers
only use database objects like tables and views. But a very powerful, yet under-utilized
feature of DB2 Web Query is its ability to use a stored procedure as a data source, provided
that the stored procedure returns a result set. DB2 Web Query has the ability to capture that
result set and use it as the source data for a report.

19.1.1 Prerequisites
Before going further with this chapter, you should create a folder under the Century
Electronics folder and name it: Assignment 14 - Stored Procedures in Action. Place your
work from this chapter into this folder.

19.2 Creating a stored procedure synonym


When a DB2 Web Query synonym is created over a stored procedure, the result set is used
as the format for synonym. This means that all fields in the result set can be used as columns
in the report. In addition, the input parameters of the stored procedures can be used as input
parameters for the report. Consequently, you can pass parameter values from a report to the
stored procedure, let the procedure use those values to perform the business logic, and
return the results to the report.

19.2.1 Reasons you might use a stored procedure


The stored procedure is a powerful technique because it gives the report developer almost
complete programmatic control over what is returned to DB2 Web Query. Consider the
following ways that a stored procedure could be used with the tool:
 Reuse and repurpose the business logic in your existing programs.You can take an
existing RPG program (or one written in any language supported by the IBM i), make small
modifications to return a result set, and register it to the database as a stored procedure.
This means that many existing reports generated by RPG programs could be converted to
work with DB2 Web Query. Comment out the header lines and change the details line to
write to a result set, temporary file, or array, rather than a print file record. By combining
DB2 Web Query with existing report programs, you can salvage proven business logic and
provide a modernized output format for those old reports.
 Use native record level access (RLA), instead of SQL, if you prefer that method of data
access.
 Provide the ability to call to other programs, commands, and system APIs as well as pull
data from other system objects such messages queues, data queues, or data areas.

606

IBM i DB2 Web Query for i Implementation Guide

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

 Provide a way to dynamically change the library list by passing an input parameter to the
stored procedure (and changing the library list based on that parameter value), then
execute the appropriate process to return the result set.
 Adopt authority of the user profile that owns the underlying program or service program.
This gives you the ability to restrict access to the database objects and only allow users to
access the objects through the programs (stored procedures) with adopted authority.
 Provide auditing capability. The stored procedure can include logic to insert a row in an
audit log table to record any report request. With so much attention given to security and
auditing these days (that is, Sarbanes-Oxley), this can be very important consideration,
especially for users who have access to sensitive information.
 Provide the ability to programmatically change attributes of the querying job. Examples of
what can be specified in a stored procedure to change the environment are:
SET CURRENT DEGREE to enable Symmetric Multi Processing (SMP) and boost
query performance of a long-running report if the requestor is an executive or other
high-profile user.
SET OPTION SRTSEQ to change the collating sequence of the report.

19.3 Example of an HR-related stored procedure


To illustrate how a stored procedure could be used, lets assume that you need to create a
report that returns rows from a sensitive table (the HR table) and you must add an auditing
feature to this report. That is, each time the report is run, information such as the time stamp,
name of the report, and requesting user profile must be logged to an audit table.
To create a stored procedure that returns data from specific columns in the payroll table and
satisfies the auditing requirement take the following steps:
1. From an SQL interface such as System i Navigator Run SQL Scripts, create the audit
table:
CREATE TABLE rptaudlog (rpttimst TIMESTAMP, rptname CHAR(25),rptusrprf
CHAR(10))
2. From same SQL interface, create the stored procedure:
CREATE PROCEDURE hr_table_audit (inplantcode CHAR(3))
DYNAMIC RESULT SETS 1
LANGUAGE SQL
NOT DETERMINISTIC
MODIFIES SQL DATA
P1 : BEGIN
DECLARE c1 CURSOR WITH RETURN TO CLIENT FOR
SELECT lastname, firstname, status, payscale, salary
FROM hr
WHERE plantcode = inplantcode;
INSERT INTO rptaudlog VALUES(CURRENT TIMESTAMP,
'HR Salary Report', SESSION_USER);
OPEN c1 ;
END P1 ;
Several items must be pointed out for this stored procedure:
 The cursor is declared with the WITH RETURN TO CLIENT clause specified. It is a good
idea to specify this clause to ensure that the result set is returned to the client application.
WITH RETURN TO CALLER is the default, which would cause problems in the event
Chapter 19. Assignment #14: Stored procedures in action

607

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

that you had a nested stored procedure (a stored procedure called by another stored
procedure) that was actually returning the result set.
 The INSERT statement is specified to log the request. This satisfies the auditing
requirement.
 The cursor is opened (and left open). This returns a result set to the client application
(which is DB2 Web Query).

19.3.1 Creating the synonym for the stored procedure example


The process for creating a stored procedure synonym is similar to that of creating a synonym
over a table. Take the following steps:
1. Log in to Web Query.

Figure 19-1 DB2 Web Query login

2. From the web menu, right click and select Metadata then New from the drop down menu
for the folder area in which you wish to create metadata. This action will start a new
window for metadata selection.

608

IBM i DB2 Web Query for i Implementation Guide

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 19-2 Accessing create synonym

3. Expand Adapters Configured DB2 cli. Right click on *LOCAL and Create
Synonym as shown in Figure 19-3.

Figure 19-3 Creating stored procedure synonym

The Select Synonym Candidates for DB2 cli (*LOCAL) screen is displayed. You will
change the object type to Stored Procedure, specify the library and optionally a full or
partial object name (example: HR%) and click Next.

Chapter 19. Assignment #14: Stored procedures in action

609

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 19-4 Creating stored procedure synonym: Step 1

4. From the list of stored procedures displayed, select HR_TABLE_AUDIT, as shown in


Figure 19-5 on page 610.Click Next.

Figure 19-5 Creating stored procedure synonym: Step 2

If the stored procedure has input parameters, you will be prompted to enter a valid value
for the input parameter.
5. As demonstrated in Figure 19-6, specify a valid input parameter value by taking these
steps:
a. Check the INPLANTCODE parameter.
b. Specify ORL as the value for the input parameter. (This is a valid Plant Code value.)
c. Specify a Prefix value of _cen and click Create Synonym.

610

IBM i DB2 Web Query for i Implementation Guide

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 19-6 Creating stored procedure synonym: Step 3

Note: When the synonym is created, the stored procedure is called by DB2 Web
Query so that it can receive the result set. This is because it must store the format of
the result set in the synonym. Consequently, you must pass it a valid value for the
input parameter at this step.
d. As shown in Figure 19-7, a confirmation window is displayed to confirm that the stored
procedure synonym was successfully created.Press Next and Finish to close the
window. You are now ready to utilize this synonym in reporting.

Figure 19-7 Stored procedure synonym created

19.4 Creating a report using the stored procedure synonym


Once the stored procedure synonym for the procedure HR_TABLE_AUDIT is available, you
will use it to create a report. The function of the stored procedure is to add a row to an audit
table and return a result set from the HR table. This will allow an administrator to see who has
been reviewing the HR data.
Using the INPLANTCODE parameter from the stored procedure enables the result to show
the required plant information but will also require the user to know the plant identifiers. It will
be more user-friendly to prompt for possible plant values - presenting a drop down list of
plants to choose from. To enable this, we base the report on the PLANT table synonym which
contains the list of manufacturing plants. We then join this to the stored procedure synonym
using the plant code as the join field. If you did not want to provide a prompt control interface

Chapter 19. Assignment #14: Stored procedures in action

611

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

to the end user, you could simply build the stored procedure directly over the stored
procedure synonym and skip the join steps.

19.4.1 Starting Info Assist to create the report.


In this section you create a report over these two synonyms by taking the following steps:
1. Use Info Assist to create a new report in your Century folder.Right click the folder, select
New and Report from the menu.

Figure 19-8 Starting a new report

2. From the list displayed, select the CEN_PLANT synonym as shown in Figure 19-9 on
page 612 and then press OK. We start with the plant table because it has a list of all
possible plants within it.

Figure 19-9 Selecting synonym for the report

612

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch21.fm

The Info Assistant tool is displayed as shown in Figure 19-10. The tool employs a ribbon
menu. As you click on each of the various the top level menu items (Home, Format, Data,
Slicers, Layout, View) you will see different ribbon menus below the top menu line.

Figure 19-10 The Info Assistant work area

The default view of fields in your table will show the field names. By clicking menu item
View and selecting List rather than Logical, you will change the data area to contain
more detailed field information, including size as depicted in Figure 19-11.

Chapter 19. Assignment #14: Stored procedures in action

613

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 19-11 Expanded field information

19.4.2 Establishing the join between Plant table and stored procedure.
To join two tables or data sources within your report, do the following steps.
1. Click menu item Data then click Join.

Figure 19-12 Specifying joins

2. Clicking Join causes the Join dialog to appear as shown in Figure 19-13 on
page 615.Press Add New to view the list of available join objects.

614

IBM i DB2 Web Query for i Implementation Guide

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 19-13 The Join window

3. From the resulting list of possible data sources, select the CENHR_TABLE_AUDIT
synonym and press OK. The updated Join dialog now shows your two objects
CEN_PLANT and CENHR_TABLE_AUDIT but they are not yet joined.
4. To complete the join, drag the PLANTCODE from the left box to the right box as seen in
Figure 19-14 and drop it on the INPLANTCODE field, resulting in a connection arrow.

Figure 19-14 Joining two synonym objects

5. Click Ok

Chapter 19. Assignment #14: Stored procedures in action

615

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

Note: You may remove the join or optionally select the join type by right clicking the
connection arrow. The join details dialog is shown in Figure 19-15.

Figure 19-15 Optional join type dialog

19.4.3 Formatting the report.


Now that youve joined the tables, you can format the report. From the main screen of Info
Assist, you will see all the fields of the joined tables. Create the report by doing the following
steps.
1. Drag the desired fields to the canvas as shown in Figure 19-16. You will see actual data. If
the underlying table is large, you may be limited to only 500 records, which is the default.
You may change this value to smaller or larger on the Slicers ribbon.

616

IBM i DB2 Web Query for i Implementation Guide

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 19-16 Selecting fields for the report

2. Press the Run button to see your report. Looking at the resulting work area, notice that a
new tabbed window opens with the report output. When you scroll down this output, you
will see that you have not yet limited the output to a specific plant. Also, you may be
missing a couple of needed fields. Next youll add these fields and the filter function to
achieve the plant selection and complete your report. After pressing Run, your resulting
output window may still be open. Close the report result tab by right clicking on either of
the report tabs, located at the top or bottom, as show in Figure 19-17 on page 617 and
select Close. This returns your view to the interactive work area.

Figure 19-17 Report output

Chapter 19. Assignment #14: Stored procedures in action

617

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

3. Because the requested report is supposed to show the complete HR information, you also
need to add the Payscale and Salary fields which are under Measures in the data area.
Drag them to the Query area. You can hold shift to select both fields then drag and drop
them on top of the Status field. This will add these fields after Status. Your result should
look as in Figure 19-18 on page 618

Figure 19-18 Placing additional fields on the report

4. Locate the Plant Code in the list of fields under the Data area and drag this field to the
Filter area. Notice that a popup filter dialog results as seen in Figure 19-19.

618

IBM i DB2 Web Query for i Implementation Guide

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 19-19 Filter dialog

5. Create a new input parameter to the report by selecting Prompt, as shown in Figure 19-20
on page 619 and pick Prompt using Data Values (Dynamic) from the drop down menu.

Figure 19-20 Selecting prompt type

6. After picking the prompt type, you will want to change the prompt seen by the user at run
time. Type over the prompt field, changing the value from PLANTCODE to Plant Code:
as shown in Figure 19-21. This will create a heading and drop down list in your report
enabling the user can select the desired plant code.Press OK to exit the filter dialog.

Figure 19-21 Modifying run time prompt dialog text

Chapter 19. Assignment #14: Stored procedures in action

619

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

7. The filter area now contains the appropriate code to cause record selection by the plant
parameter as shown in Figure 19-22 on page 620. The user will see a drop down list of
Plants and selection of one will cause the resulting report to be limited to that single plant.

Figure 19-22 Completed filter

Tip: Should circumstances require it, you can easily change from a single selection prompt
to multiple selection. In this example, it would enable the user to report on one or more
plants. The change filter dialog to do this is shown in Figure 19-23

Figure 19-23 Multiple selection option

8. Run the completed report, with selection by a single Plant and verify your results. When
you select Plant Code ORL and press Run icon, the result should look like the image in
Figure 19-25 on page 621. The run icon looks like Figure 19-24.

Figure 19-24 The RUN icon in Info Assist

620

IBM i DB2 Web Query for i Implementation Guide

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 19-25 Completed report from stored procedure with Plant code selection

19.4.4 Saving your report based on a stored procedure.


Now that you have a completed report, save it using the following steps.
1. Save your report in your folder, using the name 14a - Stored Procedure Report
Stored procedures offer a powerful technique and the ability to return data via a result set but
appearing to Web Query as any other data source.

Chapter 19. Assignment #14: Stored procedures in action

621

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

19.5 An example of a Input parameter stored procedure in RPG


Another example of how a stored procedure could be used entails the use of an ILE RPG
program to parse input parameters to simplify entry. Rather than have the user pick an entry
from a drop down list containing many entries, this optional allows the knowledgeable user
could instead give a list of codes, numbers or words, separated by a delimiter. This quick
entry technique would not be possible unless some intelligent program was in between the
input string and the SQL statement execution. In this case, RPG enables this easily.
In the following example, we will create an RPG program to parse an input string, encapsulate
the programs business logic with a stored procedure and then use the stored procedure to
feed a report in DB2 Web Query. The program will parse a string of country names, entered in
the format: Country1, Country2, Country3, Country4. After extracting the parameters, the
procedure will return a result set from the database for the selected countries. The RPG
program actually builds the SQL statement WHERE logic using COUNTRY IN (list of
countries) to retrieve the results. While this is a simplified example, it provides a scenario
which is typical of something that many RPG shops could use whenever critical business
logic already exists in RPG and a result needs to be returned via SQL to the consuming
application.

To create this example, do the following steps:


1. Enter the following ILE RPG code into source member MULTINPARM of QRPGSRC in
QWQCENT library using RDP or another favorite source editor:
H option(*srcstmt : *nodebugio)
// This works like *ENTRY PLIST
D multInParm
pr
ExtPgm('MULTINPARM')
D inputParm
200a
D multInParm
pi
D inputParm
200a
D tick
S
1a inz('''')
D sqlStm
S
2048a
D whereClause
S
1600a
D country
S
15a
D countryList
S
1500a
D sepChar
S
1a
D begPos
S
5i 0
D endPos
S
5i 0
/free
select;
when inputParm = *blanks;
return;
when inputParm = 'ALL';
whereClause = *blanks;
other;
// Build CountryList variable
sepChar = ',';
countryList = *blanks;
begPos = 1;
dow 0 = 0;
endPos=%Scan(sepChar: inputParm : begPos);
if endPos = 0;
// Get last entry in comma separated list

622

IBM i DB2 Web Query for i Implementation Guide

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

if %len(%trim(inputParm)) > 0;
country = %Subst(inputParm : begPos:
%len(%trim(inputParm))-begPos+1);
countryList = %trim(CountryList) + ' ' +
tick + %trim(country) + tick;
endif;
leave;
endif;
country = %Subst(inputParm : begPos: endPos-begPos);
countryList = %trim(CountryList) + ' ' +
tick + %trim(country) + tick + ', ';
if %len(%trim(inputParm)) < endPos + 1;
leave;
endif;
begPos = endPos + 1;
enddo;
whereClause = 'WHERE country IN (' + %trim(countryList) + ')';
endsl;
sqlStm = 'SELECT * FROM qwqcent/stores ' +
%trim(whereClause);
exec sql close c1; //make sure not open from prv call
exec sql prepare s1 FROM :sqlStm;
exec sql declare c1 cursor FOR S1;
exec sql open c1;
return;
2. Compile the program with the command:
CRTSQLRPGI OBJ(QWQCENT/MULTINPARM)
SRCFILE(QWQCENT/QRPGLESRC)
COMMIT(*NONE)
3. From an SQL interface such as System i Navigator Run SQL Scripts, create the stored
procedure with this statement:
CREATE PROCEDURE QWQCENT.MULTINPARM ( IN INPUTPARM CHAR(200) )
DYNAMIC RESULT SETS 1
LANGUAGE RPGLE
SPECIFIC QWQCENT.MULTINPARM
NOT DETERMINISTIC
READS SQL DATA
CALLED ON NULL INPUT
EXTERNAL NAME 'QWQCENT/MULTINPARM'
PARAMETER STYLE GENERAL ;
Several items must be pointed out for this stored procedure:
 Language RPG tells SQL that the program behind the procedure is written in RPG.
 External name tells the procedure where to find the RPG program which is being
encapsulated in the procedure.
 The cursor is opened (and left open). This returns a single result set to the client
application (which is DB2 Web Query).

Chapter 19. Assignment #14: Stored procedures in action

623

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

19.5.1 Creating the synonym for the MULTINPARM stored procedure


The process for creating this stored procedure synonym is identical to what you have used for
other synonyms and the procedure in the preceding section. Take the following steps:
1. Log in to Web Query.
2. From the web menu, right click and select Metadata then New from the drop down menu
for the folder area in which you wish to create metadata. This action will start a new
window for metadata selection.
3. Expand Adapters Configured DB2 cli. Right click on *LOCAL and Create
Synonym.
4. The Select Synonym Candidates for DB2 cli (*LOCAL) screen is displayed. You will
change the object type to Stored Procedure, specify the library and optionally a full or
partial object name (example: MULTI%) and click Next.
5. From the list of stored procedures displayed, select MULTINPARM, then Click Next.
Because this stored procedure has input parameters, you will be prompted to enter a valid
value for the input parameter. Specify a valid input parameter value by taking these steps:
a. Check the checkbox on the INPUTPARM line.
b. Type Germany to satisfy the requirement for a character parameter.
c. Add a the prefix value cen_ then click Create Synonym.
Note: When the synonym is created, the stored procedure is called by DB2 Web
Query so that it can receive the result set. This is because it must store the format of
the result set in the synonym. Consequently, you must pass it a valid value for the
input parameter at this step.
d. The confirmation window is displayed to confirm that the stored procedure synonym
was successfully created. You are now ready to utilize this synonym in reporting.

19.5.2 Creating the report from the MULTINPARM stored procedure synonym
Once the stored procedure synonym for the procedure MULTINPARM is available, you will
use it to create a report. The function of the stored procedure is to parse the input parameter,
locate the several country names, extract them and build an SQL statement to select from the
Stores table using a WHERE clause with IN containing the list of the country names. The
procedure will then execute the statement and return the result set to DB2 Web Query.
DB2 Web Query prompting will automatically provide an input field where the user can enter
several country names, separated by commas. When the Run button is pressed, the relevant
country data will be returned and displayed.

19.5.3 Using Info Assist to create the report.


In this section you create a report using the synonym for the stored procedure by completing
the following steps:
1. Use Info Assist to create a new report in your Century folder.Right click the folder, select
New and Report from the menu.
2. From the list displayed, select the CEN_MULTINPARM synonym as shown in Figure 19-26
and then press OK.

624

IBM i DB2 Web Query for i Implementation Guide

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 19-26 Selecting synonym for the report

The Info Assistant tool is displayed as shown in Figure 19-27. Using the menu to change
the View option from Logical (the default) to List, will enable you to see the input and
output parameters for the stored procedure.

Figure 19-27 The Info Assistant work area in List mode

Chapter 19. Assignment #14: Stored procedures in action

625

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

19.5.4 Formatting the report.


1. Drag the INPUTPARM field to the Filter area, generating the filter show in Figure 19-28.
Set this field to receive input from a simple text area (as opposed to dynamic data which
we have used in many examples). This is because the user will simply type free-form text
into the input when prompted.

Figure 19-28 Filtering the report input based on the procedures input parameter

2. Drag Storename, Country, Region and State to the By area of the Query or to the canvas.

626

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch21.fm

Figure 19-29 Selecting the report output

3. After dragging the fields, notice that unlike previous design examples, rather than seeing
data formatted on the design canvas, you see an error message (Figure 19-30). At this
time, this is an expected message given the way the tool handles a stored procedure
during design. When you run the procedure, however, even with null input, the system
handles the procedure call as expected. So this message can be ignored at design time. If
you look at the By area, the fields are visible there. Check your field sequence in the By
area.

Chapter 19. Assignment #14: Stored procedures in action

627

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 19-30 Field specification

4. Press Run in the designer to execute the report, see input parameter prompting. Enter the
name of two countries with the comma delimiter and press Run. Notice that in this
example, the user spelled the country name German not Germany. Therefore the result
set output included only France.

Figure 19-31 User parameter testing

628

IBM i DB2 Web Query for i Implementation Guide

8063ch21.fm

Draft Document for Review August 30, 2013 2:37 pm

5. After resolving the spelling issue for Germany, the result is as expected.This was a user
parameters entry error and not a programming error in this instance. The RPG-based
stored procedure is working to find.

Figure 19-32 Satisfactory results returned for quick input procedure

6. Save the report in the folder as 14b - Multiple Input Parms Separated by Comma
7. Publish your report so that other authorized users can run it

Chapter 19. Assignment #14: Stored procedures in action

629

8063ch21.fm

630

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ch22.fm

20

Chapter 20.

Assignment #14: Query/400


Modernization
In this chapter, we discuss the similarities and differences between Query/400 and DB2 Web
Query, common uses for Query/400 and how DB2 Web Query can maintain that same
functionality. In addition, we show how to create metadata from your QRYDFN objects so that
DB2 Web Query can run your existing queries.
We also introduce the idea of replacing multiple Query/400 definitions with new web query
reporting capabilities and introduce complex reporting using the HTML Composer feature of
Web Query Developer Workbench.
Prerequisites:
Before doing the examples related to Developer Workbench, it is advised to complete the
earlier chapters on Documents and Dashboards.

Copyright IBM Corp. 2012. All rights reserved.

631

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

20.1 Query/400: a reliable reporting tool


By now you understand that DB2 Web Query is the intended replacement for Query/400. This
does not to imply that familiar commands such as WRKQRY and RUNQRY are going away,
but rather that the product Query/400 is going away. You can still use older, yet robust,
technologies that have stood the test of time and are useful to your business. It is likely that
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 you changing
or running a conversion process on the QRYDFN object. You only must create metadata on
the QRYDFN object like you do 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, DB2 Web Query also
performs the output option that is defined in the QRYDFN.
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. After the metadata is created, DB2 Web Query treats table and
QRYDFN metadata in the same way.

20.2 DB2 Web Query versus Query/400: function similarities


In the following list we summarize how DB2 Web Query and Query/400 have the same
functionality:
 Report appearance: Based solely on report appearance, a basic user is unable to tell if the
report that is running is based on a DB2 object or a QRYDFN object. The information and
appearance of both final reports based on QRY/400 metadata versus DB2 file metadata
are identical.
 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 might 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 allows
all your reports developed in DB2 Web Query to be used in your batch jobs.
 Right Outer Join: RUNQRY does not support Right Outer Joins and neither does DB2
Web Query.

20.3 DB2 Web Query versus Query/400: function differences


In this section, we discuss the functionality that Query/400 has that DB2 Web Query does not
have. In all cases, the limitations are explainable and work a rounds are provided.

20.3.1 Parameter passing


It 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 20-1 shows how this is used. Then the
632

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

QRYDFN object is called by using the STRQMQRY ALWQRYDFN (*YES) command, which
prompts the user for parameters.

Figure 20-1 QRYDFN with parameters

As noted earlier in this chapter, DB2 Web Query sends the RUNQRY command to the server.
It does not send any version of STRQMQRY. This limitation means that QRY/400 queries that
were coded for use as STRQMQRY ALWQRYDFN(*YES) to allow parameter input must
instead use the DB2 Web Query parameter passing. First, you must change your QRYDFN
object to not accept parameters. After you create the metadata, you can use InfoAssist to
code the parameters into the selection criteria.

20.3.2 Using output files for the next query


It is common to use RUNQRY outfile results for use in the next RUNQRY. One of the main
reasons for doing this chaining was to do multiple levels of grouping, aggregation, and sub
totaling. With DB2 web query you can do all these operations without having to do chaining.
Even though DB2 Web Query does not need to do chaining to perform grouping, aggregation
and Sub totaling, it is possible to send the output of a report to a database file. To do this you
must first create metadata on the intermediate output files.
The metadata is hardcoded only with a 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 must 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 from the work files. When the job is
done, the work files are deleted. The next time that 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 successfully runs the report. DB2 Web Query does not know
that 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 cannot create metadata on any object in QTEMP. Therefore, the
intermediate file must be in a different library. Then the metadata can be created. If you
cannot change your work files to be in the QTEMP library, you will be unable to do query
chaining. If you change your work files from QTEMP to another library, be mindful to change
your program to delete the work files.
In summary, 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 must be
recreated.

Chapter 20. Assignment #14: Query/400 Modernization

633

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

20.4 The Assignment


Century Electronics has approximately 7,000 *QRYDFN objects on their production server.
Not all of them are used - in fact the majority of them have not been updated or even run in
years. You could certainly use the Query/400 adapter to bring all of these queries into DB2
Web Query. However, you would of course end up with over 7,000 DB2 Web Query reports which is probably not want you want. Executive Dan realizes that many users still use some of
these query objects, so he doesnt want you to simply discard them. Rather he would like for
you to bring some of the more popular ones into DB2 Web Query - but he would also like for
you to take a long term approach to query modernization and look at ways to simplify this
reporting environment - particularly from a report maintenance perspective.
In this assignment you will do both: you will use the Query/400 adapter to link to existing
query objects. You will also look at ways to reduce the number of queries by using
technologies like highly parameterized reporting, InfoMini, and Active Reports. These
features provide end users with the flexibilty to define the data that they want to retrieve and
the ability to customize the output format so that it is presented the way the want. By adopting
this approach, a single DB2 WebQuery report can replace dozens (in some cases even
hundreds) of Query/400 reports.

20.5 Creating metadata over Query/400 objects


Just as DB2 Web Query requires metadata to read from DB2 files, it also requires metadata
to read from Query/400. When creating metadata on QRYDFN objects, you must remember
to complete a few extra windows, otherwise the metadata creation will not be complete.
As noted earlier, if you change the format of your underlying files, you must recreate 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 runs the query at that time. This is
because it is gathering information about the files and columns that were used in the query
output. For this reason, the processing of creating metadata on a Query/400 object can be
somewhat longer than on a DB2 table.
DB2 Web Query asks 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. In the following
steps we explain the process for creating Metadata for Query/400. There are two additional
windows for creating metadata on a Query/400 object versus on a DB2 object. Remember to
click Next until you no longer see one.
To create Metadata for Query/400
1. Right Click Century Electronics Folder and click New Folder.

634

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 20-2 Creating a Folder

2. In the New Folder dialog box for tittle type: Assignment 15 - Query/400 Modernization
and click OK

Figure 20-3 Create New Folder dialog box

3. Right click Assignment 15 - Query/400 Modernization folder. From the list presented
select Metadata and then edit.

Chapter 20. Assignment #14: Query/400 Modernization

635

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 20-4 Creating Metadata

4. In the next Window Click on Adapters. Right click the Query/400 adapter and then click
Create Synonym

Figure 20-5 Selecting the Adapter

636

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch22.fm

5. In the Create Query Synonym for Query/400 step 1 of 2 pane (Figure 20-6), enter the
library where the QRYDFN object resides. In this case we enter the QWQCENT library. Click
Submit.

Figure 20-6 Creating a Synonym

6. In the Select Synonym candidates for Query/400 Step 2 of 2 pane (Figure 20-7),
complete these steps:
a. Select the Query/400 object on which you want to create metadata. For this
assignment we select REVGPFTQRY.
b. For Prefix type: qrydfn_
c. Click Create Synonym.

Figure 20-7 List of QRYDFN objects

Chapter 20. Assignment #14: Query/400 Modernization

637

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

7. In the Create Synonym for Query/400 Status pane (Figure 20-8), if synonym creation was
successful, you see a status of Create successfully. Click Next.

Figure 20-8 Created successfully status message

8. In the Create Synonym for Query/400 File: Save Reports pane (Figure 20-9), notice the
Report Name column. Click Next.
This is the last pane on which you must click Next. DB2 Web Query creates a report from
your QRYDFN.

Figure 20-9 Final confirmation window: Creation Synonym for Query/400

638

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

9. In the Create Synonym for Query/400 File: Save Reports Status pane (Figure 20-10),
notice that the status indicates Created successfully for the Query/400 metadata
creation. Close this window by pressing the Finish button.

Figure 20-10 Created successfully message: conversion from Query/400 to DB2 Web Query

Close the create synonym window and go back into your Assignment 15 - Query/400
Modernization folder, notice that the metadata is already created as a report
qrydfn_REVGPFTQRY. You can click this report to run it. You can also right-click it 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 Defining Metadata. Keep in mind that after metadata creation, you will be unable to tell
whether the underlying object is a DB2 table or a QRYDFN. You might want to add a prefix or
suffix that can help you to identify that the object being queried on the server side is a
QRYDFN.

20.6 Using DB2 Web Query to edit a QRYDFN


After you create metadata, DB2 Web Query understands the metadata as a result set. You
can use DB2 Web Query to edit, sort, and filter the report, but you can only work within that
result set. You cannot add new columns to the report, even if the column is from a table that is
used in the report. DB2 Web Query, in effect, sees the Query/400 result set as any other
table. In previous chapters we learned the difference between compute and define fields.
Since compute is data manipulation done on the client side, you can still use compute on your
Query/400 reports. However, the define operation is data manipulation performed on the
server side. Therefore, you are unable to do this when editing a Query/400 object. Currently
bad data is returned and might change into an error message instead.
If you edit the report from DB2 Web Query, those changes are not reflected in the QRYDFN
object. When editing a Query/400 report that contains a join, you can add a new join with DB2
Web Query. However, you will be unable to edit the joins already defined in Query/400.

Chapter 20. Assignment #14: Query/400 Modernization

639

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

20.7 Modernizing Query/400 definitions


In this assignment we are required to replace four related QRYDFN objects using one DB2
web query report. We are also required to enhanced the report using InfoMini and Active
Reports.
 The first QRYDFN object REVGPFTQRY produces a basic summary report that shows
revenue by product Category

Figure 20-11 Revenue by Product Category

 The next two QRYDFN objects (CHAINQRY1 and CHAINQRY2) are used to create a
summary report that shows Gross Profit Margin by Product Category.
CHAINQRY1creates an output file in QTEMP that it is used as an input file for the second
QRYDFN object (CHAINQRY2). This chaining was used to be able to calculate Gross
Profit Margin.
.

Figure 20-12 Gross Profit Margin Report

The last QRYDFN objects (PARMQRY1) accepts an input parameter at run time. In our
example it is using PRODTYPE as input parameter.

Figure 20-13 Product Category Report providing Camcorders as input parameter

For executive Dan this is a complex process as he does not have much experience with the
IBM i platform. Our challenge is this assignment is to consolidate these Query/400 definitions
in one web query report and make it available to executive Dan via web browser and on his
mobile devices.

640

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

20.7.1 Building the initial report.


We begin by building the first query/400 report that it is displaying Product Category, Product
Type, Revenue and Gross Profit. For this assignment we are using the Logical view of the
Data pane.
1. Sign onto DB2 Web Query
2. Expand Century Electronics Top Folder. Right-click Assignment 15 - Query/400
Modernization Folder, From the list presented select New and then Select Report.
3. From the Select a data Source dialog box select cen_orders and click OK.

Figure 20-14 Selecting a Data Source

4. From the Data pane drag the Product Category and Product Type to the By Field
category in the Query Design Pane.
5. From the Data Pane drag Revenue, and Profit to the Sum field container in the Query
Design Panel. Your report should look similar to Figure 20-15

Chapter 20. Assignment #14: Query/400 Modernization

641

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 20-15 Setting fields and measures

We have finished modernizing the first Query/400 definition. Now we need to add to our
report the gross profit margin field. Remember that we are using Chainqry1 and Chainqry2 to
accomplish this task in Query/400 but this is not necessary in DB2 web query.
6. From the Data pane drag the Margin field to the Sum field container. This field was
defined in the Metadata in previous chapters.
7. Run your report. It should look similar to Figure 20-16

642

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 20-16 Final Report Definition

Up until this point we have consolidated the first three QRYDFN objects in one web query
report. Now we need to make sure that we are able to run this report and select specific
Product categories or product types.There are different ways to accomplish this but for this
assignment we are going to use InfoMini.
You have the option to activate InfoMini when you create a report in InfoAssist. InfoMini
contains a subset of InfoAssist functionality available at run time. In other words, by using
InfoMini we can provide the user the option to interact with the report at run time.
To active InfoMini use the followings steps:
1. Click the Format tab and then click InfoMini (Figure 20-17).

Figure 20-17 Activating InfoMini

You can limit or expand the functionality that is available to the user at run time when you are
using InfoMini as explain in chapter 12.
2. Click the Drop down list menu next to the InfoMini button to see available options. Leave
the defaults and continue to the next step.

Chapter 20. Assignment #14: Query/400 Modernization

643

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 20-18 Limit or expand InfoMini functionality

3. From the report that we just created click the Slicers tab.
4. Select Product Category from the Data Pane and drag it to Group 1 ribbon.

Drag fields here to


create slicers

Figure 20-19 Adding Slicer Category

5. In the options Ribbon click New Group

Figure 20-20 Adding New Slicer Group

6. Select Product Type from the Data Pane and drag it to the new created Group 2 ribbon.

Figure 20-21 Adding Slicer Category

7. Click the Format tab and change the report output format from HTML to Active Report on
the Output Types ribbon.

644

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 20-22 Changing Output Format to Active Report

8. Save your report as A15_RPT01


9. Run your report. Notice that this time a new window is open
10.Click the Slicers Tab. Click the Product Type drop down menu, select Camcorders and
then Click OK.
11.Run your report and compare the values with the ones in Figure 20-23. The values in both
reports should be the same.

Figure 20-23 Runing Report with input parameter

12.On the Options Ribbon click the Clear Slicers button and run your report again.
13.Our Final step is to send the report by e-mail. Click the Drop down menu next to Product
Category. From the list presented click Send as e-mail

Note: This option will only be available if you are using Internet Explorer. ActiveX Settings
need to bet set correctly for this to work.

Chapter 20. Assignment #14: Query/400 Modernization

645

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 20-24 Sending a report as an E-mail

14.A dialog box pops up requesting some information. Leave the defaults and click Save
Report

Figure 20-25 Temporary report saving

15.Assuming that you have an e-mail account configure in your computer a new e-mail
window will show up with the Active Report attached to it. Write the e-mail address and
send the e-mail.
As a final step we need to publish the report.
16.Right click folder Assignment 15 - Query/400 Modernization and click Publish.
17.Right click report A15_RPT01 and click Add to Mobile Favorites.

646

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

20.8 The Migration dilemma for Query/400 reporting


This section discusses the approaches to implement highly parameterized reporting. This is
one way to provide high-function DB2 Web Query reports to replace legacy reporting
environments.
As previously mentioned, DB2 Web Query is positioned as a replacement for Query/400 and
offers not only similar basic reporting functions, but the ability to slice-and-dice data in a way
that Query/400 cant match. The web presentation, graphics and mobile capabilities, which
DB2 Web Query makes easy, allow users to visualize data and make business decisions like
never before. The web and mobile presentation layers address reporting capabilities that
most modern enterprises desire for their knowledge workers with mobile devices.
If you were a user of the Query/400 product, you may have experienced heavy usage of the
product. At some clients, hundreds of queries exist, written by many users and utilizing many
different files. In almost all cases, there is some overlap of query function and file usage.

20.9 Modernizing your reporting


As with many such changes that impact IT, the goal isnt simply to convert your Query/400
objects to Web Query. Its much better to determine the current reporting needs and figure out
a more modern way to approach the task. In prior chapters, we discussed dashboards and
other compound documents. Web Query provides the capabilities to develop reports that are
more responsive than Query/400 reports.
Consider the case of a shop where users have been creating Query/400 reports for 10 or
even 20 years. One of the challenges will be to convert the necessary queries, maintain
business reporting requirements without re-creating redundancies that may exist. Query/400
was exceptional in its day, but with the addition of web-based reporting, graphics and OLAP
processing, a single DB2 Web Query report might replace the function of numerous
Query/400 objects.
One way to approach the migration is to use DSPPGMREF command to generate an output
file of query references to files. This would enable you to determine all the queries that used
the same files. To further analyze the fields used in each query, you could convert each query
from Query/400 object to SQL source code, using the RTVQMQRY command. This
generates a source member with the equivalent SQL for the subject query. No doubt, with
some work, you could write additional queries or SQL to review these files and have some
ideas which queries to tackle first or which queries are similar or redundant.

20.9.1 IBM offering for Query Modernization


If you feel the task of migrating your query objects is a daunting challenge, IBM Services has
an offering to assist you with the process. Consisting of a set of tools to discover, analyze and
migrate Query/400 objects, this offering brings these additional tools and IBMs expertise to
the process.

20.10 Replacing Query/400 objects with Active reports


This section discusses an example of a single, highly parameterized, active report. This type
of report is typically developed by IT but, in this case, is often deployed to business analysts
Chapter 20. Assignment #14: Query/400 Modernization

647

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

or disconnected users who want to highly segment the data that they are analyzing. This
tutorial assumes that you have completed the Active Reports tutorial and understand those
concepts. Here we take an existing active report and initiate it from an HTML page that
contains a large number of input parameters in a user friendly manner.
Such a report might be used to incorporate data to eliminate one or more Query/400 reports
in the web-based environment.

20.10.1 Highly parameterized report development


In this exercise, using an active report that we created previously as 3g Active Report
Revenue and Profit Report, we will now add multiple parameters to it. This allows a user to
segment the data that he wants to analyze in different ways. Although we base this tutorial on
an active report, we can invoke any report or graph. This highly parameterized technique is
effective for subsetting the data that a user wants to download to Excel.
This exercise uses a report named 15a - Active Report Revenue and Profit Report, which
is simply a clone of the previous 3g report with a few changes. The changes to 3g to get 15a
are as follows:
1.
2.
3.
4.
5.

Open 3g Active Report Revenue and Profit Report


Remove the Product Name field
Add the CostofGoodsSold column
Add subtotals by Product Type for the numeric columns
Add traffic lighting on the Gross Profit column for color change to green when the value is
above $40M.
6. Save this report in your Century Electronics folder under subfolder Assignment 15 Query400 migration.
With these changes, your report should resemble that shown in Figure 20-26 on page 649.
You might want to quickly run this report and make sure that it looks like the example in
Figure 20-26 on page 649.

648

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 20-26 Gross Profit active report

To add the parameters to this report, do the following:


1. Open the report in Info Assist called 15b Active Report Revenue and Profit Report
2. From the Data area, one by one, select each of the field names shown in Table 20-1 below
and either drag it to the filter area or right-click each and select Filter from the menu.
Based on this table, all the conditions are WHERE conditions. The table shows the field
name to drag to the Filter pane and the condition to use. For all parameters, click Select
values. In all fields but ORDERDATE, select prompting for Dynamic values. In the
Dynamic pane, choose Select multiple values. Then click OK.
Table 20-1 Parameters for WHERE conditions
Field name

Condition

Select values

WHERE

PRODUCTTYPE

EQUAL to





Select parameter.
Dynamic data values prompting.
Select multiple values.

WHERE

PRODUCTCATEGORY

EQUAL to





Select parameter.
Autoprompt.
Select multiple values.

WHERE

SALESREP

EQUAL to





Select parameter.
Dynamic data values prompting.
Select multiple values.

Chapter 20. Assignment #14: Query/400 Modernization

649

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

Field name

Condition

Select values

WHERE

COUNTRY

EQUAL to





Select parameter.
Dynamic data values prompting.
Select multiple values.

WHERE

REGION

EQUAL to





Select parameter.
Dynamic data values prompting.
Select multiple values.

WHERE

STATE

EQUAL to





Select parameter.
Dynamic data values prompting.
Select multiple values.

WHERE

PLANTNAME

EQUAL to





Select parameter.
Dynamic data values prompting.
Select multiple values.

WHERE

ORDERDATE

GREATER
THAN or
EQUAL to




Select parameter.
Enter field name From_Date under
Parameter (do not autoprompt).
See Figure 20-28 on page 651.

WHERE

ORDERDATE

LESS THAN or
EQUAL to




Select parameter.
Enter field name To_Date under
Parameter (do not autoprompt).

Figure 20-27 Sample of Filter for Multi-select DB values

3. For the date fields, instead of using the dynamic data prompt, you need to set up a range
based on a value at run-time. This requires the Advanced Filter prompt shown in
Figure 20-28 on page 651. We use From_Date for the first date parameter and To_Date
for the second date parameter.

650

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 20-28 Advanced Filter editing for date range and others

The finished Selection criteria pane should look like the example in Figure 20-28 above,
with each parameter allowing multiple selections and the order date fitting in a range. If
you run this report, you should see a prompt screen for all these variables.

Chapter 20. Assignment #14: Query/400 Modernization

651

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 20-29 Select parameters for multi-select and date range

4. Save and close the report.

652

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

20.10.2 Creating the report in HTML Composer


To create the report in HTML Composer:
5. Navigate to the Century Electronics folder in Developer Workbench. Drill down to the
Assign 15 level and right-click the folder, selecting New HTML File (Figure 20-30).

Figure 20-30 Creating a new HTML file

6. In the window that opens (Figure 20-31), enter a report name of


15c_HighlyParmedDocument and click Create.

Figure 20-31 New report name

Chapter 20. Assignment #14: Query/400 Modernization

653

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

7. In this example, we create an HTML page that contains the various parameters and a Run
button. When the Run button is clicked, a new window opens that contains the active
report. We must import the report onto the HTML page so that DB2 Web Query
automatically brings in all the parameters that are defined in the report, saving us from
adding them manually. We remove the report frame itself after we import all the
parameters.
Click the report icon (circled in Figure 20-32) and draw a small box in the upper left corner
of the pane.

Figure 20-32 Importing a report

8. Right-click the report (the box that you just drew) and select Reference existing
procedure and select the active report (Figure 20-33).

Figure 20-33 Link to existing procedure

9. Select the report that you just created.

654

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

10.You are presented with a list of parameters that are referenced by this report
(Figure 20-34).
a.
b.
c.
d.
e.

For SALESREP, change the control type to Double list control.


For COUNTRY, change the control type to Radio button.
For PLANTNAME, change the control type to Check box.
For both dates, change the control type to Calendar.
Under Parameter grouping options, select Do not create a form.

Figure 20-34 Selecting the parameter control types - Before (left), After (right)

11.Press OK, to proceed.

Chapter 20. Assignment #14: Query/400 Modernization

655

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

The system lays out all the chosen parameters in on the canvas, but probably not the way
we would want them. Figure 20-35 shows the form controls partially arranged. Move the
Run button that was generated up to the top of the page.

Figure 20-35 Imported parameters partially arranged

656

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

12.When moving the controls, make sure that you keep the headings and controls together.
Drag the parameters into a layout similar to Figure 20-36. You may need to scroll to see
the entire page of parameters. See the following steps to size the Country control box.
Make sure that you leave enough room at the top of the report for a report heading.
Some of the boxes, such as SALESREP, require resizing. Keep any frames that are
within a panel in the panel when they are moved or resized.

Figure 20-36 Rough layout for parameters

Note: This exercise is designed to introduce you to many of the controls and
capabilities of HTML Composer. It is not intended to teach window design. Do not
design a window that has this many different controls and looks like this in production
applications.

Chapter 20. Assignment #14: Query/400 Modernization

657

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

13.We want to change Country from one column widths to two columns widths
(Figure 20-37):
a. Highlight the Country control box.
b. From the Properties pane, select columns and type 2.
c. Size the control box appropriately.

Figure 20-37 Two-column radio control box

20.10.3 Parameter controls


In this section we illustrate how to define the sequence in which the cursor moves from cursor
to cursor, also known as parameter controls:
14.Highlight the Producttype control box.
15.In the Properties pane on the right, select Tab index and enter 1. The Tab index controls
the sequence in which the cursor moves from field to field.
16.Also as part of the properties pane in the Properties and Settings where you can override
options such as your type of control box or the text to go with the ALL option. Click
Parameters tab and right click one of the control box, select Properties and Settings
as shown in Figure 20-38 on page 659. Select the add ALL option for every parameter
except the dates.

658

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 20-38 Properties and settings

Chapter 20. Assignment #14: Query/400 Modernization

659

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 20-39 Adding ALL via control Properties and settings in Workbench

17.Highlight the Productcategory control box.


18.Click the Properties tab (Figure 20-40) and under Tab index, enter the value 2.

Figure 20-40 Properties tab

660

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

20.10.4 Chaining the controls together


We want to set up our parameters so that the value selected for product type modifies (filters)
the values that are displayed in the product category drop-down list:
19.Click the producttype control box. Holding down the Shift key, also select
Productcategory.
20.Click the Add chain icon (highlighted in Figure 20-41). This function chains the parameters
together in the sequence in which you selected them.
Tip: If you right-click a control box that is chained to another control, you can override
the chaining logic. The default in our example shows all product categories that have a
product type equal to what the user selected. You can choose any relationship to the
controlling parameter, which is less than, greater than, and so on. In our example,
EQUAL is really the only choice that makes sense and it is always the default.

Figure 20-41 Chaining parameters

21.Highlight the Salesrep control. In the Properties pane, for Tab index, type 3.
22.Highlight the Country control. In the Properties pane, for Tab index, type 4.
23.Highlight the Region control. In the Properties pane, for Tab index, type 5.
24.Highlight the State control. In the Properties pane, for Tab index, type 6.
25.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:
a. Select the Country control box.
b. Hold down the Shift key and select the Region control box. Still holding down the Shift
key, select the State control box.
c. Click the Add chain button shown in Figure 20-41.
26.Highlight the Plantname control. In the Properties pane, for Tab index, type 7.

Visual representation of Chaining.


Before leaving the topic of chaining controls, please notice that at the bottom of the
workbench designer, there are several tabs; Design, Parameters and Embedded Javascript.
Viewing the parameter tab shows how the controls on the page have been linked. Switch from
the Design tab to the Parameters tab, to see this view as shown in Figure 20-42 on page 662.
Finally, using the Javascript tab would enable coding to further control data entry on the page.

Chapter 20. Assignment #14: Query/400 Modernization

661

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 20-42 Visual Parameter Chain view

20.10.5 Using calendar controls


In this section we illustrate how to define the controls when dealing with Date fields:
27.Right-click the calendar icon under From_Date and select Calendar Properties.
28.For Date range, select Static. Specify a range from January 1 2012 to July 26 2012. For
Date format in data source, select YYMD. Click OK. See Figure 20-43.
29.Highlight the From_Date control.
30.In the Properties pane, for Tab index, type 8.
31.Repeat these calendar control steps for To_Date using a Tab index of 9.
Tip: The more common calendar option is probably relative dates, for example, within
the last two years. Since our data only contains dates in 2011 and 2012 we chose the
static dates for this example.Calendars can also default the date field to todays date if
required.

662

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch22.fm

Figure 20-43 Calendar controls

32.Right-click the Run report1 button control and select Hyperlink Properties.

Chapter 20. Assignment #14: Query/400 Modernization

663

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

33.In the Hyperlink Properties window (Figure 20-44), complete these steps:
a. Change Display Text to Run Report.
b. Change Target Type to Window and Target to New Window. This runs the report in a
new window instead of in the frame drawn on the current HTML page.

Figure 20-44 Hyperlink properties Run Report

34.Delete the original frame that you drew when importing the report. It is located below all
the parameters.
35.Select the RUN control box. In the Properties pane, for Tab index, type 10.
36.Resize the Run button by dragging the frame.
37.Add a heading to the report:
a. Click the text icon on the tool bar and draw a box to contain your heading
(Figure 20-45).
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.

Figure 20-45 Adding text to a page

38.Enter a title of Gross Profit Active Report.


39.Click your text box so that it is surrounded by a straight line frame and slashes or handles.
40.In the Properties pane on the right, select the ... button next to Styling: Font.

664

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

41.In the Font window (Figure 20-46), select the styling for your heading:
a.
b.
c.
d.

For Font, select Arial.


For Font Style, select Bold.
For Size, select 18pt.
For Effects, select Underline. Click OK.

Figure 20-46 Styling text

42.Click the background area of the HTML layout.

Chapter 20. Assignment #14: Query/400 Modernization

665

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

43.In the Properties pane, click the ... button next to Background color and select a pale color
(Figure 20-47).

Figure 20-47 Background color

44.When we modified all the parameter control boxes, we changed the tab index in the
Properties pane. This controls the sequence that the users tab through the fields in the
window. We still have a problem in that some of the other elements on the page have a tab
index that might conflict with 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. The Run button had a tab index of
10 and we want it to be last in our normal sequence. Do not forget to check the arrow
elements in Salesrep.

666

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch22.fm

Figure 20-48 Tab layout view in Workbench

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 shows the sequence of
your tabs for the user. Make sure that you do not have duplicates and that the order is
left to right, top to bottom for INPUT-capable fields.
45.Save and run the report.

Chapter 20. Assignment #14: Query/400 Modernization

667

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

46.For our first test, select ALL for Salesrep and 2012/01/01 to 2012/06/26 for the dates
(Figure 20-49).
Tip: Having chosen the double list control for Salesrep means that you always must
select at least one item for SALESREP. This can be ALL, but there must be a value in
the output list.

Figure 20-49 Prompting for parameters for test run

668

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

47.Click RUN. Figure 20-50 shows the output of running this report.

Figure 20-50 Test result output

At this point, you can try and run the report, taking advantage of the parameter chaining.
Selecting a product type changes the product categories list box. Similarly, choosing a region
changes the state displayed.
Then go back to your parameter design page and start tailoring the page to look like a more
practical report that you might show to a user.

20.10.6 Providing multiple report output format options for users


In some cases your users may want to choose the output format dynamically at run time. For
example, user OZZIE may want the Gross Profit report to be generated as an Active Report,
while user ARCH prefers that same report to be presented as a PDF file, and SHANEG is a
power Excel user and likes his reports as spreadsheets. This dynamic specification of the
output format can be accomplished at report runtime by using the InfoMini capability of
InfoAssist.
Go back to Info Assist and edit your report named 15b - Active Report Revenue and Profit
Report. Take the following steps to clone this report with InfoMini enabled:
1. Click Format.

Chapter 20. Assignment #14: Query/400 Modernization

669

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

2. Select both Active Report and InfoMini.

Figure 20-51 Info Mini selection enabled

3. Using Save As, save the report as 15c - Active InfoMini Revenue and Profit Report
and then run it.
4. When you run a report that has InfoMini enabled, you will see a miniature version of Info
Assist at runtime with the controls to enable various report output options, as shown in
Figure 20-52.

1. Specify values for all parameters.


2. Select the run button to submit the request.
Figure 20-52 InfoMini report output options

5. Return to the HTML parameter report that you have open in DB2 Web Query Developer
Workbench.
6. As shown in Figure 20-53, right click Run Report button icon and select copy and then
paste to create a duplicate button. Change the text to indicate Run with output options.
Now the form has the option to run and see output or run and select output type.

Figure 20-53 Create another button

670

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

7. To define the action that occurs when the user clicks it, right-click the new button and
select Hyperlink properties, as shown in Figure 20-54.

Figure 20-54 Establish hyperlink on button

8. From the Hyperlink Properties dialog window, change the Display Text field to Run with
Output Options and set the Action, source and target information, as demonstrated in
Figure 20-55.

Figure 20-55 Hyperlink properties

9. Select External procedure as the Action, click the ellipsis icon under Source, and (from
the list of presented procedures) select your InfoMini report as the report to run. An
example is displayed in Figure 20-55.
10.Click the Open button to accept this report as the source and return to the Hyperlink
Properties dialog.
11.To display the PDF report in an overlapping browser pop-up window, select InfoWindow
for the Target Type setting and specify a size of 700/500 in the size window.
12.OK to accept the changes.
13.Click the Save icon to save your changes
14.Run the report and click the new Run with Output Options button to test it. You should
see a new window with an InfoMini screen as described previously and shown in
Figure 20-52.
15.Close the window.
With the InfoMini choice, the user more control over the output formats such as HTML, PDF,
Flash, Excel spreadsheet and PowerPoint.

Chapter 20. Assignment #14: Query/400 Modernization

671

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

20.11 Additional parameter tips


This section describes additional techniques that can be used to provide more control over
how report parameters are displayed and handled.

20.11.1 Displaying the values of one column while passing another


When developing DB2 Web Query reports that require prompt control (input parameters), you
may run into a requirement to present a drop-down list that is based on a column in your
database (for example, product name) but actually pass the value of a different column (such
as product number) as the input parameter value. This can be accomplished by utilizing the
display field feature of HTML Composer in DB2 Developer Workbench.
To set up a report and html page that utilizes this feature:
1. Using Info Assist, create a new report against CEN_ORDERS. The sort fields are
PRODUCT NAME and PRODUCTNUMBER, and the measure is Revenue (include
commas and floating currency for formatting). An example is shown in Figure 20-56.

Figure 20-56 New report specification and Revenue format

672

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

2. In the Data pane, right click on PRODUCTNUMBER and select Filter to add
PRODUCTNUMBER as a screening condition. Define it as a multi-value prompt control
parameter that is based on PRODUCTNUMBER in CEN_ORDERS. An example is
provided in Figure 20-57.

Figure 20-57 Set up prompt control parameter for PRODUCTNUMBER

3. Save the report as 15d-parameterPromptReport.

Chapter 20. Assignment #14: Query/400 Modernization

673

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

4. Run the report with No Selection. It should look like the example shown in Figure 20-58.

Figure 20-58 Example of 15d-parameterPromptReportt

5. Return to the Developer Workbench tool and create a new HTML file in your Tutorials
folder, as shown in Figure 20-59. Name the new html file 15eParameterPrompting.

674

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 20-59 Create new HTML file for 15eParameterPrompting

6. In the HTML Composer tool select the report icon to add a new report to the layout
(Figure 20-60).

Figure 20-60 Add report to layout

7. Using the crosshairs, draw/outline the location of the report on the canvas.
8. Right-click the report outline and select Reference Existing Procedure.
9. From the list of reports displayed, select 15d-parameterPromptReport. The New
Parameters dialog window is presented.
10.From this window, select Do not create a form under Parameter grouping options, then
click OK.

Chapter 20. Assignment #14: Query/400 Modernization

675

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 20-61 Parameters for ra6_parm report

676

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

11.Move the elements around on the canvas as shown in the example in Figure 20-62.

Figure 20-62 Move elements on canvas

12.Select the PRODUCTMNUMBER listbox element and on the Properties dialog for the
field, you will see Value Field and Display Field parameters (Figure 20-63).Notice that be
default, they are both identical. By pressing the ellipsis on the right of Display Field, you
may change the value seen during execution to a more user-friendly descriptive value

Chapter 20. Assignment #14: Query/400 Modernization

677

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

while still passing the parameter as the original PRODUCTNUMBER. Our friendly
description is in the field PRODUCTNAME, so we need to select that name in Display
Field.

Figure 20-63 Select parameters for Display value

The properties for the PRODUCTNUMBER parameter are displayed as shown in


Figure 20-64.

Figure 20-64 Parameter properties

13.Click the Run icon to test the report.


Notice that the drop-down list is populated with product names rather than the product
numbers.

678

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

14.Select multiple product names in the list (by selecting them and holding down the Ctrl key
on your keyboard) and click Run Report. Your results should look similar to the example in
Figure 20-65.

Figure 20-65 Example of report that displays one column as parameter but passes another

The drop-down list on the HTML page is populated with product names, yet the value of the
correlating ProductNumber column is passed to the underlying report. Because
ProductNumber is the parameter that the report is expecting, the report is able to find and
display the appropriate rows.
15.Close the browser window.
16.Back in the HTML Composer session, save the report.
17.Close the HTML Composer session.

20.11.2 Using another report to control parameter sorting and filtering


Another useful feature that can be implemented in HTML Composer is the ability to use
another procedure (another term for a report) to control the parameter list sorting and filtering.
This is useful, for example, if you have a report with a prompt control parameter of the
OrderDate column, but you would like the drop-down list sorted in descending order (rather
than the default, which is ascending). You would also like to filter this list to only show dates
for the year 2012.
To illustrate how this can be set up, the following three components are created in this
exercise:
 The base report with prompt control of OrderDate. This report shows revenue for the
selected OrderDate by country and region.
 Report (procedure) that sorts by OrderDate in descending order and only includes rows
for the year 2012. This report is generated to XML output format.
 HTML Layout that calls the base report and uses the procedure to populate and sort the
drop-down list.
The following steps
1. Launch Info Assist to create a new report based on the CEN_ORDERS synonym.

Chapter 20. Assignment #14: Query/400 Modernization

679

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

2. Sort the report by ORDERDATE_MDYY, COUNTRY, and REGION.


3. Drag Revenue into the Sum pane and specify column formatting of commas and floating
currency. An example is shown in Figure 20-66.

Figure 20-66 Using a procedure to sort the parameter list: base report

4. Set up the a prompt control parameter over the ORDERDATE column by doing the
following:
a. Drag the ORDERDATE field from the list of available fields into the Filter conditions
pane.
Note: In the QWQCENT test data, the metadata for OrderDate specified the field in
the YYMD format and we wanted it in MDYY format for this example, so a Define
field was created to reformat the date. This field OrderDate_MDYY was used for the
report column but NOT for the filter.
b. Click the Prompt button and select prompt using data values (Dynamic) option. link.
c. Verify the field name ORDERDATE is selected and click the Allow Multiples button.

680

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

These steps are shown in Figure 20-67.

Figure 20-67 Set up prompt control for ORDERDATE

5. Click OK.
6. Save your report as 15f - Revenue for Selected Order Date.
7. Run your report. Use the prompt control.
Notice that OrderDates are listed in the drop-down list and are sorted in ascending order,
as shown in Figure 20-68.

Figure 20-68 Report with prompt control for OrderDate

The behavior that you really want for this drop-down list is to present the OrderDates in
descending order. You would also like to filter this list so that only order dates for the year
2012 are presented and can be selected by the user.
One way to obtain this behavior is to create another report (procedure) and use it to
handle the parameter sorting and filtering. This procedure would be used to populate hte
listbox, via XML, with the dates. We will use SQL to expose the desired date range as
metadata that can be utilized by the listbox. An SQL view over the Orders table is created,
with the limitation of accessing 2012 dates only. This can be referenced in the HTML page
to populate the listbox with descending dates for only 2012. The SQL for this view is as
follows:
create view qwqcent.distinctOrdDt
as
Select distinct orderdate
from qwqcent.orders
where year(orderdate) in 2012 ;

Once you create the metadata DISTINCTORDDT.mas to make this view available, the
HTML composer is used to connect the view to the listbox in our example. The step is

Chapter 20. Assignment #14: Query/400 Modernization

681

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

handled by editing the properties for the listbox and specifying this datasource as the
embedded procedure to drive the listbox. We select sorting in descending sequence for
the listbox.

Figure 20-69 Connecting Listbox to embedded procedure

8. Run your HTML page to see the result. It should resemble the output shown in
Figure 20-70. Now the date selection includes only 2012 dates and they appear in the list
in descending sequence.

Figure 20-70 Resulting prompt for 2012 dates in descending sequence

682

IBM i DB2 Web Query for i Implementation Guide

8063ch22.fm

Draft Document for Review August 30, 2013 2:37 pm

The result is as desired. Note that one potential issue is the use of the special value ALL in
this circumstance. All enables selection of all data in the underlying table, which has data
for several years. Thus is ALL is used, the 2011 dates would show up also. Our listbox is
connected to the view, so shows only the limited year we wanted. Therefore, if using this
technique, do not check the box for Add ALL option.
This example is complete.
9. Save the HTML file in your chapter folder.
10.Close the HTML Composer session.
11.Return to the Web browser and run the report.

Chapter 20. Assignment #14: Query/400 Modernization

683

8063ch22.fm

684

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ch17.fm

21

Chapter 21.

Assignment 15: Creating JD


Edwards reports
The DB2 Web Query Adapter for Oracle JD Edwards is optimized to work seamlessly with the
JD Edwards World or JD Edwards EnterpriseOne application. This adapter provides realtime
access to your JD Edwards data and will leverage the security and business rules that your
organization has invested in JD Edwards. In addition, JD Edwards UDC (User-Defined
Codes) lookups, date conversions, and friendly column titles are automatically handled. With
these adapters, Web Query users will be able to generate and distribute reports, charts and
documents against JD Edwards data while adhering to the security rules defined in the JD
Edwards application.
Century Electronics uses JD Edwards as their ERP solution. As such Executive Dan would
like you to create reports based on data in the JD Edards database.
This chapter will takes you through the configuration, administration, and basic reporting
steps associated with the JD Edwards adapters using the reporting tool InfoAssist to create a
report.

Copyright IBM Corp. 2012. All rights reserved.

685

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

21.1 Connecting to a Remote JD Edwards Database Using


Adapters for JD Edwards
This chapter highlights the differences between the adapter for JD Edwards World and the
adapter for JD Edwards EnterpriseOne when connecting to a remote JD Edwards Database.
The document also describes what files need to be copied in order to connect to a remote JD
Edwards database. As an administrator, we recommend that you review the section 21.1.1,
Areas to Consider When Connecting to a Remote JD Edwards Database before you attempt
to connect to a remote JD Edwards database.

21.1.1 Areas to Consider When Connecting to a Remote JD Edwards Database


When connecting from a remote JD Edwards database ensure that you account for the
following points of consideration.
1. In the case of the JD Edwards World adapter, the dictionary tables that are replicated will
get out of sync if the originals are changed.
2. Report data retrieval may be slower than if the tables were local, depending on the amount
of data to process.

21.1.2 Using JD Edwards Adapter to Connect to a Remote JD Edwards


Database
Note: JD Edwards Dictionary Files Needed on Local System to Access Remote JD
Edwards Databases.
The JD Edwards World adapter and the JD EnterpriseOne adapter function differently in how
they access the dictionary information.
 The JD Edwards World adapter does not use an extract of the dictionary files for the
Master File conversion step, but does have a UDC descriptions extract locally to speed up
the UDC lookup when running a report.
 The JD Edwards EnterpriseOne adapter uses an extract for all of the dictionary
information.
The metadata repository for the adapter will need to be re-created if there are changes to the
information in UDC or security tables. This applies to both adapters, but principally the JD
Edwards EnterpriseOne adapter. If the repository is not refreshed, then information in the
report may be incorrect, or access to the data may be restricted or allowed depending on the
security change.

21.1.3 JD Edwards Dictionary Files Needed on Local System to Access


Remote JD Edwards Databases
The following synonym files need to be copied for JD Edwards to use the remote database.
For JD Edwards World 7:




686

F0092
F0001
F0005
F9401

IBM i DB2 Web Query for i Implementation Guide

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

 F0004
 F9202
 F9201
For JD Edwards World 8 and 9:








F0092
F0001
F0005
F9401
F0004
F9202
F9210

For JD Edwards EnterpriseOne:










F0092
F00950
F980WSEC
F0004
F0005
F9202
F9210

These files need to be copied to the local system in a library which is in the Web Query
startup library list and the user profile library list. That library name will also be used in the
entries needed when configuring the JD Edwards adapters.

21.2 Using the Adapter for JD Edwards World


The Adapter for JD Edwards World allows DB2 Web Query to access JD Edwards World data
sources. With this adapter, data in the JD Edwards World DBMS is displayed using rules
contained in dictionary files, thereby ensuring that valid information is returned to the
requesting program.

21.2.1 Preparing the JD Edwards World Environment


Although no environment preparation steps are required, ensure that your system complies
with all software specifications.
Do not add this JD Edwards adapter to a Reporting Server which already contains a
configured adapter for JD Edwards EnterpriseOne. If you would like to add this adapter to that
server configuration, you must remove the existing adapter for JD Edwards EnterpriseOne
first.
The only software requirement is to use a JD Edwards World Application installation
configured with DB2.

21.2.2 Overview of the Set Up Process


The setup process is comprised of the following basic steps:
1. Configure the Adapter for JD Edwards World. Define what type of JD Edwards security to
implement.

Chapter 21. Assignment 15: Creating JD Edwards reports

687

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

2. Refresh the metadata repository. You will need to perform this step initially, and repeat it
only if there are changes in the JD Edwards metadata tables. This occurs infrequently at
most sites.
3. Create the JD Edwards World synonyms. Synonyms are required for Web Query reporting
against a data source.

21.2.3 Configuring the Adapter for JD Edwards World


In this chapter we explain how to configure the Adapter for JD Edwards World. Follow steps
bellow to configure the Adapter for JD Edwards World.
1. Log on to DB2 Web Query as the DB2 Web Query (user profile with QWQADMIN group)
administrator ID.
The administrator is the user that configures and manages the adapter configuration;
other users are not permitted to manage and configure adapters.
2. In the Reporting area, create folder Assignment 15 - Creating JD Edwards reports. In
this tutorial, the folder is created under Century Electronics folder as in Figure 21-1

Figure 21-1 Menu to Create Folder

3. Expand DB2 Web Query Century Electronics Assignment 15 - Creating JD


Edwards reports. Right-click the Assignment 15 - Creating JD Edwards reports folder,
and select Metadata Edit as in Figure 21-2 on page 689.

688

IBM i DB2 Web Query for i Implementation Guide

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 21-2 Menu to Edit Metadata

4. In the new opened window, click the Adapter to open the Adapter tab, as in Figure 21-3

Figure 21-3 Open the Adapter tab

5. In the left-hand Adapter navigation pane, expand the Available folder.


6. Expand the ERP folder.
7. Expand the JD Edwards World folder.
8. Double-click A7.x - A9.x, the configure window will show as Figure 21-4

Chapter 21. Assignment 15: Creating JD Edwards reports

689

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 21-4 JD Edward World A7.x -A9.x Configuratoin

9. Select the connection parameters.


a. Business Unit Security
Check this box to enable automatic execution of JD Edwards World Business Unit
Security. The Server for IBM i automatically restricts user access to data, based on
information retrieved from the F0001 and F0006 tables, and then adds appropriate
WHERE conditions to the user's submitted data access request. Unchecked (OFF) is
the default setting. If you check this parameter, you cannot turn it OFF until the server
is shut down and then restarted (with no parameter settings).
b. Search Type Security
Check this box to enable automatic execution of JD Edwards World Search Type
Security. The adapter automatically restricts user access to data, based on information
retrieved from the F0005 table, and then adds appropriate WHERE conditions to the
user's submitted data access request. Unchecked (OFF) is the default setting. If you
check this parameter, you cannot turn it OFF until the server is shut down and then
restarted (with no parameter settings).
c. Business Unit (PA)
Check this box to revert (if necessary) to an older security model used by this adapter.
Unchecked (OFF) is the default setting. If checked, this option overrides standard
Business Unit Security (as described above).
d. Column Security
Check this box to enable column security based on information in the F9401 file.
Unchecked (OFF) is the default setting. If you check this parameter, you cannot turn it
OFF until the server is shut down and then restarted (with no parameter settings).
e. UDC Direct File Access
Check this box to enable User Defined Code Direct File Access. Unchecked (OFF) is
the default setting.
Note: It will create files, udcdicdb.*, in the JDWSEC application folder directory. Do not
delete these files.
f. Select Profile
690

IBM i DB2 Web Query for i Implementation Guide

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

This must be EDASPROF.


10.Click Configure.
You will receive a confirmation message.
11.Click OK.
Restarting the Reporting Server disconnects any users currently working in DB2 Web Query,
please confirm no Web Query user jobs are running before clicking OK. After the server
restarts, the adapter for JD Edwards World is successfully added to the configuration.

21.2.4 Refreshing the Metadata Repository


The Metadata repository contains the dictionary information for the JD Edwards World tables.
You must refresh the repository the first time you set up the adapter and repeat the process
each time the JD Edwards World tables change.

How to Refresh Metadata Repository


Important: In order to refresh metadata, you must have first configured the adapter.
1. Right-click JD Edwards World Click Refresh Metadata Repository as in Figure 21-5
This is only done when you first configure the adapter for JD Edwards World, or when JD
Edwards data dictionary information changes.

Figure 21-5 Menu to Refresh Metadata Repository

2. Select the version of JD Edwards World you will be using. Enter the name of the library for
each of the specified objects.
The UDC library parameter is the library name that will contain information on the User
Defined Codes in the JDE dictionary. A new library with the name specified will be created
on the system. Additionally, a new table will be created in that library which will contain
UDC information to be used by DB2 Web Query.
3. Click Refresh Now.
Once the refresh has completed, the metadata repository has been successfully
refreshed.

Chapter 21. Assignment 15: Creating JD Edwards reports

691

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

21.2.5 Creating the JD Edwards World Synonyms


To report against JD Edwards World data, you must first create synonyms.

How to Create the JD Edwards World Synonyms


1. Right-click JD Edwards World, and select Create Synonym.
2. Click the DB2 cli connection that points to your JD Edwards World data tables.
3. Select the restrictions you would like to apply when searching for synonym candidates.
Restriction options included are restrict object type, further restricting Tables, Views,
Aliases, and MQTs.
4. Click Next.
5. Select the check box next to the table(s) you wish to create synonyms for. Click create
Synonyms.
6. Add JD Edwards dictionary information to your synonym.
Options to specify include date format, presumptive join, field names, language code,
UDC, and Combine UDC.
a. Select date format
The options are: YMD, YYMD, DMY, MDY, MDYY, DMYY, MYY, YYM. (YYMD is the
default setting.) The selected format will be used only if the field is described as a
DATE in the Data Dictionary.
b. Presumptive Join
Check the Presumptive Joins box to include additional DEFINEs (virtual fields) for
presumptive join fields in the synonym. Checked (ON) is the default setting.
c. Field Names
Select Long Fieldname (the default) to display the field descriptions as names on
reports. Select Short Fieldname to use the JDE aliases as field names on reports.
d. Language Code
Enter the appropriate Language Code, which exists in the JDE F9292 file. (Leave the
field blank for English.)
e. UDC
Check the UDC box to ensure that UDC description fields are generated as DEFINEs
(virtual fields) in the synonym. Checked (ON) is the default setting.
f. Combine UDC
Check this box to Combine User Defined Code. Unchecked (OFF) is the default
setting.
7. Click Continue.

Once you have created the synonyms, you can now develop DB2 Web Query reports to
access JD Edwards World data.

692

IBM i DB2 Web Query for i Implementation Guide

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

21.3 Using the Adapter for JD Edwards EnterpriseOne


The adapter for JD Edwards EnterpriseOne allows DB2 Web Query to access JD Edwards
EnterpriseOne data sources. With this adapter, data in the JD Edwards EnterpriseOne DBMS
is displayed using rules contained in dictionary files, thereby ensuring that valid information is
returned to the requesting program.

21.3.1 Preparing the JD Edwards EnterpriseOne Environment


Although no environment preparation steps are required, ensure that your system complies
with all software specifications.
Do not add this JD Edwards adapter to a Reporting Server which already contains a
configured JD Edwards World adapter. If you would like to add this adapter to that server
configuration,you must remove the existing JD Edwards World adapter first.
The only software requirement is to use a JD Edwards EnterpriseOne Application installation
configured with DB2.

21.3.2 Overview of the Setup Process


The setup process for the adapter for JD Edwards EnterpriseOne is comprised of the
following basic steps:
1. Configure the adapter for JD Edwards EnterpriseOne. Define what type of security to
implement.
2. Refresh the metadata repository. You will need to perform this step initially, and repeat it
only if there are changes in the JD Edwards metadata tables. This occurs infrequently at
most sites.
3. Refresh the security extract. This step is required only if Group or Role based security is
configured in step 1. This captures the current JD Edwards EnterpriseOne rules for the
adapter to enforce.
4. Create the JD Edwards EnterpriseOne synonyms. Synonyms are required for Web Query
reporting against a data source.

21.3.3 Configuring the Adapter for JD Edwards EnterpriseOne


In this chapter we explain how to configure the Adapter for JD Edwards EnterpriseOne.
Follow steps bellow to configure the Adapter for JD Edwards EnterpriseOne.
1. Log on to DB2 Web Query as the DB2 Web Query (user profile with QWQADMIN group)
administrator ID.
The administrator is the user that configures and manages the adapter configuration;
other users are not permitted to manage and configure adapters.
2. In the Reporting area, create folder Assignment 15 - Creating JD Edwards reports. In
this tutorial, the folder is created under Century Electronics folder as in Figure 21-6 on
page 694
If you already have this folder created, please skip this step.

Chapter 21. Assignment 15: Creating JD Edwards reports

693

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 21-6 Menu to Create Folder

3. Expand DB2 Web Query Century Electronics Assignment 15 - Creating JD


Edwards reports. Right-click the Assignment 15 - Creating JD Edwards reports folder,
and select Metadata Edit as in Figure 21-7 on page 695.

694

IBM i DB2 Web Query for i Implementation Guide

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 21-7 Menu to Edit Metadata

4. In the new opened window, click the Adapter to open the Adapter tab, as in Figure 21-8

Figure 21-8 Open the Adapter tab

5. In the left-hand Adapter navigation pane, expand the Available folder.


6. Expand the ERP folder.
7. Expand the JD Edwards EnterpriseOne folder.
8. Double-click JD Edwards EnterpriseOne, the configure window will show as Figure 21-9
on page 696

Chapter 21. Assignment 15: Creating JD Edwards reports

695

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 21-9 JD Edward EnterpriseOne Configuration

9. Select the connection parameters.


a. Server Authentication
Check this box if the reporting server is secured. This option applies when every JD
Edwards EnterpriseOne user has a user ID on the reporting server system as is the
case in Web Query.
b. Security Type
When you configure the adapter for JD Edwards EnterpriseOne, you must choose if
your JDE environment is configured to use role-, group-based security, or no security
(NONE).
c. UDC Direct File Access
When you select this check box, you give users access to the User Defined Code
Direct File.
d. Select Profile
You must choose edasprof.
10.Click Configure.
You will receive a confirmation message.
Note: The reporting server agents will be stopped. You need to confirm that no Web Query
jobs are running before clicking OK. Restarting the Reporting Server disconnects any
users currently working in DB2 Web Query.
11.Click OK.

21.3.4 Refreshing the Metadata Repository


The Metadata repository contains the dictionary information for the JD Edwards
EnterpriseOne tables.
You must refresh the repository the first time you set up the adapter and repeat the process
each time the JD Edwards EnterpriseOne dictionary tables change.

696

IBM i DB2 Web Query for i Implementation Guide

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

How to Refresh the Metadata Repository


From the Adapters list in the navigation pane on the web page:
1. Right-click the configured JD Edwards EnterpriseOne adapter and select Refresh
Metadata Repository as in Figure 21-10
You will need to perform this step initially, and repeat it only if there are changes in the
metadata for tables. This occurs infrequently at most sites.
The Refresh Metadata Repository pane opens. The JDE tables required for this procedure
are listed in the first column.

Figure 21-10 Menu to Refresh Metadata Repository

2. Enter the Library name of the library containing the specified objects. The UDC library can
be any arbitrary name, for example, UDCDIC.
3. Click Refresh Now to refresh the metadata repository.
Once the refresh has completed, the metadata repository has been successfully
refreshed.

21.3.5 Refreshing the Security Extract


The security extract is a snapshot of the security rules defined in JD Edwards EnterpriseOne.
The adapter uses this extract to enforce the restrictions when reporting against JD Edwards
EnterpriseOne data. You must refresh the security extract as often as the security rules
change in the JD Edwards EnterpriseOne application.

How to Refresh the Security Extract


In order to refresh the security extract, navigate to the Adapters list in the navigation pane on
the web page.
1. Right-click the configured JD Edwards Enterprise One adapter and select Refresh
Security Extract as in Figure 21-11 on page 698.
Note: You will need to perform this step upon initial configuration of the adapter, and
repeat it only if there are changes in the JD Edwards EnterpriseOne security rules.
Chapter 21. Assignment 15: Creating JD Edwards reports

697

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 21-11 Menu to Refresh Security Extract

2. Enter the Library name of the library containing the specificed objects.
3. Click Submit to refresh the security extract.

21.3.6 Creating the JD Edwards EnterpriseOne Synonyms


To report against JD Edwards EnterpriseOne data, you must first create synonyms.

How to Create the JD Edwards EnterpriseOne Synonyms


1. Right-click JD Edwards EnterpriseOne, and select Create Synonym.
2. Click the DB2 cli connection that points to your JD Edwards EnterpriseOne data tables.
3. Select the restrictions you would like to apply when searching for synonym candidates.
Restriction options included are restrict object type, further restricting Tables, Views,
Aliases, and MQTs.
4. Click Next.
5. Select the parameters you would like the synonym to include.
Parameters options include With foreign keys, One-part name, Application, Prefix, Suffix,
and Overwrite existing synonyms.
a. With foreign keys
Select the With foreign key check box to include within this synonym every table related
to the current table by a foreign key. The resulting multi-table synonym describes all of
this tables foreign key relationships.
b. One-part name. On the IBM i platform, the One-part name check box is unchecked by
default. The unchecked behavior generates a table name that includes the explicit
name of the library containing the table. For example, if you specified a library on the
first Create Synonym pane, a qualified name like the following is automatically created
in the Access File:
TABLENAME=MYLIB/MYTABLE

698

IBM i DB2 Web Query for i Implementation Guide

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

With this explicit type of entry in the Access File, at run-time the library is directly
located and searched for the table name. If you select the check box, the explicit library
name is not stored in the metadata (Access File). When the synonym is generated, the
library portion of the table name is omitted from the Access File, and appears as
follows:
TABLENAME=MYTABLE
With this type of entry in the Access File, at run time the library path of the user is
searched until the table name is located.
c. Application
This defaults to the first application folder in the application path.
d. Prefix/Suffix
If you have tables with identical table names, assign a prefix or a suffix to distinguish
them. For example, if you have identically named human resources and payroll tables,
assign the prefix HR to distinguish the synonyms for the human resources tables. Note
that the resulting synonym name cannot exceed 64 characters. If all tables and views
have unique names, leave prefix and suffix fields blank.
e. Overwrite existing synonym
To specify that this synonym should overwrite any earlier synonym with the same fully
qualified name, select the Overwrite existing synonyms check box.
Note: The connected user must have operating system write privileges in order to
recreate a synonym.
6. Select the check box next to table(s) you wish to create synonyms for.
7. Click Create synonym.
8. Add JD Edwards dictionary information to the synonym.
a. Select date format
The options are: YMD, YYMD, DMY, MDY, MDYY, DMYY, MYY, YYM. (YYMD is the
default setting.) The selected format will be used only if the field is described as a
DATE in the Data Dictionary.
b. UDC
Check the UDC box to ensure that UDC description fields are generated as DEFINEs
(virtual fields) in the synonym. Checked (ON) is the default setting.
c. Combine UDC
Check this box to Combine User Defined Code. Unchecked (OFF) is the default
setting.
9. Click Continue.
The synonym has been successfully created.

21.4 Developing a JD Edwards Report


This section will highlight the JD Edwards synonym using InfoAssist. We will use the F0911
table (Account Ledger) for this section of the tutorial and assumes you have completed all the
prior sections of this tutorial.

The benefits of the JD Edwards adapter are:


 Proper decimal notation
Chapter 21. Assignment 15: Creating JD Edwards reports

699

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

 Automatic UDC lookups


 Julian to Gregorian date conversion
 User friendly column titles
 Leveraging Presumptive Joins (World only) and Security definitions
This tutorial will highlight the first four benefits.

How to Develop a JD Edwards Report


1. Log on to DB2 Web Query.
2. Expand DB2 Web Query Century Electronics Assignment 150 - Creating JD
Edwards reports. Right-click the Assignment 15 - Creating JD Edwards reports folder,
and select New Report as in Figure 21-12

Figure 21-12 Menu to Create Report

3. Select the JD Edwards F0911 synonym in the Select data source dialog window.

700

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch17.fm

Figure 21-13 Select Synonym

By default you are presented with the Logical view of the field list from F0911. The Logical
view arranges your fields by Dimension and Measures. Your fields are sorted such that all
your numeric fields are grouped under a heading called Measures and all the character
fields are grouped under Dimensions, as in Figure 21-14 on page 702

Chapter 21. Assignment 15: Creating JD Edwards reports

701

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 21-14 Logical view of the field list

4. If you want display filed names, you can set this by clicking on the Logical icon on the View
Ribbon and selecting Field.

702

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch17.fm

Figure 21-15 Display field names

5. Let's scroll down the field list and notice the UDC (User Defined Codes) fields. These
represent the descriptive text for key fields in the file.
6. Scroll down further and notice the Measures associated with this file, as in Figure 21-16
on page 704.

Chapter 21. Assignment 15: Creating JD Edwards reports

703

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 21-16 Measures fields

7. Select some of each of the aforementioned fields and build a report. You can double click
fields, or drag and drop them on to your Interactive Design View panel to build the report.
InfoAssist will put dimensions as Sort fields and measures as Measure fields where you
can aggregate as required. The other option is to drag fields into a specific area of the
Query Panel.
Figure 21-17 on page 705 shows the Interactive Design view using Data from Source. It
represents what your report will look like at run time using data from the JD Edwards data
source.

704

IBM i DB2 Web Query for i Implementation Guide

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 21-17 Build a report

a. Notice that the Query Panel to be 2x2 has been changed by selecting the icon from the
Query Panel group on the View Ribbon. The icon on the View Ribbon and the Query
Panel group are both highlighted with boxes labeled A in Figure 21-17.
b. Notice the UDC field, DOCUMENT_TYPE_CODE_DESC_1, is provided. In this case,
it is giving the descriptive name for Document Type. This is highlighted in the box
labeled B in Figure 21-17.
c. Notice the Date is converted to a Gregorian date YYMD. This is highlighted in the box
labeled C in Figure 21-17.
d. Notice the decimal precision on the numeric columns as well as the friendly column
titles. This is highlighted in the box labeled D in Figure 21-17.
8. There are a couple of tasks you can perform to enhance your report before running it.
a. UDC field titles can be changed by right clicking on the UDC field in the Interactive
Design View and selecting the Change Title option as in Figure 21-18 on page 706.

Chapter 21. Assignment 15: Creating JD Edwards reports

705

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 21-18 Menu to Change Title

A dialog box will appear to allow you to enter in a new column title.
b. Currency fields can be easily formatted with floating currency symbols. Select a
numeric field on the Interactive Design View. Let's select Amount. Notice the Field
Ribbon appears for Amount, as in Figure 21-19.

Figure 21-19 Select Amount field

Use the Format group on the Field Ribbon to add floating currency and commas by
clicking on the respective icons. An item that is highlighted in yellow means the option
is turned on.

Figure 21-20 Add Floating Currency

To do more advance formatting, click on the drop down and select More options

706

IBM i DB2 Web Query for i Implementation Guide

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 21-21 Menu to More options

Change decimal precision to 2.

Figure 21-22 Window to change field format

The Interactive Design View dynamically reflects this change, as in Figure 21-23 on
page 708.

Chapter 21. Assignment 15: Creating JD Edwards reports

707

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 21-23 Interactive Design View of the report

c. Add a subtotal on each DOCUMENT_TYPE_CODE_DESC_1. On the Interactive


Design View, click on the DOCUMENT_TYPE_CODE_DESC_1 field and click the
Subtotal icon in the Break group on the DOCUMENT_TYPE_CODE_DESC_1 Field
Ribbon as in Figure 21-24 on page 708.

Figure 21-24 Button to add Subtotal

Notice a subtotal is added dynamically to the Interactive Design View, as in


Figure 21-25 on page 709.

708

IBM i DB2 Web Query for i Implementation Guide

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 21-25 Report with subtotal

9. Save your report as 15a - JD Edwards report


10.Click the Run button on the Quick Access Toolbar to run your report, as in Figure 21-26 on
page 709.

Figure 21-26 Run button

Depending on your InfoAssist settings, your report output will appear in a tab or window. In
this example, InfoAssist directs the output to a single tab.

Chapter 21. Assignment 15: Creating JD Edwards reports

709

8063ch17.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 21-27 Run the report

This tutorial guides you through your first JD Edwards report. As you can see, configuring the
JD Edwards adapter, managing JD Edward synonyms, and developing a report with Web
Query InfoAssist is very similar to any other data source in Web Query.

710

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch22a.fm

22

Chapter 22.

The Century BI Solution


Challenge: Postmortem
In this chapter we look back on Century Challenge BI solution and provide the results of the
challenge.

Copyright IBM Corp. 2012. All rights reserved.

711

8063ch22a.fm

Draft Document for Review August 30, 2013 2:37 pm

22.1 Summary
In the previous chapters in Part 2, you completed a variety of assignments related to the
Century Challenge BI solution. In each chapter you were given assignments by a skeptical
executive who did not believe in the IBM i plaform, the DB2 for i database, or the DB2 Web
Query product. In the end, you delivered on all of the assignments and in many cases, you
exceeded Executive Dans expectations. All the reports, charts, dashboards, and scheduling
requirements were delivered - and all within the 2 month period.
As a result of your efforts, Exective Dan decided that you and Mel were correct: that the IBM i
platform is powerful, modern, secure, stable, reliable, and leading edge. And that it would be
foolish for a business to ever move off of such a platform. He humbly accepted defeat in the
challenge, but in the process, he became an ardent and enthusiastic supporter of the IBM i. In
fact, a few short months later he placed the order for a new Power 7 model, and initiated
projects to look at migrating other business applications and databases TO the IBM i platform.
He fired Fitzgerald (his caddy at the country club) citing an abundance of bad IT advice and
lack of moral support. He even aspires to speak at midrange user conferences in the future to
present a case studies on Century Challenge BI solution and the migration projects. What a
difference two months makes!

Figure 22-1 The new Executive Dan

712

IBM i DB2 Web Query for i Implementation Guide

8063p03.fm

Draft Document for Review August 30, 2013 2:37 pm

Part 3

Part

Miscellaneous topics
In this part we discuss miscellaneous topics regarding DB2 Web Query such as:
 Migration Considerations
 An IBM i Business Intelligence Solution
 An Adapter for Microsoft SQL Server

Copyright IBM Corp. 2012. All rights reserved.

713

8063p03.fm

714

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ch23.fm

23

Chapter 23.

Performance Case study


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 we discuss DB2 Web
Query performance considerations and recommendations. We include a case study that is
intended to demonstrate steps that you can take to tune a DB2 Web Query report.

Copyright IBM Corp. 2012. All rights reserved.

715

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

23.1 Performance basics


When the objective is to obtain optimal report performance, keep 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 i database
engine, the DB2 Web Query Reporting Server, or a combination of both.
 DB2 Web Query attempts to translate the source code of a DB2 Web Query report into
equivalent SQL statements. When the report is run, the SQL statement is submitted to the
database engine for processing.
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.
 Like most other relational databases management systems (RDBMS), the DB2 for i
database engine knows its own data. Its optimizer component uses complex costing
algorithms to determine the ideal access plan, which indexes to use, and so on, so that 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 IBM i, which is 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 is
to push as much of this processing, decision making, and execution as possible down to
the database level.
If a request is not optimized, the DB2 Web Query Reporting Server performs the tasks such
as joining, sorting, and aggregating. In these cases, the database engine retrieves all the
rows that are necessary for the request based on the translation. DB2 Web Query then
completes that processing necessary to prepare the data for the report. This can have the
following results:
 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

23.2 DB2 CLI adapter performance


In this section we discuss performance considerations that are specific to the DB2 call-level
interface (CLI) adapter.

23.2.1 Report request process flow


As a foundation for understanding DB2 Web Query performance factors, you must 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 the different phases of optimization
occur when a report request is made and how you can influence them.

716

IBM i DB2 Web Query for i Implementation Guide

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

The process of running a DB2 Web Query request consists of two phases:
 The execution phase
 The report production phase
Figure 23-1 illustrates the flow of the request through these two phases.

Execution phase

HTTP Clients

DB2 Web Server/


Application Server

DB2 Web Query


Reporting Server
DB2 for i

Database
result set

Report production phase

DB2 Web Query


result set

Report
Figure 23-1 Flow of DB2 Web Query report run request

Report execution phase


The following steps occur during the execution phase of a report request:
1. The Web browser client sends the request to the Web server or application server for
processing.
2. The Web server or application server routes the request to the DB2 Web Query Reporting
Server.
3. The Reporting Server component handles the following tasks during this phase:
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 i, so that the Reporting Server can create
metadata for the result set that will be returned
d. Passes the procedure to the data adapter for processing
4. The DB2 Web Query data adapter component handles the following tasks during this
phase:
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

Chapter 23. Performance Case study

717

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

c. Translates (optimizes) the DB2 Web Query request to the appropriate SQL statement
or statements
d. Passes the SELECT statement or statements to the DB2 for i database engine
5. The database engine component handles the following tasks during this phase:
a.
b.
c.
d.

Analyzes and optimizes the SQL statement or statements


Chooses the appropriate access path and retrieval method
Retrieves the data
Creates the database result set

6. The report execution phase ends.

Report production phase


At the completion of the report execution phase, the report production phase begins. During
the report production phase, the database engine component sends a row and an SQL status
code to the Reporting Server.
Note: The database engine is now interfacing with the database result set and not the
native relational data on DB2 for i.
The Reporting Server component handles the following tasks during this phase:
1. Reads the row from the database result set and processes any remaining actions on that
row (IF/WHERE, DEFINEs, and so on, that were not translated by the database engine)
2. Converts nonstandard 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. Repeats tasks 14 (loop) until the end of the database result set (SQL status code +100)
6. Processes the DB2 Web Query result set, applies style sheets, and formats the report
output as requested by the instructions in the procedure
7. Displays the report via a browser or native program based on the type of output produced
(for example, Adobe or Excel)

23.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 23-1 displays the DB2 Web Query operations and the SQL equivalent.
Table 23-1 DB2 Web Query operations and SQL equivalent

718

Operation

SQL equivalent

Retrieve rows for columns specified.

SELECT
SELECT DISTINCT(.)

IBM i DB2 Web Query for i Implementation Guide

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

Operation

SQL equivalent

Identify the table from which to report.

FROM

Simple aggregation functions.

SUM, COUNT, AVG, MIN, MAX

Retrieve specific rows.

WHERE

Retrieve specific aggregated rows.

HAVING

Ordering rows.

ORDER BY

Create logical table structures (joins).

FROM...WHERE...

Define field

FUNCTON(COLUMN)

Chapter 23. Performance Case study

719

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

Operation

SQL equivalent

Compute field

FUNCTON(SUM( ) )

Selection and projection


Two 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 is translated into various predicates of the SQL WHERE clause except those
expressions listed in Table 23-2.
Table 23-2 Selection disablers
Selection disabler

Description

Non-translatable
DEFINE fields

Certain DEFINE expressions can be translated to SQL as part of


aggregation or record selection operations. In some circumstances,
they can be used as part of a define-based join. The following
examples are of translatable DEFINE expressions:
 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 (for example, on the


right side of the equal sign) in the DEFINE expression, not on the
format of the field that is being defined.

Table 23-3 provides more information about the DEFINE field


expressions that can be translated to SQL.
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.

Table 23-3 lists the DEFINE expressions that can be translated to SQL.
Table 23-3 DEFINE expressions that can be translated to SQL
Expression

SQL translatable conditions

Arithmetic expressions
NEWSAL/D12.2 =
((CURR_SAL + OTIME_SAL) x 1.1) - 100;







720

IBM i DB2 Web Query for i Implementation Guide

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

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

Expression

SQL translatable conditions

Character string expressions


FORMAL_NAME/A36 =
LAST_NAME | ', ' | FIRSTNAME;




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 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
Real-field operands of any DB2 Web Query-supported
data type (including DATE fields)
Constants with same data type as fields 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

For more information about creating DEFINE fields refer to New fields - Define vs
Compute on page 91.
 Projection
Projection is the process of retrieving the table columns that meet the request criteria.
Projection is 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 return all columns in the master file only.
Note: SELECT * is never generated by DB2 Web Query.
It is important to understand the DB2 Web Query selection and projection operations
because they are both processes that reduce the volume of data that is returned from the
database, which helps to improve performance, efficiency, and report response time.

Optimization hierarchy
In addition to individual operations being optimized, a progressive optimization hierarchy
affects the SQL that is being generated. Figure 23-2 shows the order of adapter optimization.

Chapter 23. Performance Case study

721

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

Creation of logical
table structures (JOIN)

If the join optimization fails, so does the


sort and aggregation optimization.

Ordering rows (SORT)

If the sort optimization fails, so does


aggregation optimization.

Aggregating rows
(SUM/COUNT)

Aggregation optimization occurs only if


the join and sort operations were
optimized and aggregation was required.

Figure 23-2 DB2 Web Query adapter optimization order

Translation to SQL: Regardless of the hierarchy in Figure 23-2, the adapter always tries
to translate row selection (WHERE) and projection operations to their SQL equivalents.
This hierarchy is mentioned because it is important for you to know what to focus on first. If
your reports ordering or aggregating is not being performed by the database engine and you
are unable to determine why, it might be because join optimization is failing. Therefore, if you
have a poorly performing report that is joining two or more tables, your analysis should begin
with join optimization.

Join optimization
A 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:
1. The DB2 Web Query request is optimized and is translated to a single SQL select
statement.
2. The database engine retrieves the data from the tables specified in the select statement.
3. The database engine merges the rows using its chosen join implementation.
4. Screening conditions are applied, if any.
5. The columns in the request are applied.
6. Any column function values or expressions are calculated.
7. One result set is produced.

722

IBM i DB2 Web Query for i Implementation Guide

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

Table 23-4 illustrates the strengths of DB2 Web Query as well with the corresponding
strengths of DB2 for i.
Table 23-4 Quick guide to strengths of DB2 Web Query and DB2 for i
DB2 Web Query strengths

DB2 for i strengths

DB2 for i federated joins

Joining on local tables (SELECT...FROM...WHERE)

Complex calculations

Row and column selection (SELECTWHERE)

Sophisticated formatting

Sorting (SELECTORDER BY)

Generate graphs

Aggregation (SELECTGROUP BY)

Referential integrity and constraint awareness: As of V5R3, the SQL Query Engine
also has referential integrity and constraint awareness. This means that the optimizer is
capable of using the referential integrity 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.
DB2 for i 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 can still fail.

Conditions that prevent full DB2 Web Query optimization


After a query request is submitted, there are several conditions that cause the adapter to
disable the optimization of the join operation. These join disablers are shown in Table 23-5.
You must eliminate these conditions if you want full DB2 Web Query optimization to occur.
Table 23-5 Join disablers
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 Selection and projection on page 720,
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 is not translated either.

DEFINE fields that span


more than one segment in a
joined structure

Joining tables based on DEFINE fields prevents the database engine


from processing the join.

Multiplicative effect

An aggregation at any level other than the lowest level of the JOINed
structure or a child table whose foreign key does not totally cover its
primary key (causing the parent table rows to be duplicated). .

Federated joins

Joining DB2 for i tables on different systems, partitions, or


independent auxiliary storage pools (IASPs) is carried out by DB2 for
DB2 Web Query and not the database engine.

When you create a join connection (via the join tab) between tables, DB2 Web Query might
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 Querys performance considerably. In particular,

Chapter 23. Performance Case study

723

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

when the joined-in table (called the target table to 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 tables (called host tables to the left of the
join panel) matches at most one row in the joined-in target table (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.

Sorting optimization
If any of the conditions listed in Table 23-6 are true, DB2 Web Query performs the sorting.
Table 23-6 Sorting and aggregating disablers
Sort disablers

Description

DB2 Web Query managed join

See Table 23-5 on page 723.

Sort on a non-translatable DEFINE field

Any request that contains a sort on a non-translatable


DEFINE field.

Interface-managed join

SQL sorts the answer set by the tables primary key,


causing DB2 Web Query to re-sort for the display report.

Aggregation optimization
If any of the conditions listed in Table 23-7 are true, DB2 Web Query performs the
aggregation.
Table 23-7 Aggregation disablers
Aggregation disablers

Description

DB2 Web Query managed join or sort

See Table 23-5 on page 723 and Table 23-6.

DB2 Web Query managed row selection

Some WHERE clauses are not passed to the database


engine.

Non-direct SQL operators

The request contains direct operators, such as PCT. and


TOT., that cannot be translated into SQL.

Aggregation on a non-translatable
DEFINE

Aggregating on a DEFINE field that cannot directly


translate to SQL.

Other ways to influence optimization


The conditions that we discussed in the previous sections help dictate whether DB2 Web
Query or the database engine performs the bulk of the report processing. In addition, there
are techniques that you can use to influence this behavior and improve report response time.

Creating SQL views


During DB2 Web Query report development, you might encounter situations in which a report
does 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 tables from the database description list.
This instructs DB2 Web Query to use the view and push the selection, join syntax, and
aggregation to the database engine. This particular technique is used to tune a problem
report in 23.5, Performance case study on page 745.

724

IBM i DB2 Web Query for i Implementation Guide

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

The advantages of using views are many. The following list provides an idea of what SQL
views can do:
 Provide the ability to specify additional join types that are not supported by the DB2 Web
Query product.
DB2 Web Query allows 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
Right Exception
 Allow you to specify CASE statements to handle more complex, conditional logic.
 Provide fullselect support.
SQL fullselect is the term for generating an SQL result set by combining multiple SELECT
statements using the UNION, INTERSECT, 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 exist only during the execution of an SQL
statement. When defined, the CTE 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 i 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 about recursive CTEs, refer to the article V5R4 SQL Packs a
Punch, which you can download from the Web at:
http://www-03.ibm.com/servers/eserver/iseries/db2/pdf/rcte_olap.pdf
 Allow business logic to reside in the database layer, making it available to all users and all
SQL interfaces.
 Provide a database abstraction layer.
 Provide security granularity.
When the 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.
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 database administrator (DBA) are
concerned about access path maintenance, this is not an issue with views.

Establishing and using foreign key relationships


If you have foreign key relationships explicitly defined in IBM i database, you can take
advantage of a DB2 Web Query feature to include with the selected tables synonym, every
table related to the selected table by a foreign key. The resulting multi-table synonym
describes all of this tables 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
Chapter 23. Performance Case study

725

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

relationships, DB2 Web Query is able to understand the join syntax that must be created and
generates the appropriate SQL statement.

Creating materialized query tables


Materialized query table (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
querys definition. It provides a mechanism for improving the response time of complex SQL
queries. While it can be 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 considers 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) in the System i environment. Because of this, it can
be accessed directly, just like any other table on the system. While it is usually the optimizers
job to select and implement an MQT in the access plan of a query request, DB2 Web Query
has 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:
1. From the DB2 Web Query BI portal, right-click your reports folder and select Metadata
New.
2. In the browser window, from the left navigation pane Steps, select Synonym Or
Samples, and select the DB2 cli adapter. Select Create Synonym.
3. In the Select Synonym Candidates for DB2 (*LOCAL) pane (Figure 23-3), specify the
collection and select the MQTs check box. Click Next.

Figure 23-3 Creating a synonym for MQT: specifying the collection

726

IBM i DB2 Web Query for i Implementation Guide

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

4. In the Create Synonym for DB2 cli pane, specify a prefix and suffix, select the MQTs that
are listed, and click Create synonym.
After the synonyms are created for the MQTs, you can create reports against them as you
would for any other table object on the system.
While their potential performance efficiencies are appealing for DBAs, query developers, and
report users, MQTs have several attributes and limitations that must be understood prior to
implementation. Probably most important, you must know 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 must 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 can 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-theminute, you might come to the conclusion that an MQT is not the right fit.
For more information about MQTs see the white paper Creating and using materialized query
tables (MQT) in IBM DB2 for i, which you can find on the Web at:
http://www-304.ibm.com/jct09002c/partnerworld/wps/servlet/ContentHandler/
SROY-6UZ5E6bv

23.2.3 Remote database access considerations (including cross-system


joining)
One feature of the DB2 Web Query base product is the ability to access data on remote DB2
for i systems or partitions. This feature, which is available only for the DB2 CLI adapter, gives
you the 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 or one or more remote systems or
partitions.
If full DB2 Web Query optimization can be performed for Local and Remote database access,
and no other external factors are negatively influencing query performance, you can expect
your reports to perform reasonably well. Again, this is because DB2 Web Query can generate
one SQL statement and allow the DB2 for i 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 generates a
separate SQL statement for each connection and submits 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) that
has 116 rows. If both of the tables are on the local (or even remote) system, DB2 Web Query
generates a single SQL statement and submits it to DB2 for i. Example 23-1 shows how the
statement looks.
Example 23-1 Single SQL statement

SELECT T2."Country",T2."State", SUM(T1."LineTotal")


FROM CENTURY/ORDERS T1,CENTURY/STORES T2
WHERE (T2."StoreCode" = T1."StoreCode")
Chapter 23. Performance Case study

727

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

GROUP BY T2."Country",T2."State"
ORDER BY T2."Country",T2."State"
FOR FETCH ONLY
Since one statement is generated and the database engine handles all the joining, grouping,
and ordering, you can expect this report to run quite efficiently.
However, if the dimension table STORES resides on another system and infoAssist 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 23-2 Local system SQL statement

SELECT T1."StoreCode",T1."LineTotal"
FROM CENTURY/ORDERS T1
FOR FETCH ONLY
 Remote system
Example 23-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 is modified to specify STORES (with only 116 rows) as the base table, the join
fan-out is greatly reduced. This results in a report that runs significantly faster, but is still not
nearly as fast as when all tables are on same system. Therefore, we generally recommend
that you avoid creating reports with cross-system joins when the tables have a substantial
number of rows. However, if such an implementation is required, consider the following
suggestions to enhance the reports performance:
 Eliminate the reports requirement of multiple connections by making local copies of the
remote tables. After all tables are on one system, join optimization can be enabled and
DB2 Web Query attempts 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 reduces 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
Figure 23-4 shows an example of this setting specified in the report source. This setting
impacts the number of FOR FETCH lines when one of the tables is remote. In effect, it
turns all of the tables into local internal tables and sort merges them.

728

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch23.fm

Figure 23-4 SORTMERGE setting

23.3 Query/400 adapter performance


Another feature of DB2 Web Query is the ability to run most existing Query/400 queries. This
is done by using the Query/400 adapter that is provided with the base offering of 5733-QU2.
This adapter functions by 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 well and takes several minutes to run to completion, it requires just as much
time (and perhaps more) to create the DB2 Web Query synonym. After the synonym is
created and you run the new DB2 Web Query report, you can again expect it to require at
least the same amount of time to run.
Because the adapter is running the existing query, you are 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 ensures that the appropriate indexes are in place for the optimizer to use when
creating the access plan for the query. Refer to 23.4.3, Indexes on page 740, to learn about
approaches for implementing an indexing strategy.
As we mentioned earlier in this chapter, Classic Query Engine (CQE) processes non-SQL
database requests such as those from Query/400 queries. CQE provides index advisory
information for query selection. Missing from CQE is the ability to create index advisories for
joining, grouping, and ordering. Analysis and tuning, which are more manual in nature, are
required for these types of requests. If your Query/400 reports are not performing to your

Chapter 23. Performance Case study

729

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

satisfaction, make sure that the indexes exist over all join fields, order by fields, and fields that
are aggregated.

23.4 DB2 for i 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 IBM i database itself that can affect efficiency.
These types of factors are usually the responsibility of the DBA and not the users. However, a
little knowledge of these factors and how they can affect efficiency enables a user to
communicate effectively with the DBA.
When the users have done everything that they possibly can in the efficiency spectrum to
ensure that the report definitions are as good as they can be, the following DB2 for i factors
can still influence the overall efficiency of the request:






Database design
Query Engine used
Indexes
Available hardware
Number of concurrent users

23.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 a high-level language (HLL) program written in RPG or COBOL. This approach
works when such programs are the only interface to the data and can hide the complexity
from 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. In the following list, we highlight the shortcomings of a poorly designed database:
 Complexity
The application programs contain most, if not 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 users) are forced to
develop the reports. Often the reports themselves are HLL programs that can be complex
and difficult to maintain. Programmers can find themselves constantly creating new copies
of reports to satisfy a seemingly endless list ad hoc reporting requirements by the user.
 Lacks flexibility
The database is difficult to maintain, adapt, and expand. Repeating groups must be
squeezed into a single record, which places limits on the number of 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
used and, therefore, the report performance is not maximized.

730

IBM i DB2 Web Query for i Implementation Guide

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

If this describes your current database design, you might want to consider investing in a
robust data modeling tool that can help you implement a database design that is both
functional and efficient.

23.4.2 Query Engine used


As described earlier in this publication, DB2 for i employs two database engines. Both CQE
and SQE are used to process database access requests. Although SQE is the engine
designed for SQL access, there are still inhibitors that can prevent SQE processing for SQL
requests. The SQE inhibitors for each supported version of the operating system are listed in
Table 23-8.
Table 23-8 SQE inhibitors
6.1 SQE inhibitors





ICU 2.6.1 Sort Sequences


Non-SQL Interfaces (OPNQRYF, Query/400,
QQQQRY API)
Logical File reference on FROM Clause
Select/Omit Logical Files defined on tables

7.1 SQE inhibitors




Non-SQL Interfaces (OPNQRYF, Query/400,


QQQQRY API)

Important: While as of 6.1 the SQE optimizer is still unable to utilize Select/Omit logical
files when building query plans, IBM did change the default value for the
Ignore_Derived_Index QAQQINI parameter to enable more SQE usage. This QAQQINI
parameter was first added back in V5R3 to allow the SQL Query Engine to be used in
environments where SQL statements are referencing DB2 objects created with DDS. Prior
to 6.1, the default value for this parameter was *NO, causing the SQE optimizer to reroute
execution of any SQL request to the Classic Query Engine (CQE) anytime that a derived
logical file was encountered during the query optimization process. The default value in 6.1
for the Ignore_Derived_Index QAQQINI parameter has been changed to *YES. This value
allows the SQE query optimizer to ignore any keyed logical files that contain select/omit
criteria during optimization and process the query instead of rerouting execution to CQE.
Your goal as a database administrator or DB2 Web Query administrator/developer should be
to ensure that each DB2 Web Query request is processed by SQE. Why is this so important?
Because SQE is the IBM strategic optimizer, and as such, it will be the one on which the IBM
development team focuses. Enhancements that add new features and boost performance will
only be applied to SQE, not CQE. Consequently, when a query is processed by SQE you can
expect vastly superior performance over the same query handled by CQE. Some of the
reasons for this include:





Enhanced optimization techniquesa smarter, faster, and more efficient optimizer


Self-learning query optimization
Ability to self-adjust during query execution
Better/faster database primitives to access the data

In addition, SQE provides many more features than CQE. Among them are:





Materialized Query Tables (MQTs)


Maintained Temporary Indexes (MTIs)
SQE plan cache
Ability to cache results

Chapter 23. Performance Case study

731

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

Achieving SQE processing for every DB2 Web Query request is quite simple: avoid SQE
Inhibitors. The following list provides the major issues to look out for in a proactive mode:
 Avoid creating metadata for DDS logical files.
Only create metadata over tables/physical files, SQL views, or MQTs.
If you need the filtering or joining provided by a DDS Logical File, create an SQL View
that performs the equivalent filtering/joining.
 Watch out for Select-Omit logical files against physical files.
Again, this is not as important in 6.1because the default behavior is for SQE to ignore
Select-Omit logical files. But if you are at 5.4 of the IBM i operating system and you need
to create metadata over a physical file that has Select-Omit logical files against it, you will
can instruct the optimizer to ignore this derived logical file by using the
IGNORE_DERIVED_INDEX parameter in the QAQQINI query options file. This process is
documented in the tech tip Maximize SQL Query Engine (SQE) Usage of Your DB2 Web
Query Reports, which can be access from the following URL:
http://www.mcpressonline.com/database/db2/maximize-sql-query-engine-sqe-usage-of
-your-db2-web-query-reports.html
 Use the DB2 CLI adapter whenever possible.
Keep in mind that both the Heritage File and Query/400 adapters use CQE.
Recreate Query/400 reports as new reports that use synonyms based on the DB2 CLI
adapter.
There is no way to avoid it for multi-format files (must use Heritage File adapter).
Use SQL Aliases to access multiple members.

Determining which engine is used


You can also work in a reactive mode to determine which engine is handling your query
requests. This can be done by collecting a database monitor and analyzing the results. Two of
the most common ways to do this are as follows:
 Run the statement in Run SQL Scripts window (System i Navigator) and use Visual
Explain to analyze the results.
 Start a database monitor collection, run the query, and use the System i Navigator
dashboard to analyze results.

Using Run SQL Scripts window and Visual Explain


With this method, you capture the SQL statement that DB2 Web Query is producing for a
report and copy and paste the statement into the Run SQL Scripts window of System i
Navigator. Visual Explain is then launched against the statement to produce a graphical
representation of the optimizers chosen access plan for the query, as well as a wealth of
information about the plan. Part of the information provided in this process is which query
engine is used.
To implement this method, take the following steps:
1. Right-mouse the report and select Run w/SQL Trace.

732

IBM i DB2 Web Query for i Implementation Guide

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 23-5 Run w/SQL Trace

Rather than running the report and displaying the results, this option displays the
generated SQL statement.
2. As shown in Figure 23-6, copy this statement to your clipboard.

Copy the statement


Figure 23-6 Copy the SQL statement

3. In System i Navigator open a connection to your system and launch a Run SQL Scripts
window.

Chapter 23. Performance Case study

733

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

4. Paste the statement from your clipboard into the Run SQL Scripts window. This is shown
in Figure 23-7.

Paste the statement into


Run SQL Scripts window

Figure 23-7 Paste the SQL statement

Tip: Depending on your configured naming convention (*SQL or *SYSTEM in the format
tab of the JDBC settings for your System i Navigator connection), you may have to edit the
statement after you paste it into the window. The naming conventions are:
 The *SQL naming convention uses a period (.) between the library and object names.
 The *SYS naming convention uses a forward slash (/) between the library and object
names.
This means that you may have to the replace the / character with a period (.) for all
qualified object references.
5. As shown in Figure 23-8, swipe/highlight the statement and click the Explain icon in the
tool bar.

734

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch23.fm

Figure 23-8 Explain the SQL statement

This action launches the Visual Explain utility. Visual Explain provides information about
the optimizers chosen access plan. It also renders a graphical representation of the query
access plan.
6. Select the Final Select icon on the plan and scroll down to the bottom of the Attribute pane
on the right. This is shown in Figure 23-9.

Figure 23-9 Visual Explain example

The Query Engine Used attribute appears at the bottom. The value of this attribute
provides the information for which you are looking. In this case, SQE was used.

Using database monitor collection


Another technique is to run the report in DB2 Web Query after starting a an SQL monitor. You
can then use the dashboard provided with the On Demand Performance Center tool to quickly
determine which query engine is used.
The following steps describe this process:
1. Open a System i Navigator connection to your system and expand Databases
<name_of_your_database>.

Chapter 23. Performance Case study

735

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

2. Right-click SQL Performance Monitors and select New SQL Performance Monitor,
as shown in Figure 23-10.

Figure 23-10 Start new SQL Performance Monitor

3. On the SQL Performance Monitor Wizard dialog window, specify the following:
Name: DB2 Web Query Redbook monitor
Type: Detailed
Schema for data: QGPL
Click Next. An example screen is provided in Figure 23-11.

Figure 23-11 SQL Performance Monitor Wizard window 1

736

IBM i DB2 Web Query for i Implementation Guide

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

The second dialog window for SQL Performance Monitor Wizard is presented. This
window allows you to specify pre-filtering criteria for the monitor collection. Using
pre-filtering is strongly recommended because it can greatly reduce the amount of monitor
data collected. This will help keep your analysis simple. In this example, you pre-filter on
the user profile running the request and the schema (library) name of the object being
queried. This should keep the collection small (ideally to a single SQL statement).
4. As shown in Figure 23-12, specify the following prefilter criteria and click Next:
Check the box for Current user and specify your user profile name.
Check the box for the setting Statements that access these objects and under
Schema, enter QWQCENT.

Figure 23-12 SQL Performance Monitor Wizard window 2

5. On the third dialog window for SQL Performance Monitor Wizard, select the radio button
for All jobs and click Next. An example is displayed in Figure 23-13.

Figure 23-13 SQL Performance Monitor Wizard window 3

Chapter 23. Performance Case study

737

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

On the final dialog window for SQL Performance Monitor Wizard, click Finish.

Figure 23-14 SQL Performance Monitor Wizard window 4

6. Return to your DB2 Web Query browser session and run the report.
At this point the monitor data has been collected for the report run. The monitor can now
be ended.
7. Return to the System i Navigator session. Under the connection, select Databases
<name_of_your_database SQL Performance Monitors.
A list of available SQL Performance monitors is displayed.
8. Find the monitor that you just started and select End from the right-click menu
(Figure 23-15).

Figure 23-15 End SQL Performance Monitor

738

IBM i DB2 Web Query for i Implementation Guide

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

9. Now you can analyze the results. Again, right-click the monitor entry. This time select the
Analyze option, as shown in Figure 23-16.

Figure 23-16 Analyze SQL Performance Monitor

The SQL Performance Data Analysis dashboard window is launched. Under the
Overview category, find the lines for SQE and CQE. As displayed in Figure 23-17, the
dashboard shows the value of 1 for SQE and 0 for CQE. This means that your query
was processed by SQE.

Figure 23-17 SQL Performance Data Analysis dashboard

Chapter 23. Performance Case study

739

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

23.4.3 Indexes
Like any other application that accesses information from the database, efficient DB2 Web
Query performance heavily depends on having the correct indexes in place. When your
database is in production, it might be difficult to implement recommended database design
practices such as database normalization. However, at this point, you can still implement an
indexing strategy that helps to optimize the performance of your query reports.
Indexes over your database tables have 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 can 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 ensures that no duplicate values exist for that column.
Using indexes might result in the following ramifications:
 As mentioned previously, indexes 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 used 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 IBM DB2 for i
indexing methods and strategies. You can download this paper from the Web at the following
address:
https://www.ibm.com/partnerworld/wps/servlet/ContentHandler/stg_ast_sys_wp_db2_i_i
ndexing_methods_strategies
In addition, the following tips can help you get started:
 Take a proactive approach and make sure that there are indexes available over all of the
selection, joining, ordering, and grouping columns of your queries.

740

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch23.fm

 In a reactive mode, run your queries and use the available database feedback
mechanisms to determine what indexes the optimizer wants 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 tables that are being queried. It makes a recommendation that the index be
created. Afterward, this advice can be obtained from various sources, including the
following sources:

Index Advisor
SQE Plan Cache
SQL Plan Cache snapshot
SQL Performance Monitor
Visual Explain

The index advisories can be extracted from these sources of optimizer feedback and used
to create the recommended indexes.
Important: When an advised index is created and the query is run again, you might
observe that the optimizer does not use that index during implementation. Indexes are
sometimes recommended for the information that they can provide to the optimizer.
This information is used to help the optimizer cost each access method. It might also
help the optimizer determine that the advised index is not the optimal one to use during
query execution.
For more information about SQL and database performance analysis, refer to OnDemand
SQL Performance Analysis Simplified on DB2 for i5/OS in V5R4, SG24-7326.

23.4.4 Available hardware


Hardware is certainly a critical component when considering the factors that can impact an
applications performance. Insufficient resources usually mean that users sit and wait while
the work is being done. Typically, older hardware equates to fewer resources: slower
processors, less memory, and overall inferior throughput. While DB2 Web Query can run on
any system with V5R4 or later, newer models do offer the advantages of more processing
power and better overall throughput. The product makes heavy use of JAVA and SQL, two
technologies that will consume system resources. The bottom line is that factors such CPW
ratings and amount of available memory do matter when it comes to DB2 Web Query
performance. This is true of any application running on the system. If its been a while since
your last upgrade, you must evaluate your performance expectations and decide whether you
want to run modern software on a server that is, for example, 12 years old.

A balanced system
While sufficient hardware resources to run your workloads is critical factor, it is also important
that you have a balanced hardware configuration. What does this mean? It means that simply
adding more memory or another processor to your system may not improve overall
performance and create an unbalance in the environment. This is because when it comes to
driving workloads, the ultimate goal is to keep the processor busy while minimizing wait times
(queuing). To help illustrate this, consider the following dish-washing analogy.
Let us say that you own a restaurant and one of the workloads to be performed is washing
dishes. In this subsystem the busser (term used for both busboy and busgirl) brings the dirty
dishes and places them in the sink and the dishwasher (a person) takes the dishes out of the

Chapter 23. Performance Case study

741

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

sink and washes them. Each component in this process can be analogous to a component in
your hardware configuration:
 The dishwasher = the processor
 The sink = memory
 The bussers = disk units/arms
The goal is to keep the dishwasher busy (as long as there is work to be done) so that the
dishes are cleaned as fast as possible. Therefore, acceptable performance and a balanced
system are largely dependent on the following:
 The speed of the dishwasher
 The number of dishes to be washed
 Performance expectations
Let us say that the process is not going as fast as you would like and not enough dishes are
being cleaned. Your performance expectations are not being met. So you take the following
steps:
1. You walk into the kitchen and discover that Frank, the dishwasher, is waiting for work. This
means that queuing is occurring earlier in the process. You observe that there are four
bussers (working frantically) and they cannot bring dishes into the sink fast enough
(queuing at the disk I/O level is occurring). So you hire four more bussers.
2. This corrective action helps and Frank becomes busier but is still waiting for work. So,
again, you hire four additional bussers. This has no effect on performance because now
the bussers are queued up, waiting to place dishes in the sink because the sink is full (not
enough memory). This is an example of an unbalanced system.
3. Showcasing your sharp business acumen, you purchase a bigger sink (more memory).
This eliminates the queuing at the sink and Frank stays busy all the time. You now have a
balanced system, but you are still not satisfied with the pace of which the dishes are being
washed.
4. Because it worked before, you decide to trade in that sink for one that is even larger. You
then observe that many more dishes can be placed in the sink, but it does not help overall
performance whatsoever, This is because the dishes are piled up in a big heap in the sink
and Frank cannot work any faster (too much memory). At this point the system is again out
of balance.
5. Evaluating the situation, you ascertain that hiring more bussers will not help. And an even
bigger sink would be a foolish purchase. You conclude that there are two choices: you can
either fire Frank and hire a faster dishwasher (upgrade) or you can hire another
dishwasher to help Frank out (add another processor). Frank is a good guy and has never
called in sick once in the three years he has been employed, so you decide to help him out
and hire his third cousin Gus. This new hire proves to be the right move: Frank and Gus
become a formidable dishwashing duo, producing clean plates at a brisk and more than
acceptable pace. The number of bussers is optimal, as is the size of the sink, thus there is
no queuing. You finally have a balanced system that meets your performance
expectations.
This simple analogy is meant to illuminate the fact that the amount of work to be done,
performance expectations, and a balanced system must be considered when it comes to
evaluating your hardware resource needs.

Workload estimator for DB2 Web Query


Determining the system resources needed to run your query workloads while maintaining a
balanced system is not a trivial task. To help you with this venture, IBM has provided a Work
Load Estimator (WLE) for DB2 Web Query. This tool is a sizing guide that is provided to help

742

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch23.fm

you estimate your hardware resource needs for DB2 Web Query workloads and is part of the
IBM suite of sizings guides. It is based on a series of workload benchmarks defined and
performed by the IBM STG Lab Services team.
Once you are into the DB2 Web Query WLE (Figure 23-18 on page 743), you define the
workload characteristics to the tool. Information such as the following should be included:
 Users
Includes the number of concurrent users and developers and the types of users (heavy,
medium, light).
 Environment
Attributes about the environment in which the DB2 Web Query product will be running.
This include factors such as the size of your database.
 Specifics of production environment, if applicable
Specify whether queries are running in a shared environment (for example, against
production databases) or a dedicated environment (for example, a data warehouse).

Figure 23-18 DB2 Web Query Workload Define

Chapter 23. Performance Case study

743

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

Once you have completed these steps, the sizing guide provides an estimate of the minimum
hardware configuration necessary to run the defined DB2 Web Query workloads.
Note: Although DB2 Web Query does not require Power7 hardware, the DB2 Web Query
WLE produces Power7 hardware recommendations only.
Figure 23-19 provides an example of the output produced by the DB2 Web Query WLE.

Figure 23-19 Sample output of Workload Estimator for DB2 Web Query

Important: The use of the Workload Estimator and its results are restricted to the purpose
of helping you predict a possible system solution. These results are estimates and
averages based on certain assumptions and conditions, and are based on measurements
and analysis with a variety of workloads (internal to IBM and by third parties), performance
characterizations of systems hardware and software, and best performance practices.
Ensure that realistic inputs have been provided for the high-level configuration, the
workload definitions, and user options. Actual customer results may differ significantly.
The system recommendations are based on measurements of a fixed set of reasonably
well-tuned queries. Resource requirements for any specific user workload will vary
depending on the complexity of the queries, the make-up of the database, and the extent to
which the queries have been tuned.

744

IBM i DB2 Web Query for i Implementation Guide

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

23.4.5 Concurrent users


Unless they sign on to the system and do nothing, application users typically equate to more
workload on the system. More units of work means that more system resources are being
consumed. You may have a balanced system with satisfactory performance, but at some
point (as you add more users or those existing users request more work or work that is more
resource intensive) you will either experience queuing or a processor that cannot keep up.
Getting back to the dish-washing analogy, as the word spreads and your restaurant gains
popularity, you suddenly have an influx of new customers. More customers means more dirty
dishes that must be washed. Frank and Gus may need some help, perhaps in the form of
more bussers, a larger sink, or another dishwasher. The balanced system may need an
adjustment.
Much of this is obvious, but you may find it difficult to find the right balance. This again is
where the DB2 Web Query WLE can prove to be helpful, because it does consider the
number of concurrent users in its calculations.

23.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 available optimization techniques.
The objective is to determine why the particular report has an excessive runtime and provide
example approaches in order to reduce the overall runtime.
In this section we describe the following steps:
1.
2.
3.
4.
5.
6.

Identify a long-running report.


Perform analysis, looking for optimization disablers.
Determine report-tuning options.
Create an SQL view and synonym and change the report to use view.
Create a new report based on the SQL view.
Perform additional database analysis and tuning.

23.5.1 Identifying a long-running report


During creating reports, we may see a report that require an excessive amount of time to run
to completion. However, reports that were similar in nature, meaning that they had the same
general format and approximately the same number of rows returned, ran in seconds.

Chapter 23. Performance Case study

745

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

23.5.2 Performing analysis and looking for optimization disablers


To help determine the reasons behind the substantial run time, DB2 Web Query provides the
Run w/SQL Trace 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.
Note: Report Assistant (included in DB2 Web Query 1.1.x) has the Run w/SQL Trace
option but infoAssist doesnt have the Run w/SQL Trace now (as of DB2 Web Query 2.1
HotFix1). Since infoAssist will have the function later, this section provides a performance
analysis with the Run w/SQL Trace.

When the report is run using the Run w/SQL Trace option, the SQL trace information is
displayed as HTML output to the browser, as shown in Figure 23-20.

Not translated to SQL


(and why)
Translated SQL
statement

Figure 23-20 Report trace results

This trace reveals a couple of interesting points. First, it shows that part of the report cannot
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 is generated (and what is ultimately submitted to the database engine). Even though part
of the translation failed, the Reporting Server was able to construct a meaningful SQL
statement.
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 statements WHERE clause (Figure 23-21).

746

IBM i DB2 Web Query for i Implementation Guide

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 23-21 Define field DAYS_DIFF

Anytime that a define field can be passed to the database engine, a more efficient report
results, particularly when the define field is part of the selection process, which it is the case
in our example. If the define field cannot 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 kind of behavior can negatively impact performance and should be avoided if at all
possible. Again, we must emphasize that the report is more efficient if the entire database
access portion of the report definition can be pushed down to the database engine for
processing.

23.5.3 Determining report-tuning options


Tuning this particular report basically means selecting one of the following actions:
 Eliminate the culprit define field.
 Modify the report in an attempt to enable SQL translation for the define field.
 Push the define field logic down to a database using SQL views.
For this example, the define field is required to deliver the necessary information in the report
(and therefore cannot be removed). In addition, repeated efforts to fix the translation for the
define field prove to be futile. Therefore, only the third option remains, which is to push the
define field logic down to a database using SQL views.

23.5.4 Creating an SQL view and synonym


The next step is to create an SQL view that contains all the required tables, join syntax,
columns, and selection, including the DAYS_DIFF field selection that DB2 Web Query was
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 is
added to the view. Example 23-4 shows this result column, also named DAYS_DIFF.

Chapter 23. Performance Case study

747

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

Example 23-4 DAYS_DIFF result column

DAYS('1998-01-31') - DAYS(T1.SHIPDATE) AS DAYS_DIFF


To create the new view:
1. From a System i Navigator, open a connection to the System i environment and open a
Run SQL Script window.
2. Type the CREATE VIEW statement or use the SQL selection statement that is displayed in
the trace as a base for this view definition and make the necessary modifications. Copy
and paste the statement into the Run SQL script window and begin making the changes.
For the copy and paste method, Figure 23-22 shows more details about what to add and
remove from the selection statement to form the CREATE VIEW statement.
Add CREATE VIEW syntax

SQL statement
copied from
trace
Add result
column
DAYS_DIFF

Remove local
selection
Remove ORDER BY clause
Figure 23-22 Anatomy of the CREATE VIEW statement

Notice that the local selection is removed from the CREATE VIEW statement. This is
added to the statement that references the view. Also observe that the ORDER BY clause
is removed. This is because views cannot be ordered. Ordering is specified in the report
definition.
After all the necessary modifications are made, Example 23-5 shows how the CREATE
VIEW statement should look.
Example 23-5 Create SQL view

CREATE VIEW STAR1G.DAYS_DIFFERENCE_VIEW


AS
SELECT T1."SHIPDATE",T1."CUSTKEY",T1."REVENUE_WO_TAX",
T2."CUSTOMER",T3."YEAR",T3."MONTH",
DAYS('1998-01-31') - DAYS(T1.SHIPDATE) as DAYS_DIFF
FROM STAR1G.ITEM_FACT T1, STAR1G.CUST_DIM T2,STAR1G.TIME_DIM T3

748

IBM i DB2 Web Query for i Implementation Guide

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

WHERE (T2."CUSTKEY" = T1."CUSTKEY") AND (T3."DATEKEY" = T1."SHIPDATE")


3. Execute the statement to create the view.
4. From the browser, open the DB2 Web Query metadata window and create a synonym
against the new view.

23.5.5 Creating a new report based on the SQL view


When the new view and its synonym are in place, a new report is created to access the
contents of the view:
1. From DB2 Web Query home page, select infoAssist to create a brand new report.
2. In the Select from available database descriptions window (Figure 23-23), select the new
view. Click OK.

Figure 23-23 infoAssist: selecting a new view

Chapter 23. Performance Case study

749

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

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 23-24 and
Figure 23-25 on page 751.

Figure 23-24 Report using SQL view: Field selection tab

750

IBM i DB2 Web Query for i Implementation Guide

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 23-25 Report using SQL view: Selection criteria tab

4. Save the report and click Quit.


5. Run the new report.
6. Record performance measurements.
In the case of this example, significant improvements in performance are observed. In fact,
simple benchmark measurements reveal that the report, using the view, runs 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 you can obtain. Many factors can
affect report performance, so your results might vary.

23.5.6 Performing additional database analysis and tuning


When your report is using the SQL view and all database processing is being handled by the
database engine, your work might not yet be done. You can potentially gain further
efficiencies by performing regular database analysis and tuning. You can use the following
tools and technologies to assist 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 has been made available through the System i
Navigator toolset. From this interface, you can find the SQL statement generated by DB2
Web Query and begin performing your analysis.
Chapter 23. Performance Case study

751

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

 Visual Explain
Visual Explain provides a graphical representation of the optimizer implementation of a
query request. The query request is broken 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 Explains
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
that are 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 the
SYSIXADV table in the QSYS2 schema.
 Database monitor
The Database Performance Monitor is a set of integrated tools that is 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 in a database tables, where it can be analyzed and used to identify and tune
performance problem areas.
 Materialized query tables
As mentioned previously, an MQT is a DB2 table that contains the results of a query, along
with the querys 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
The database optimizer can use Index Only Access if all of the columns specified in the
SQL statement are represented in the index as key columns. Because all of the columns
that are 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.
Database performance analysis and tuning are rather broad topics that are briefly discussed
in 23.4, DB2 for i optimization on page 730. For a more extensive discussion about this
subject refer to OnDemand SQL Performance Analysis Simplified on DB2 for i5/OS in V5R4,
SG24-7326.
For this exercise, feedback from the optimizer (obtained by locating the statement in the SQE
plan cache and launching Visual Explain) suggests the creation of the indexes shown in
Example 23-6.
Example 23-6 Indexes created for the 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
752

IBM i DB2 Web Query for i Implementation Guide

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

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 are created and the report is run again. Simple benchmark testing reveals
modest improvements to the runtime after these indexes are created.

23.6 Performance benchmark


A performance benchmark was conducted to help determine DB2 Web Query runtime
performance expectations relative to the equivalent Query/400 objects and SQL statements.

23.6.1 Objectives
The benchmark had the following objectives:
 Measure the overhead and resource usage of using the 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.

23.6.2 Scenarios
The benchmark test bucket included six scenarios, each with a set of eight different queries or
statements. Each query was run with 10 different sets of host variable values to measure
variances in selectivity and cardinality. We measured the following scenarios of queries:







Query/400 *QRYDFN objects (using the IBM i RUNQRY command)


DB2 Web Query running the *QRYDFN objects
Direct SQL statements
DB2 Web Query reports using the DB2 CLI adapter
Direct SQL statements with all full open and re-optimization
DB2 Web Query reports using the DB2 CLI adapter with all full open and re-optimization

For each measurement, we captured the following data:


 Total execution time for a given number of loops of the executed queries and reports
 Performance monitor data
 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).

Chapter 23. Performance Case study

753

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

23.6.3 Database and system configuration


For all of the benchmark measurements, a sample database with approximately 1 GB of data
was used.
The measurements were done on a Model 515 System i environment with one or two
processors, 7.5 GB of memory, and six disk arms. After running sets of measurements on the
system, it was determined that one processor was a better match for the amount of memory
and number of disk arms on the system. All measurements reported were done with a
one-processor configuration.

23.6.4 Matrics
The measurement data was summarized into four key metrics:





Minimum average response time per query


Maximum throughput
CPU usage
Memory usage

Minimum average response time per query


The metric for minimum average response time shows the average response time per query
for a single user. The results of this metric are shown in Figure 23-26. The average response
time (sec/query) is computed as the inverse of the measured throughput (queries/sec) for a
single user running back-to-back queries with no think time.

Minimum Ave Response Time


3.500

Seconds

3.000

Qry400 *qrydfns
Web Query *qrydfns

2.500
SQL

2.000
Web Query

1.500
1.000
0.500

SQL Full Open / Reopt


Web Query Full Open/
Reopt

0.000
Figure 23-26 Minimum average response time chart

Figure 23-26 shows that there is a moderate response time increase for *QRYDFN objects
that are run through DB2 Web Query compared to *QRYDFN run through Query/400. Some
response time increase is expected when running from a remote client. As expected, the
direct SQL statements have the fastest response time. The response time of the DB2 Web
Query reports, although longer than the direct SQL statements, is significantly faster than the
response time of the *QRYDFN objects. This is primarily due to the efficiencies of the SQL
generated by the DB2 Web Query running through SQE. Because it is an SQL CLI
application that runs in server mode, each server job is recycled after every DB2 Web Query
request. This means that all queries are ad hoc in nature and do incur full opens. However,
the DB2 Web Query response time is only slightly increased due to this. This is the case due

754

IBM i DB2 Web Query for i Implementation Guide

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

to server jobs being recycled after each DB2 Web Query report. The extra overhead of more
full opens is incurred in the base DB2 Web Query response time numbers as well.

Maximum throughput
The objective of measuring maximum throughput is to show the maximum number of queries
per second that ran before reaching a system bottleneck, such as processor or disk
utilization. See Figure 23-27. This limit is measured by increasing the number of users who
are running queries until no additional throughput is gained.

Maximum Throughput
30.00

Queries/Sec

25.00
20.00

Qry400 *qrydfns
Web Query *qrydfns
SQL

15.00
10.00
5.00

Web Query
SQL Full Open / Reopt
Web Query Full Open/
Reopt

0.00
Figure 23-27 Maximum throughput chart

The maximum throughput for *QRYDFN objects that run through the Web Query interface is
almost equivalent to the maximum throughput of running the *QRYDFN objects through
Query/400. As expected, the executed SQL statements have the greatest throughput. DB2
Web Query introduces additional overhead compared to SQL. However, the maximum
throughput for the DB2 Web Query reports is 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 is only reduced slightly. This
is the case due to server jobs being recycled after each Web Query report. Therefore, the
extra overhead of more full opens occurs in the base Web Query throughput numbers as well.

Chapter 23. Performance Case study

755

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

Resource usage: CPU


The chart of CPU resource usage in Figure 23-28 shows the amount of CPU resource used
per query on average. The CPU utilization is measured when the system was running at
maximum throughput. The CPU usage is then calculated as the CPU utilization divided by the
queries per second at the maximum throughput point.

Resource Usage: CPU

CPU Util/Max Throughput

160.00
140.00

Qry400 *qrydfns

120.00

Web Query *qrydfns

100.00

SQL

80.00
60.00

Web Query
SQL Full Open / Reopt

40.00
20.00

Web Query Full Open/


Reopt

0.00
Figure 23-28 CPU usage chart

Figure 23-28 shows a 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 use more CPU than the equivalent plain SQL.

Resource usage: memory


The 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 (Figure 23-29 on page 757). The memory requirement is
determined by collecting a memory curve. Throughput for a fixed number of users is
measured at various base pool sizes. The smallest memory size measured with the high level
of throughput is the memory requirement point. DB2 Web Query running *QRYDFN objects
compared to *QRYDFN objects run through Query/400 require more memory. This is
expected due to the additional server jobs used by DB2 Web Query. As expected, the plain
SQL queries require the least amount of memory. DB2 Web Query reports, running at a
higher throughput rate, require about the same amount of memory as the *QRYDFN objects
run through Query/400.

756

IBM i DB2 Web Query for i Implementation Guide

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

Resource Usage: Memory

MB in Base Pool

3500
3000

Qry400 *qrydfns

2500

Web Query *qrydfns

2000

SQL
Web Query

1500

SQL Full Open / Reopt

1000

Web Query Full Open/


Reopt

500
0
Figure 23-29 Memory usage chart

Figure 23-30 lists the data used in the graphs in this section.

Qry400 *qrydfns

Minimum
Average
Response
Time
(Sec/Query)
2.346

Maximum
Throughput
(Queries/sec)
0.74

CPU
Util/Throughput
134.55

Memory
Required
(MB)
2676

Web Query *qrydfns

3.240

0.64

147.26

3188

SQL

0.116

24.82

3.65

2164

Web Query

1.213

3.60

16.20

2676

SQL Full Open / Reopt

0.189

11.07

8.80

2164

Web Query Full Open / Reopt

1.263

3.11

22.30

3000

Figure 23-30 Benchmark results table

23.6.5 Conclusions
We used the results of the benchmark to derive the following conclusions:
 Comparisons of the DB2 Web Query *QRYDFN versus the Query/400 *QRYDFN show an
increased response time. This result is expected when running to a client application as is
the case with DB2 Web Query. The server CPU used is 9% more, and more memory is
required.
 Comparisons of DB2 Web Query (using DB2 CLI adapter) reports to Query/400
*QRYDFN are positive. Even with running to a client, the DB2 Web Query reports run
faster, use much less CPU, and require about the same amount of memory. This can
primarily be attributed to the DB2 CLI adapter generating SQL and using the new SQL
Query Engine (SQE).
 Comparisons of Web Query to SQL show that DB2 Web Query has longer response
times, which again is expected when running to a client, and uses more resources. The
CPU used by Web Query is two to four times the CPU used when running SQL,
depending on whether the full open re-optimization was forced every time. Note that Web
Query recycles the server jobs for every query.

Chapter 23. Performance Case study

757

8063ch23.fm

Draft Document for Review August 30, 2013 2:37 pm

 If you are using DB2 Web Query to modernize Query/400 queries (by creating new
reports), there is little additional overhead.
 If you are creating new reports, always keep in mind that SQL is being generated.
Therefore, an understanding of SQL performance basics is vital.

758

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch24.fm

24

Chapter 24.

Migration Considerations
This chapter describes the migration considerations when you update Web Query for IBM i
from release 1.1.x. Firstly, introduces the new concepts and terms available in Web Query
2.1.0, then describes migrating from 1.1.x.

Copyright IBM Corp. 2012. All rights reserved.

759

8063ch24.fm

Draft Document for Review August 30, 2013 2:37 pm

24.1 New concepts and terms in Web Query 2.1.0


Effective with this release, the Report Assistant, Graph Assistant, Power Painter, Web
development tools and the Developer Workbench Graph Assistant tool have been replaced
with Web-based Rich Internet Application facilities. This aligns with the on-going strategy to
consolidate tool sets and to standardize on a common look-and-feel across all report
development products.
InfoAssist Basic is a modern, Web-based facility that provides comparable functionality as
found in Report Assistant, as well as over 80 chart types. It will include functionality equivalent
to that found within Report Assistant and Graph Assistant.

24.1.1 Business Intelligence Portal


The Business Intelligence Portal (BI Portal) is new in Web Query 2.1.0 and is the driving force
behind the new user interface. It is the successor to the Business Intelligence Dashboard (BI
Dashboard). It does everything that BI Dashboard does, and more.
The BI Portal is about being able to build complete, modern Web sites. The end user
experiences the drag-and-drop features that are available in popular online portals. This is a
key point, as end users do not need to learn anything new. This results in no training and a
high usage rate.

24.1.2 New Web Query Administration User ID


QWQADMIN is the new Web Query Administrator user ID that has the ability to manage
users and configuration settings for a Web Query installation. The QWQADMIN user ID has
the following attributes:
 Does not take up a named user license.
 Can add and remove users to Web Query.
 Can add or remove other Web Query administrators.
 Can grant users authorization to specific roles by adding them to groups.
 Can associate group profiles to specific folder run group(s).
 Can launch the Report Broker and Administration Consoles to configure the Web Query
installation.
 Cannot manage folders, procedures, schedules or metadata.
 Has ownership of all the metadata.

24.1.3 Web Query Folders


For Web Query 2.1.0, almost all content is stored in the Web Query Client Repository (DB2
Tables)as shown in Figure 24-1. The only exception is Web Query metadata. Synonyms are
still stored in the IFS in application directories.

760

IBM i DB2 Web Query for i Implementation Guide

8063ch24.fm

Draft Document for Review August 30, 2013 2:37 pm

Client Repository

Top Level Folders

Application
Directories

Figure 24-1 Folders structure

Web Query content consists of procedures, HTML files, Stylesheets, images, Report Broker
schedules and distribution lists. This content is stored in one or more folders.

Top Level Folders


Top level folders reside at the top of the Web Query Client Repository and are used to
segregate applications. For example, you may want to have a top level folder for Sales and
another folder for Human Resources (HR) where users can be assigned to one or more
folders. A user can have a different set of roles for each folder. For example, a user can be
assigned to only run reports in HR but takes on a developer/dba role in Sales.
Each top level folder is created with its own set of Web Query Groups that define the
authorization rules for the folder. For more information, see Web Query Groups on
page 762.
The Common top level folder exists for all Web Query installations. The purpose of this folder
is to contain content that can be run by all users. If you prefer not to display the Common top
level folder, there is an option to hide it.

How to Hide the Common Top Level Folder


Note: Customers that have migrated from Web Query 1.1.x will have their Common
Domain contents migrated to the Common top level folder.
1. Login to Web Query using the QWQADMIN user ID.
2. Right-click on the Common top level folder and click Hide.

Application Directories and Metadata Management


Application directories are where synonyms are created. They are IFS directories which map
to the following path:
/qibm/UserData/qwebqry/apps
In Web Query 1.1.x, the baseapp application directory is the default location for newly created
synonyms. Synonyms in the baseapp directory are accessible from all Domains. If Developer

Chapter 24. Migration Considerations

761

8063ch24.fm

Draft Document for Review August 30, 2013 2:37 pm

Workbench was licensed, it could be used to create new application directories which could
be linked to a Domain's application directory path.
In release 2.1.0, the baseapp application directory fulfills the same role in 1.1.x. However, a
new application directory is created for every top level folder and is automatically linked to the
folder as the 1st directory of the application directory path.
The application directory path is searched whenever a synonym is required to:
1. Develop a new procedure
2. Edit an existing procedure
3. Run an existing procedure
The automatic creation of this application directory and making it first in the application
directory path allows you to segregate synonyms without using Developer Workbench.
Synonyms that only pertain to one top level folder or application should be created in that
folder's application directory. Synonyms that need to be shared across all applications should
be copied or created in the baseapp directory.
Note: If a synonym with the same name exists in both application directories of the
application directory path, the first one found in the path will be used.

Web Query Groups


Web Query Groups are pre-defined to represent a specific set of functions or role. Global
Groups define a role at the Web Query product level and apply across folders whereas folder
Groups define a role at the top level folder level.
There are two global Groups are defined as follows.
Table 24-1 Global groups
Group Name

Role Description

WebQueryAdministrator

Can perform all functions in Web Query and can


access all folders.

DevWorkBench

Can connect to Web Query using Developer


Workbench.

The six folder Groups are defined as follows.


Table 24-2 Folder groups

762

Group Name

Role Description

Folder-run

Can run procedures in the respective folder.

Folder-analyst

Folder-run role plus ability to develop and run


procedures in private folders.

Folder-dev

Folder-analyst role plus ability to develop, run and


publish procedures in published folders within the
respective folder.

Folder-dba

Can manage metadata in the respective folder's


application folder.

Folder-sched

Can manage schedules and distribution lists in


the respective folder.

IBM i DB2 Web Query for i Implementation Guide

8063ch24.fm

Draft Document for Review August 30, 2013 2:37 pm

Group Name

Role Description

Folder-admin

Can manage users in the respective folder.


Note: A Folder-admin can not acquire or release
a developer or group profile license.

Each top level folder that is created will automatically have the six folder based groups
created in the Web Query repository.
For example, if you add a top-level folder named Sales, the following six groups are
automatically created:
 Sales-run. Can run reports in the Sales folder.
 Sales-analyst. Can develop and run reports in private folders within the Sales folder.
 Sales-developer. Can develop, run, and publish reports in a published folder within the
Sales folder.
 Sales-dba. Can manage metadata in the Sales folder application directory.
 Sales-sched. Can manage schedules and distribution lists in the Sales folder.
 Sales-admin. Can add a user to or remove a user from the Sales folder group.
Users are added to one or more groups to provide the functionality they require to perform
their job. This is done using the Security Center.
Note: The group permissions are additive, not progressive. That is, if you want a user to
have schedule and admin rights, you have to add them to both.

24.2 Migrating from Release 1.1.x


The 2.1.0 release introduces a number of new concepts and terms that are documented in
chapter 24.1, New concepts and terms in Web Query 2.1.0 on page 760. It is important that
you read this chapter very carefully.
Users, group profiles, and content can be migrated from Web Query Release 1.1.x 5733QU2
to Release 2.1.0 5733WQX.

24.2.1 Migrating Web Query Users, Group Profile License Information and
Metadata
Web Query Release 2.1.0 introduces a new security model. A key component of this security
is the Group which is best described as a set of operations that formulate a role. The following
table maps Release 1.1.x authorizations to the new Groups defined in Release 2.1.0.
Table 24-3 Group map
Release 1.1.x Profiles

Release 2.1.0 Groups

MUdomain profile

Folder-run

MDdomain profile

Folder-dev, Folder-dba

MRADMIN

WebQueryAdministrator

MRSCHEDULE

Folder-sched

Chapter 24. Migration Considerations

763

8063ch24.fm

Draft Document for Review August 30, 2013 2:37 pm

The post install exit program migrates both metadata and profile licenses during the product
installation.
 When the base product is installed, the metadata is copied to the new directory structure.
 When option 4 Web Query Developer Users is installed, the named user licenses are
migrated from QU2 base to WQX option 4.
 When option 6 Web Query Runtime Enablement Groups is installed, then licensed group
profiles are migrated from QU2 base to option 6.
For example, when option 4 Web Query Developer Users is installed, the QU2 administrators
are migrated as WebQueryAdministrator group users, the QU2 domain developers are
migrated as Folder-dba group users, the QU2 report schedulers are migrated as
Folder-sched group users.

24.2.2 Migrating Web Query Content


The content includes Domains, Reports, HTML files, Stylesheets, and images. Report Broker
content can be migrated as well. This includes schedules and distribution lists.
Content migration executed at first startup (STRWEBQRY) the Web Query 2.1.0, Reporting
Server must be active (that is, successfully started) for the migration to occur. Content
migration is a one-time thing on first successful startup after install. If after the migration you
add or change reports in QU2, those items are not automatically migrated to WQX..
Note: Content migration may take several minutes. Status message is displayed.

In Web Query Release 2.1.0, the term Domain is no longer used. The new terminology is a
top level folder. Domains will map directly to a top level folder. A Domain's folders map to sub
folders. Procedures, HTML files, bitmaps and stylesheets are still relative terms.
The following table maps Release 1.1.x objects to Release 2.1.0 objects:
Table 24-4 Object map
Release 1.1.x

Release 2.1.0 Object

Domain

Top Level folder

Domain folders

Sub folder

With the Release 2.1.0, the best practice for users is to use the new top level folder and app
folder association as opposed to using the baseapp approach. Using this best practice, an
app folder with the same name as a newly created top level folder will be created and linked to
that top level folder. Creating and managing metadata in the linked app folder is the best
practice.

24.3 Other Considerations


Command Proxies
During Web Query 2.1.0 installation, the command proxies in QSYS are switched to the new
product. So STRWEBQRY, ENDWEBQRY, and the other Web Query commands will be
directed to the new release unless they are qualified QWEBQRY77 or QWEBQRY76.

764

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch24.fm

Security model
According to the new security model of Web Query Release 2.1.0, after migration, the top
level folder directory, subdirectories, and the metadata files are owned by QWQADMIN. A
unique authorization list is created at time of folder creation to secure the folder and it's
metadata files. Users are added to the authorization list and their authorities correspond to
their permission group assignments in the Security Center. QWQADMIN have all access and
other users will have only read access. Public will have no access.

Coexistence between 1.1.x and 2.1.0


While WQX base is in 70-day trial, both products can run concurrently and function
independently. This allows time to test (convenience and flexibility) before switching
production to the new release. After WQX is keyed, either product can be active, but not
both. If QU2 is already active when WQX is started, WQX will fail to start. If WQX is active
before QU2, it will use the 11331 port; QU2 can be started, but users will be unable to login.
During migration, content is copied from QU2 to WQX, but the QU2 content (reports,
schedules, metadata) remains intact.

NLS setting
In Web Query 1.1.x, for non-English clients, they had to configure the client NLS settings for
their codepage in the Web Query administrator console. In Web Query 2.1.x, the client is
migrated to Unicode for compatibility with any Language setting on the login page.

Items not migrated


After Web Query 2.1.0 installed, some items are not migrated: configurations, custom
settings, connections, additional adapters (Microsoft SQL Server and JD Edward adapters).

Chapter 24. Migration Considerations

765

8063ch24.fm

766

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ch26.fm

25

Chapter 25.

IBM i Business Intelligence


Solution
DB2 Web Query for i provides analytical (business intelligence) capabilities for end users.
One of the critical success factors of any business intelligence application is delivering that
information to those end users (analysts) to meet their requirements related to timing. Some
analysts require real time access to information in a self-service model (no dependency on
someone else to run reports for them). Others may find that having reports run in batch mode
and delivered to them overnight meets their needs. Still others may view complex analysis
jobs as needing to be done as efficiently as possible but not expecting that to be
instantaneous.
In other words, setting expectations on performance of the BI environment and implementing
a solution that meets those expectations can make or break a BI project.
In some cases, the best way to achieve those performance requirements may be to isolate
and optimize the analytics workload from other production workloads.
In this chapter we introduce, provide, describe, or discuss...

Copyright IBM Corp. 2012. All rights reserved.

767

8063ch26.fm

Draft Document for Review August 30, 2013 2:37 pm

25.1 Operational Data Stores, Data Marts, and Data


Warehouses
Separating the analytics workload could involve creation of an isolated, optimized
system/database for improving performance while not negatively impacting production
systems.
An Operational Data Store (ODS) is a replicated image of your production database. It may
not be an exact replica, but is close to it. Some minimal data transformations may alter the
data upon movement into the ODS, such as elimination of unimportant fields/columns, or
transforming codes into descriptive names.
Data marts and data warehouses take that isolated reporting repository beyond a mirrored
image of the database, adding much more data transformations of the data to support
analytics. For example, creation of a surrogate key to manage the consolidation of two
databases with customer information but non-unique customer IDs is a common data
warehouse data transformation.
For IBM i customers, an optimized environment for analytics while leveraging your skills and
administrative functions and policies needs serious consideration in meeting the performance
expectations of your analysts!

25.2 Introducing the new IBM i for Business Intelligence


Solution
IBM i for Business Intelligence is a packaged solution that is easy to order and easy to
implement, a perfect choice for improving your capability to analyze data -turning it into
information that can help transform your business.
Demonstrate immediate results with Operational Reporting and transition into a robust Data
Warehouse, based on your business demands.
This solution combines the strengths of Power Systems, IBM i, DB2 for i, DB2 Web Query for
i, and data transportation software to deliver an integrated platform that houses the extracted
and transported data sourced from your production systems.
IBM i for Business Intelligence comes with what you need to start-up your reporting
environment and it is ready when you are as an expandable, growth platform to extend your
data analytic capabilities, transforming sourced data by leveraging additional ETL tooling and
services to build a Data Warehouse.
This new solution is offered as three configurations (small, medium, and large) that include
software and required licensing, as well as getting started services designed to get you up
and running fast - no long wait times before you can show new business information to your
execs.

25.2.1 DB2 Web Query for i Standard Edition


Included in the IBM i for BI solution is the Standard Edition of DB2 Web Query. This product
provides a very robust set of functions to support the ad-hoc, self-service reporting
requirements, to the batch oriented automated report execution and distribution.

768

IBM i DB2 Web Query for i Implementation Guide

8063ch26.fm

Draft Document for Review August 30, 2013 2:37 pm

Include data from any Microsoft SQLServer database into your applications with the included
data adapter for SQLServer. Integrate reports into customized web based applications with
the ability to invoke DB2 Web Query functions programmatically.
Analytical functions in Standard Edition include mobility support, spreadsheet integration, and
onLine analytical processing.

Improve performance and simplify management


IBM has spent over a decade building features into DB2 for i for improved query performance
and simplified management, including many functions automated by DB2 for i when
processing queries. The DB2 for i SQL Query Engine (SQE) can improve performance over
five times from previous technology. Take advantage of advanced indexing and statistic
technologies, along with the ability to create and store aggregate (summary) data for best
performance. These technologies are especially important in processing the types of
requests typical in a reporting environment where analysts want to view summarized data
and then drill into it. The On Demand Performance Center simplifies the ability for an
administrator to understand how DB2 is processing queries and provides advice on steps to
take to improve runtime performance.

Reduce I/T support efforts


The IBM i for BI solution also includes installation services such that you can get up and
running with your ODS in a matter of days.
By leveraging the operational and administrative functions that you already have built around
your current IBM i on Power Systems environment allows you to minimize costs and risk,
while still providing an appliance-like optimized solution for DB2 Web Query analytics!
Unlike true "appliances", the multi-core, partition capable systems available in the three sized
of the IBM i for BI solution can be expandable for other purposes.
Implement a combined ODS and disaster recovery system, or take advantage of POWER7
resources to run other applications, including AIX or Linux operating system based apps.
Get the advantages of an appliance without the lock in of only using it for a single purpose!

Chapter 25. IBM i Business Intelligence Solution

769

8063ch26.fm

770

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ch27.fm

26

Chapter 26.

Adapter for Microsoft SQL Server


The DB2 Web Query Adapter for Microsoft SQL Server extends your reporting environment
by incorporating access to data stored in one or more Microsoft SQL Server databases.
Current versions supported are 2000, 2005, and 2008.
Although the majority of your data is likely in DB2 on i, access to data stored in Microsoft SQL
Server databases may also be key to creating desired reports. By installing DB2 Web Query
Standard, you can seamlessly incorporate SQL Server data in your reports in real time
without the need of a complex replication process. The Microsoft SQL Server adapter allows
your organization to use a single query and report writing tool, DB2 Web Query, to access all
of the necessary data for your reports.
In earlier chapters you learned how you can extend the value of the information stored in DB2
for i by doing online analytical processing, active reports, dashboards, and automatic report
distribution. With this adapter, you can do the same with information stored in your Microsoft
SQL Server databases.
This chapter will take you through the steps necessary to establish a connection to your SQL
Servers. But, before we get started, you must install the option.

Copyright IBM Corp. 2012. All rights reserved.

771

8063ch27.fm

Draft Document for Review August 30, 2013 2:37 pm

26.1 Installation
To begin, you must install Web Query Standard Edition. Also make sure that you have the
latest PTF group installed for DB2 Web Query.
Due to Microsoft's licensing agreements, we are unable to ship required code as part of the
Web Query package. Therefore, to complete the installation you must install a version of
Microsoft's JDBC driver for SQL Server on your system.
To determine which version to download, we briefly discuss versions. Microsoft currently
offers four levels of its JDBC driver. Version 1.1 is designed for SQL Server 2000, Version 1.2
for SQL Server 2005 and Version 2.0 for SQL Server 2008. At the time of writing, Web Query
only supports the 1.1 , 1.2 and 2.0 versions of the JDBC driver.
When configuring Web Query, we can only configure it for one level of the driver, either 1.1 ,
1.2 or 2.0. If you have only SQL Server 2000 servers, we recommend using Version 1.1. If
you have only SQL Server 2005 servers, you must use Version 1.2. If you have SQL server
2008 you need to use Version 2.0. Version 2.0 is also backwards compatible to SQL Server
2000 and SQL Server 2005. Therefore, if you are in doubt as to which version of driver to
choose, we recommend the 2.0 version, as that will work with all levels of SQL Server.
As we are discussing configuration settings, it is important to note that the settings are tied to
the driver level and not the level of SQL Server. Let us assume that you are using the 1.2
version to connect to both SQL Server 2000 and 2005 servers. Even when you are defining
the connection to the SQL Server 2000 server, you follow the settings for the 2005 server
since those correspond to the 1.2 version of the driver that you are using.
So now that you know which version of the driver you want to download, use your favorite
search engine or Microsoft.com to find links to the 1.1, 1.2 or 2.0 version of the JDBC driver.
Searching for Microsoft SQL Server JDBC Driver" usually returns the correct page at the top
of the results. If prompted, download the UNIX version of the driver, not the Windows version.
This will download a tar/gz package containing the required Java Archives (JAR) files. Use
your favorite decompression utility, such as the open source 7-Zip, to extract the required
files. For Version 1.1 of the driver the files are msbase.jar, mssqlserver.jar, and msutil.jar.
For Version 1.2 of the driver, it is just one: sqljdbc.jar. For Version 2.0 of the driver the files
are sqljdbc.jar and sqljdbc4.jar.
Once you have the JAR files, FTP them in binary mode or use a mapped drive to put them
onto the system. The JAR files must be placed into the Java Extensions directory located at
/QIBM/UserData/Java400/ext. If you choose version 2.0, only copy the sqljdbc4.jar to the IFS.
By placing them in this directory we do not have to worry about setting the proper classpath.
This directory is always included.

26.2 Establishing a connection to your MS SQL Server


To configure the adapter within DB2 Web Query, you must provide both connection and
authentication information. In this example we show how to configure the SQL adapter for
Microsoft SQL server 2008 using the JDBC driver Version 2.0 (sqljdbc4.jar) To configure
the adapter from DB2 Web Query, follow these steps:
1. Log on to Web Query as a developer or an administrator.
2. Right Click the Century Electronics top folder, choose Metadata and then select New

772

IBM i DB2 Web Query for i Implementation Guide

8063ch27.fm

Draft Document for Review August 30, 2013 2:37 pm

3. A new pop up window will appear. From this window expand Available , expand SQL, and
the expand MS SQL Server. You will see three possible MS SQL Server versions (2000
for Version 1.1 of the driver, 2005 for Version 1.2 of the driver or 2008 for Version 2.0)
represented. Again, choose the version that matches the level of driver that you installed,
which may not be the same as the level of SQL Server to which you are connecting. For
this example Right click 2008 (Unicode Optional) and click Configure.

Figure 26-1 Configure New SQL Adapter

4. The Add MS SQL Server 2008 to Configuration is presented.

Figure 26-2 Add MS SQL Sever Configuration

5. In the configuration panel, name your adapter as desired. In this example the connection
name is called SQLTEST. This can be any name that you want.
6. Enter the URL location for your SQL Server data source. This consists of the driver prefix,
the separator (://), followed by the host name (location) of the SQL Server, the separator
(:), and the port, in the format as follows:
prefix://hostname:port
If you are using the 1.1 version of the driver (2000), the prefix is jdbc:microsoft:sqlserver. If
you are using the 1.2 version (2005), the prefix is jdbc:sqlserver. If you are using the 2.0
version (2008), the prefix is jdbc:sqlserver . The host name for your system can be either
the DNS name (sqlserver.mycompany.com) or dotted IP address (1.2.3.4). If you use a

Chapter 26. Adapter for Microsoft SQL Server

773

8063ch27.fm

Draft Document for Review August 30, 2013 2:37 pm

DNS name, make sure that IBM i can resolve it by doing a simple PING from the
command line to the SQL Server's DNS name.
The final piece of this URL is the port number. The default port for the SQL Server is 1433.
However, not all SQL Servers run on that port. To find your SQL Server's port number, do
the following. First open up the Windows Task Manger. Add the PID (Process ID) column
by clicking View Select Columns Check the PID option OK. Find the image
name sqlservr.exe and record its PID. Then open a command prompt and run netstat
-a -n -o and look for the matching PID number. Under the Local Address column will be
0.0.0.0:xyz. The value xyz after the colon is the port number.
Assume that the DNS name of our SQL server is sqltest.rchland.ibm.com, the port is
1433, and the version of the driver is 2.0. The URL would then be:
jdbc:sqlserver://sqltest.rchland.ibm.com:1433
If the above were the same but using the 1.1 version of the driver, the URL would then be:
jdbc:microsoft:sqlserver://sqltest.rchland.ibm.com:1443
7. Select for Security the option Explicit and provide a SQL Server user and password
necessary for authentication. All connections to the SQL Server will use this profile.
Therefore, it is important that this profile is granted access to all tables to be accessed in
the SQL Server. In this example, a user of sqltest and corresponding password was
provided. This will be unique to your location.
8. The final step is to enter the driver name. This tool is varied with the version of the driver. If
you are using the 1.1 driver, enter com.microsoft.jdbc.sqlserver.SQLServerDriver for
the driver name. If you are using version 1.2 of the driver, enter
com.microsoft.sqlserver.jdbc.SQLServerDriver for the driver name. If you are using
version 2.0 of the driver use com.microsoft.sqlserver.jdbc.SQLServerDriver
9. Do not be concerned that the CLASSPATH is NOT SET, provided that you posted the
JDBC driver JAR file in the above directory location. Web Query will find the necessary
driver.
In our example the final configuration panel is as shown in Figure 26-3

Figure 26-3 Add MS SQL Server

10.If you want to make sure that you configuration is correct click the test button. If your
configuration is valid a new web page will open containing a result set from your SQL
Server as shown in Figure 26-4

774

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ch27.fm

Figure 26-4 Validating SQL Settings

11.Click Configure once the appropriate information is provided.You will receive a message
stating that you about to change Servers Configuration (Figure 26-5). Click Ok.

Figure 26-5 Message Server Configuration

12.Once you have configured the new adapter you should restart the DB2 Web Query
servers before moving on to create metadata. Use the ENDWEBQRY and STRWEBQRY
commands.

26.3 Creating Metadata


Just as in Chapter 3 Defining Metadata, once you have established a connection to a data
source, you can create various synonyms over the data (tables, views, stored procedures) at
that data source that you want to query.
1. Again, Right Click the Century Electronics top folder, choose Metadata and then select
New.
2. In the Adapter pane you should now see your MS SQL Server as a data source.
Right-click the newly created connection and select Create Synonym, as shown in
Figure 26-6 on page 776.

Chapter 26. Adapter for Microsoft SQL Server

775

8063ch27.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 26-6 Creating Synonyms SQL Server

3. Defining this synonym is a two-step process. You will first see a panel similar to
Figure 26-7.

Figure 26-7 Identify the Target Database

First identify the target database on the SQL Server. Remember, SQL Server is different
from IBM i in that is has a concept of multiple databases. Within each of those databases
are the schemas that contain the tables. In this example, we have imported the
QWQCENT sample database so that it appears in the Select database list. In this example
only table objects are requested from the selected database.
4. Click Next to advance to the second step.
5. In the second step, select the tables that you are interested in querying.
In this example, the selection is the Orders table and specifying the With foreign keys
option.

776

IBM i DB2 Web Query for i Implementation Guide

8063ch27.fm

Draft Document for Review August 30, 2013 2:37 pm

Provide the prefix or suffix if desired and click Create Synonym once you have selected
the tables of interest. As a best practice, we recommend using the schema name followed
by an underscore as the prefix and a suffix such as _mssql. This way, your Order table
appears as qwqcent_Orders_mssql. This groups all items from the HumanResources
schema together and provides you with a reminder that this data source is from a SQL
Server, as shown in .

Figure 26-8 Selected Table from the Imported qwqcent into SQL

6. Click Create Synomyn.


7. You will see a summary completion panel similar to Figure 26-9. Close that window.

Figure 26-9 Create Synonym Completion Message

8. You now have a synonym that is specific to tables located in a database on a MS SQL
Sever. You can now use this new synonym to build reports using InfoAssist, or Developer
Workbench, exactly the same way that you do with local data synonyms.

Chapter 26. Adapter for Microsoft SQL Server

777

8063ch27.fm

Draft Document for Review August 30, 2013 2:37 pm

26.4 Additional SQL Server Adapter information


For additional information about the DB2 Web Query SQL Server adapter, a documentation
PDF file is located under the documents link on the DB2 Web Query Getting Started page
located at:
http://www.ibm.com/systems/i/software/db2/webquery/gettingstarted.html
Some of the information available in this document is:
 How to customize your SQL Server environment
 How to call SQL Server stored procedures
 Information about SQL Server data types

778

IBM i DB2 Web Query for i Implementation Guide

8063p04.fm

Draft Document for Review August 30, 2013 2:37 pm

Part 4

Part

Appendixes
In this section we have included several appendixes for your convenience.
 Appendix A, Date and time functionality on page 781
 Appendix B, DB2 Web Query System Variables on page 831
 Appendix C, Change management considerations on page 833

Copyright IBM Corp. 2012. All rights reserved.

779

8063p04.fm

780

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ax01.fm

Appendix A.

Date and time functionality


Date and time components are very critical in querying and reporting. DB2 Web Query
provides a variety of ways to provide these key elements in your reporting environment. This
appendix contains many of the details needed for including date and time elements in your
reports and charts.

Copyright IBM Corp. 2012. All rights reserved.

781

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Date and time system variables


Table 26-1 lists the date and time variables that are available in DB2 Web Query. These
variables can be specified in the headings and footers at the report and page level, as well as
used in define fields.
Table 26-1 Date and time variables
System
variable

Description

Format or
value

Example (for
October 07,
2012)

&DATE

Returns the current date

MM/DD/YY

10/07/2012

&DMY

Returns the current date

DDMMYY

071012

&DMYY

Returns the current (four-digit year) date

DDMMCCYY

07102012

&MDY

Returns the current date. Useful for numerical


comparisons

MMDDYY

100712

&MDYY

Returns the current (four-digit year) date

MMDDCCYY

10072012

&TOD

Returns the current time that the query was


executed

HH.MM.SS

15.50.07

&YMD

Returns the current date

YYMMDD

121007

&YYMD

Returns the current (four-digit year) date

CCYYMMDD

20121007

&DATEWtr

Returns the full name of the day of the week

Name of day
of week

Wednesday

&DATEMtrDYY

Returns the name of the month followed by


the day and the four digit year

Name of
month DD,
YYYY

October 7,
2012

&DATEWtr,
&DATEMtrDYY

Returns the full name of the day of the week,


followed by the name of the month, followed
by the day and the four-digit year

Name of day
of week,
Name of
month DD,
YYYY

Wednesday,
October 7,
2012

Date format
The various date formats enable you to define a field as a date and work with it as a date.
Using the date format, you can perform the following tasks:
 Define date components, such as year, quarter, month, day, and day of week, and extract
them easily from the date fields.
 Sort reports into date sequence, regardless of how the date appears. For example,
January sorts before April even though, without date smarts, April alphabetically comes
before January.
 Do arithmetic with dates and compare the dates without resorting to special date-handling
functions.

782

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

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 Table A-1.

Note: Use of these format options may result in queries that do not translate the date
formatting to SQL. This can result in a query that does not perform optimally. If you
experieience this, you should explore other techniques to convert your date formats. These
alternative methods are discussed later in this chapter.
Table A-1 Date format options
Display option

Meaning

Effect

Day

Displays a value from 1 to 31 for the day.

Month

Displays a value from 1 to 12 for the month.

Year

Displays a 2-digit year.

YY

Four-digit year

Displays a 2-digit year.

Translate month

When used with M in a date (MT or TM), the 3-letter


abbreviation for the month in uppercase is displayed.

Translate month

When used with M in a date (Mt or tM), the 3-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.

Quarter

Displays the quarter Q1Q4.

Day of week

On its own, W displays the number of the day of the


week (17, Mon=1). Used in combination with other
date options, W displays a 3-letter abbreviation of the
day of the week in uppercase.

Day of week

Functions as uppercase W (described previously),


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 4-digit year and the
number of days counting from January 1. For example,
January 3, 2001 in Julian format is 2001003.

Appendix A. Date and time functionality

783

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Table A-2 shows samples of output for various date formatting options.
Table A-2 Sample output for date formatting options
Translation

Display

MT

JAN

Mt

Jan

MTR

JANUARY

Mtr

January

WR

MONDAY

wr

Monday

Q1

YQ

07Q1

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. The year-quarter format is displayed with the year and
quarter separated by a blank (for example, 12 Q3 or Q3 2012). 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 be
eliminated entirely. Table A-3 shows the FORMAT specifications that can be used to change
the separating character.
Table A-3 Date separators

784

Format

Display

YMD

12/09/22

Y.M.D

12.09.22

Y-M

12-09

YBMBD

12 09 22 (The letter B signifies blank spaces.)

Y|M|D

120922 (The concatenation symbol | eliminates


the separation character.)

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Using date fields


Table A-4 shows valid examples of specifying dates.
Table A-4 Examples of specifying the dates
Situation

Natural date literal

In WHERE screening

WHERE MYDATE IS 'SEP 22 2012'

In arithmetic expressions

MYDATE - '2012 SEP 22'

In computational date comparisons

IF MYDATE GT '22 SEP 2012'

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, NEWQUARTER and THISQUARTER both have FORMAT
specifications of Q and the value of THISQUARTER is 2. In this case, consider the following
statement:
NEWQUARTER = THISQUARTER + 3
This statement 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


Can DB2 Web Query handle my legacy date fields?
That is a good question. Dates and times are vital business dimensions that are required in
most business reports. After all, how often do you create a report against data in your
database without filtering, sorting, or aggregating the data against a date-related or
time-related field? For most reports, the date and time dimension is an integral piece of
information.
When it comes to storing date values in their database files, many IBM i shops use legacy
date data types. Legacy dates are typically defined as numeric or alphanumeric fields that
contain numbers or character strings that represent the date. An example of this is a field
defined as zoned decimal (8,0), which contains the value 06152012 to represent the date
June15, 2012. However, to DB2 Web Query, this field is nothing more than a decimal field.
However, to DB2 Web Query, this field is nothing more than a decimal field and it is not
recognized as a date data.
But getting back to the original question, the answer is that, yes, DB2 Web Query can handle
your legacy date fields. This section describes how to implement two different techniques for
converting legacy date formats to fields that DB2 Web Query recognizes as true date fields
(also referred to as smart dates).

Appendix A. Date and time functionality

785

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

When the tool recognizes fields as dates, it can provide additional reporting features:
 Advanced date and time manipulation, calculations, and analysis
 Report selection parameters that can be specified by invoking JavaScript calendar
widgets for a more user-friendly experience
 Date decomposition to break the date into separate fields that represent the year, quarter,
month, and day
All of these things enable the report developer to deliver a report that is easy to use and to
provide the report formatting and information that is required.
This section focuses on date conversions. Two types of conversions are possible:
 Format conversion
 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 by specifying different date components. For example, the value
of REPORTDATE (DMY) can be assigned to SALESDATE (Y). In this case the year is
extracted from REPORTDATE. If REPORTDATE is Apr 27 99, SALESDATE is 99.

Changing the usage


Before you begin with any actual date conversion efforts, you first must determine whether
date conversions in your company's DB2 Web Query environment are even necessary. You
may be ahead of the curve and have already implemented true date and time fields in your
DB2 for i production database. If this is indeed the case, and you simply want to display the
dates in your reports differently from how they are stored in the database, all that may be
necessary is changing the Usage attribute in the file's DB2 Web Query synonym. For
example, perhaps you are storing the date columns in YYMD format and simply want those
dates to appear in DMYY format on your reports.
Note: YYMD is the short name used to refer to the actual YYYY/MM/DD format. Similarly,
MDYY refers to the full MM/DD/YYYY format.
In this exercise, you will convert the order date field from the YYMD format (as it is stored in
the database) so that it is displayed in MDYY format on a DB2 Web Query report.
1. From your browser session, log into DB2 Web Query as a developer.
2. From your Century Electronics folder, create a new report.
3. From the list of synonyms, select cen_orders as the reports data source.

786

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

4. In the InfoAssist tool, from list of available fields, select ORDERDATE, LINETOTAL, and
COSTOFGOODSOLD and drag them into the Interactive Design View pane.
When you have finished the report should look like the example provided in Figure A-1.

Figure A-1 Revenue by Order Date report

5. Save the report as Revenue by Order Date.


6. Run the report. In this report (Figure A-2) you see revenue and cost of goods sold ordered
and grouped by order date.

Figure A-2 Results of Revenue by Order Date report

Appendix A. Date and time functionality

787

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

This is a useful report, but suppose that your users really want the order date shown in MDYY
format. Because the order date field in your database is defined as YYMD format, you must
take additional steps to override this attribute when displaying the date field in a DB2 Web
Query report. These steps involve changing the usage value of the order date field as defined
in the synonym of the file this report is based on.
To update the synonym you will use DB2 Web Query Developer Workbench.
7. Open DB2 Web Query Developer Workbench and open a connection to your environment.
8. Expand Data Servers EDASERVE Applications baseapp.
9. Find and right-click the cen_orders.mas synonym file and select Edit in Synonym Editor
from right-click menu.
The synonym editor is opened.
10.Select the ORDERDATE field. Notice that this is a true DATE field (see the ACTUAL
attribute) and its USAGE value is YYMD (which is how it is defined in the database). As
shown in Figure A-3, override this attribute by selecting MDYY from the Date Order setting
under USAGE.

Figure A-3 Change date order

11.The USAGE field changes to MDYY. Click the save icon to save this change.

788

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

12.Return to your DB2 Web Query browser session and click the Revenue by Order Date
report again to run it.
Notice that the Order Date column is now presented in MDYY format (Figure A-4).

Figure A-4 Results of revenue by order date after changing usage

Using DB2 Web Query functions to convert to dates


Changing the usage field may be enough if your date fields are defined as true date fields in
your database and all you want to do is change the month-day-year order of how the date is
displayed. However, as mentioned earlier, if you are like many IBM i shops, you probably have
date fields defined as a data type other than date or time stamp (because these data types
were not supported by the RPG compiler until V3R1 of the operating system). Consequently,
you may have date fields defined as packed decimal (8,0), which contain the value 04102008
to represent the date April 10, 2008.
In this exercise, the file used has packed decimal (8,0) date fields with this MDYY format. You
use the DB2 Web Query built-in functions (BIFs) to convert these fields to virtual fields that
are defined as a true date. This true date field is used as the basis for other virtual columns in
other formats such as year and day of the week.

Appendix A. Date and time functionality

789

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Attention: You could also create these virtual fields in the synonym (rather than in the
report). In fact, this is the recommended approach, but for the purpose of this exercise, the
conversions are performed in the report definition.
You create a report that uses these virtual fields is in a two-dimensional format:
 Sorted/grouped vertically by the year of the order
 Sorted/grouped across by the name of the day of the week
The measure shown for each of these groupings will be the aggregated order amount.
To perform date conversions using the DB2 Web Query BIFs, follow these steps:
1. Open DB2 Web Query in a browser session and log in.
2. Create a DB2 Web Query synonym over the LEGACY_ORDER_HEADER table. Give it a
prefix of cen_.
3. Create a new report in the Century Electronics folder
4. From the list of displayed synonyms, select CEN_LEGACY_ORDER_HEADER as the
data source, as shown in Figure A-5.

Figure A-5 Select synonym

790

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

e. In InfoAssist, create a New define field by selecting the Data and selecting the Detail
(Define) icon, as shown in Figure A-6.

Figure A-6 Create new define field

To convert the packed decimal fields to dates, use the DATECVT function. This function
converts the field value of any standard date format or legacy date format into a new date,
in either the desired standard date format or the legacy date format. These are the
parameters for this function:
date is the input legacy field to be converted.
in_format is the format of the input legacy date (for example, P8MDYY, I8MDYY,
I6YMD, and A8MDYY).
output_format is the output date format (for example, YYMD, YQ, M, DMY, and JUL).
5. From the Define Field Creator window, specify the following, then click OK:
Field: OrderDate (This is the new virtual column name.)
Format: MDYY (This is the output date format of the new virtual column.)
Expression: DATECVT( ORDDAT, 'P8MDYY', 'MDYY' )
An example is provided in Figure A-7.

Figure A-7 Define field for ORDERDATE

Appendix A. Date and time functionality

791

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Note: ORDDAT is a Packed Decimal (8,0) field. If you inspect the DB2 Web Query
synonym for the this field, you will notice that it is defined as P9 (rather than P8). This is
normal. The extra digit is used to store the decimal point. For the purposes of date
conversion, always ignore extra digits when specifying the value of the input format
parameter. In this case the value should be P8MDYY.
6. Create another define field to display just the year of the OrderDate column. Specify the
following attributes, then click OK:
Field: OrderYear
Format: YY
Expression: OrderDate
An example is provided in Figure A-8.

Figure A-8 Define field for ORDERYEAR

7. Create another define field to display the day of the week (MON, TUE, and so on) of the
OrderDate column. Specify the following attributes, then click OK:
Field: OrderDayOfWeek
Format: WT
Expression: OrderDate
An example is provided in Figure A-9.

792

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure A-9 Define field for ORDERDAYOFWEEK

Attention: A full list of date display formats can be found in Date format display
options on page 783.
8. Finish the report by performing the following:
a. Drag the new OrderYear field into the Sort by panel.
b. Drag the OrderDayOfWeek field into the Sort across panel.
c. Drag the ORDAMT field into the Sum pane and select it. Click the Show field options
icon for this field.
d. Edit the format of the ORDAMT field. Specify comma inclusion and floating currency.
e. When finished, the report definition should look like the example provided in
Figure A-10.

Appendix A. Date and time functionality

793

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure A-10 Report using Define fields for date conversion

9. Run the report. It should look like the example displayed in Figure A-11.

Figure A-11 Results of report that uses define fields for date conversion

10.Save your report as Date conversion using Web Query functions.


11.CloseInfoAssist.

Using date conversion table to convert to dates


Also referred to as a calendar table, a date conversion table is simply a DB2 for i table that
contains one row for each individual day within a specified date range. Each row is made up
of columns that represent the same date value in various ways (for example, the day of the
week). Your reporting and business intelligence requirements will dictate how many date
value representations you add to your conversion table. For example, a date conversion table
could include the following columns:




794

Julian date
Date (a true DB2 date field)
Fiscal year
Fiscal quarter

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm













Day of the week (Monday, Tuesday, and so on)


Month of the year (January, February, and so on)
Season (spring, summer, autumn, winter)
Same day (of the week) last year
Week ending date
Week of the year
Super Bowl Sunday flag (Y or N)
Day before a holiday flag (Y or N)
Day after a holiday flag (Y or N)
Full moon flag (Y or N)
And so on

In order for this technique to work, the date conversion table must have a column that
represents the date in the same format as the legacy file. You then define an inner join from
the legacy file to the date conversion table using the legacy date fields as the join columns.
This can be done with any of the following techniques:





Implementing Referential Integrity (setting up Primary and Foreign Keys)


Creating an SQL view with syntax to join your legacy files to the date conversion table
Defining the join in the DB2 Web Query synonym
Defining the join in each DB2 Web Query reports/graphs

When the report is run, DB2 Web Query uses the chosen join definition method to generate
the SQL syntax necessary to join the legacy file and the date conversion table. For each row
returned in the legacy file, the matching row (for that date) of the date conversion table is also
returned, providing the report with all the various columns representing that particular date.
The result is a very efficient date conversion implementation and a faster-running report.
Figure A-12 illustrates how the join to the date conversion table works.
LEGACY_ORDER_HEADER file

Date conversion table

Join (RI constraints, SQL view, synonym join, report join

Figure A-12 Joining files to date conversion table

With this technique, each date format (column) in the date conversion table is available to the
DB2 Web Query development tools and therefore easily can be included in any report. This
gives the report developer the ability to effortlessly do some interesting customized analysis.
For example:
 What are the profit margins on days before and after holidays?
 How many bags of corn chips are sold the week before the Super Bowl?

Appendix A. Date and time functionality

795

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

 What is the rate of product returns on the day after Christmas as compared to any other
day of the year?
 Are more galoshes sold in the spring or the fall?
 How many boxes of diapers are sold on days when there is a full moon?
The usefulness of a date conversion table goes well beyond DB2 Web Query. It can be
implemented in any application or tool that has access to DB2 for i. If you have RPG
programs, you can join to this table (using either embedded SQL or native Record Level
Access operations such as CHAIN) to perform quick and easy date conversions. It can even
be used in your Query/400 reports.
Implementing the date conversion method is relatively simple and can be performed in the
following four steps:
1.
2.
3.
4.

Create the date conversion table.


Populate the date conversion table.
Add join segment to the synonym.
Create reports.

Creating the date conversion table


A pre-populated date conversion table named DATE_CONV is included in the QWQCENT
library. Starting in version 2.1, this library is shipped in a save file format when you install the
DB2 Web Query product 5733WQX. The name of the save file is QWQCENT and it resides in
library QWEBQRY. The QWQCENT llibrary may be updated occasionally to provide more
objects, columns, stored procedure, and other examples. So you may want to occasionally
check to see if a new version has been provided and if so, restore it. At the time this redbook
was published, DATE_CONV contained the following columns:

Column Name

Data
Length

Length

Description

DC_DATE

DATE

Date (date format)

DC_JDE_JULIAN_DATE

DECIMAL

JDE Julian Date (CYYDDD decimal)

DC_MDYY_DEC

DECIMAL

Date (MMDDYYYY packed decimal)

DC_MDYY_ZONED

NUMERIC

Date (MMDDYYYY zoned decimal)

DC_MDYY_CHAR

CHAR

Date (MMDDYYYY character)

DC_YYMD_DEC

DECIMAL

Date (YYYYMMDD packed decimal)

DC_YYMD_ZONED

NUMERIC

Date (YYYYMMDD zoned decimal)

DC_YYMD_CHAR

CHAR

Date (YYYYMMDD character)

DC_MDY_DEC

DECIMAL

Date (MMDDYY packed decimal)

DC_MDY_ZONED

NUMERIC

Date (MMDDYY zoned decimal)

DC_MDY_CHAR

CHAR

Date (MMDDYY character)

DC_YMD_DEC

DECIMAL

Date (YYMMDD packed decimal)

DC_YMD_ZONED

NUMERIC

Date (YYMMDD zoned decimal)

796

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

DC_YMD_CHAR

CHAR

Date (YYMMDD character)

DC_CC_CHAR

CHAR

Century (2 characters)

DC_YY_CHAR

CHAR

Year (2 characters)

DC_MM_CHAR

CHAR

Month (2 characters)

DC_DD_CHAR

CHAR

Day (2 characters)

DC_YEAR

INTEGER

Year (4 digits)

DC_DOW

INTEGER

Day of week (1-7)

DC_DOW_ISO

INTEGER

Day of week (1-7)

DC_DOY

INTEGER

Day of year (1-366)

DC_WOY

INTEGER

Week of year (1-52)

DC_WOY_ISO

INTEGER

Week of year (1-53)

DC_QOY

INTEGER

Quarter of year (1-4)

DC_CC

NUMERIC

Century (2 digits)

DC_YY

NUMERIC

Year (2 digits)

DC_MM

NUMERIC

Month (2 digits)

DC_DD

NUMERIC

Day (2 digits)

DC_CCYYMM

NUMERIC

Century, Year, Month CCYYMM (6 digits)

DC_DAY_NAME

CHAR

Day Name (Monday,etc.)

DC_QUARTER_NAME

CHAR

Quarter name (2008Q1)

DC_WEEKEND

CHAR

Weekend Flag (Y or N)

DC_HOLIDAY

CHAR

Holiday (Y or N)

DC_DAY_BEFORE_HOLIDAY

CHAR

Day Before Holiday (Y or N)

DC_DAY_AFTER_HOLIDAY

CHAR

Day AfterHoliday (Y or N)

DC_FULL_MOON

CHAR

Full Moon (Y or N)

DC_SEASON

CHAR

Season (Spring, Summer, Autumn, Winter)

DC_FISCAL_YEAR

INTEGER

Fiscal year (4 digits)

DC_FISCAL_QUARTER

INTEGER

Fiscal quarter (1-4)

DC_MONTH_NAME

CHAR

Month name (January, etc)

DC_MONTH_ABRV

CHAR

Month abbreviation (Jan, Feb, etc)

DC_JULIAN

NUMERIC

Date in Julian format

DC_CYYMMDD

DECIMAL

CYYMMDD packed C = 0 for 1900 & C = 1


for 2000

DC_EXCEL_DATE

INTEGER

Date in Excel format

Appendix A. Date and time functionality

797

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

DC_WEEK_STARTING_DATE

DATE

Week starting date (the prior Saturday)

DC_WEEK_ENDING_DATE

DATE

Week ending date (the next Friday)

DC_SAME_DAY_LAST_YEAR

DATE

Same day last year

DC_CURRENT_DAY

CHAR

Current Day (Y/N)

DC_CURRENT_WEEK

CHAR

Current Week (Y/N)

DC_CURRENT_MONTH

CHAR

Current Month (Y/N)

DC_CURRENT_QUARTER

CHAR

Current Quarter (Y/N)

DC_CURRENT_YEAR

CHAR

Current Year (Y/N)

DC_CURRENT_YTD

CHAR

Current Year to Date (Y/N)

DC_CURRENT_DAY_LAST_YEAR

CHAR

Current Day Last Year (Y/N)

DC_CURRENT_WEEK_LAST_YEAR

CHAR

Current Week Last Year (Y/N)

DC_CURRENT_MONTH_LAST_YEAR

CHAR

Current Month Last Year (Y/N)

DC_CURRENT_QUARTER_LAST_YEAR

CHAR

Current Quarter Last Year (Y/N)

DC_CURRENT_YEAR_LAST_YEAR

CHAR

Current Year Last Year (Y/N)

DC_CURRENT_YTD_LAST_YEAR

CHAR

Current Year To Date Last Year (Y/N)

DC_PREVIOUS_MONTH

CHAR

Previous Month (Y/N)

DC_PREVIOUS_FISCAL_YEAR

CHAR

Previous fiscal year (Y/N)

DC_CURRENT_FISCAL_YEAR

CHAR

Current fiscal year (Y/N)

DC_PREVIOUS_FISCAL_YTD

CHAR

Previous fiscal year to date (Y/N)

DC_CURRENT_FISCAL_YTD

CHAR

Current fiscal year to date (Y/N)

DC_NTH_DAY_OF_WEEK_OF_MONTH

INTEGER

Nth Day of the Week of the month

Populating and maintaining the date conversion table


As mentioned previously, a pre-populated date conversion table is included in the QWQCENT
library. Therefore, unless there are columns that you want to add or remove, you can simply
use this version of the table. If you are interested in creating a customized version, an SQL
stored procedure used to populate this table is also provided in the QWQCENT library. The

798

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

name of this stored procedure is LOAD_DATE_CONVERSION_TABLE and it creates one row


for each day on and between January 1, 1900 and December 31, 2030. You can see the SQL
source code of this stored procedure by using the Generate SQL option from System i
Navigator as shown in Figure A-13

Figure A-13 Generate SQL for LOAD_DATE_CONVERSION_TABLE procedure

Notice that several of the columns in the date conversion table are current flags that contain a
value of Y or N depending on whether the condition for that flag is met. For example, the
column DC_CURRENT_YEAR contains a Y if that row represents a date whose year is
equal to the current year. So if the current date is June 20, 2012, then the value for the
DC_CURRENT_YEAR column would be Y for all of the rows that represent dates for the
year 2012. Because these are dynamic values, you must add a process to keep these
columns in the date conversion table updated. Again a stored procedure that does this is
provided in the QWQCENT library and it is named UPDATE_DATE_CONVERSION_TABLE.
You can also see the source for this procedure by using the Generate SQL option as
described above.
To keep these current flags accurate, all you must do is make sure that the
UPDATE_DATE_CONVERSION_TABLE stored procedure runs every day. To do this, create
a job scheduler entry to call this stored procedure daily. This can be accomplished by taking
the following steps:
1. Create a source file member to store an SQL statement script:
ADDPFM FILE(QGPL/QTXTSRC) MBR(UPDDATCONV)
2. Edit this source file member and add the following SQL statement to call the stored
procedure:
CALL QWQCENT/UPDATE_DATE_CONVERSION_TABLE
3. Now add a job scheduler job to run the SQL script in the source file member:
ADDJOBJS JOB(UPDDATCONV) SCDCDE(*DAILY) TIME(0010) CMD(RUNSQLSTM
SRCFILE(QGPL/QTXTSRC) SRCMBR(UPDDATCONV) COMMIT(*NONE) NAMING(*SYS))
This job scheduler job runs daily at 1 a.m. and calls the RUNSQLSTM command to run the
script (in the specified source file member) through SQL.

Appendix A. Date and time functionality

799

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Adding join segments to the synonym


As described earlier, there are several ways that the date conversion table can be joined to
the legacy file. This section describes how to implement the join in the DB2 Web Query
synonym. In general, it is advantageous to define the joins in the synonym (rather than
individual reports and graphs) for the simple reason that this piece of logic is centralized in
one location. Each report and graph that uses the synonym will be able to use the join
segment (and not have to redefine it).
For this example, you will use the table in library QWQCENT named
LEGACY_ORDER_HEADER (the 10-character system name is ORDHDR).
1. Create a DB2 Web Query synonym over the DATE_CONV table. Give it a a prefix of cen_.
2. Open DB2 Web Query Developer Workbench and open a connection to your environment.
3. Find the cen_legacy_order_header.mas file under Data Servers EDASERVE
Applications baseapp.
4. Right-click this file and select Edit in Synonym Editor, as shown in Figure A-14.

Figure A-14 Edit cen_legacy_order_header

At this point add a join segment to the date conversion table.


5. Right-click the CEN_LEGAGY_ORDER_HEADER segment name and select Insert
Copy of Existing Synonym, as shown in Figure A-15.

800

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure A-15 Add join segment to legacy_orders_table

A list of synonyms in the BASEAPP folder is presented.

Appendix A. Date and time functionality

801

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

6. As demonstrated in Figure A-16, find and select the cen_date_conv synonym and click
Select.

Figure A-16 Select cen_date_conv synonym

The new segment is added to the synonym. Next you must change the segment type from
Multiple to Unique.
7. Select the new CEN_DATE_CONV join segment and locate the Type attribute under
SEGTYPE.

802

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ax01.fm

8. This is a drop-down list. Click it to and change the type to One to One, as shown in
Figure A-17. This instructs DB2 Web Query to rely on SQL syntax to create the join and
when accessing the joined columns (allowing you to sort and select fields across multiple
join segments).

Figure A-17 Change segment type to One to One

9. Define the fields that will be used to join the tables together. As shown in Figure A-18,
right-click again the CEN_DATE_CONV segment and select Join Properties.

Figure A-18 Select Join Properties


Appendix A. Date and time functionality

803

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

10.In the Join Properties window, do the following:


a. From the list of columns in the CEN_LEGACY_ORDER_HEADER segment, select
ORDDAT so that it is highlighted.
b. From the list of columns in the CEN_DATE_CONV segment, select DC_MDYY_DEC
so that it is highlighted. The values in the ORDDAT are in this format, thus this is the
column in the date conversion table to use as the join column.
c. Click the = icon located between the two segment lists. This action should bring the
selected join columns down into the expression pane. An example is shown in
Figure A-19.

Figure A-19 Define join columns

11.Click OK. To help the report developers identify what legacy date field this date conversion
segment represents, rename the segment to the name of the field that it is converting. If
you do not do this, the segment names to the date conversion table many be ambiguous
(your report developers may not be certain of what legacy date field they represent). This

804

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ax01.fm

is particularly true if you have multiple legacy date fields in your synonym because to
convert them you must define a join segment to date_conv for each one.
Tip: If you are very meticulous (and ambitious), you could even completely remove the
ambiguity by renaming each of the individual column names in the date conversion
segments (for example, rename DC_YEAR to ORDDAT_YEAR). This can be done by
highlighting the column and selecting Rename from the right-click menu. That is really
going the extra mile, but your report developers would very much appreciate this.
12.Highlight the segment and select Rename from the right-click menu. This is shown in
Figure A-20.

Figure A-20 Rename the segment

Appendix A. Date and time functionality

805

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

13.Specify ORDDAT as the segment name. When you are finished, your synonym will look
like the example provided in Figure A-21.

Figure A-21 Synonym with new ORDDAT segment

14.Repeat step 5 on page 800 through step 13 for the SHPDAT legacy date field field. Be
sure that you rename the segment SHPDAT.
15.Save the synonym.
16.Close the Edit synonym window.
Tip: For performance reasons, now would be a good time to create indexes over your join
columns. The DB2 optimizer will be able to use these indexes for statistics and
implementation during query execution. Here are the two SQL statements for creating
indexes over the LEGACY_ORDER_HEADER and DATE_CONV tables:
CREATE INDEX LEGACY_ORDER_HEADER_INDEX_00001 ON LEGACY_ORDER_HEADER (ORDDAT
ASC);
CREATE INDEX DATE_CONV_INDEX_00001 ON DATE_CONV (DC_MDYY_DEC ASC);

Creating reports using the date conversion table


Once the join has been defined in the synonym, the next step is to create a report over this
updated synonym. Follow these steps:
1. Return to your DB2 Web Query browser session.
2. Create a new report in the Century Electronics folder using InfoAssist.

806

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ax01.fm

3. Select the CEN_LEGACY_ORDER_HEADER synonym as the report data source.


The InfoAssist tool is presented. Notice that all of the columns from the date conversion
table now appear in the list of fields to choose from. If your default view is set to Logical,
you may notice that the list is now long and cluttered. To organize it better, click the
Structured icon under the View ribbon, as shown in Figure A-22, so that the list is
organized into a hierarchical tree view.

Figure A-22 Change to Structured view

Appendix A. Date and time functionality

807

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

As shown in Figure A-23, taking this action groups the synonym columns under their
respective segments and allows you to expand and collapse the list of columns under
each segment.

Figure A-23 Example of Structured view

4. Finish the report by performing the following steps:


a. Drag the new ORDDAT.DC_YEAR field into the By field container in the Query pane.
b. Drag the ORDDAT.DC_DOW field into the Across field container in the Query pane.
Make it an invisible field as shown in Figure A-24. DC_DOW is the numeric value of the
day of the week. You must sort by this field, but not by the name of the day of the week
field (DC_DAY_NAME). Otherwise, the data for Friday would appear first (since it is the
first day name alphabetically) and Wednesday would appear last. However, you
probably do not want the numeric day of the week value to actually appear on the
report, so hide this column in the report.

808

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ax01.fm

Figure A-24 Hide the DC_DOW column

c. Drag the ORDDAT.DC_DAY_NAME field into the Across field container in the Query
pane. Make sure it is after DC_DOW.
d. Drag the ORDDAT.ORDAMT field into the Sum field container in the Query pane and
select it. Click the Show field options icon for this field.
e. Add comma inclusion and floating currency formatting to the ORDAMT field in the
report.
When finished, the report definition should look like the example provided in Figure A-25.

Figure A-25 Report using date conversion table

5. Run the report. The results should look identical to those in Figure A-26 on page 810.

Appendix A. Date and time functionality

809

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure A-26 Results of report using date conversion table

Other than the fields and techniques used for date conversion, this is the same report that
you created in Using DB2 Web Query functions to convert to dates on page 789.
Compare the results of those two reports. They should be identical.
6. Save your report as Date conversion using date conversion table.
Tip: Now is an opportune time to create indexes over the join columns.
One of the advantages of the date conversion table method is that all of the columns in the
table will be brought into the synonyms segment and subsequently will appear in the list of
available fields in the development tools. This gives report developers the ability to easily and
effortlessly include a wide variety of date formats in your reports.
One of the disadvantages is that all of the columns in the table will appear in the list of
available fields in the development tools. Why is this a disadvantage? Because there may be
many columns in the table and some of them may never actually be used in the reports.
These columns can clutter up the list, particularly if the synonym contains many other
columns.
Furthermore, and as mentioned previously, if you have multiple legacy date fields in your file
and you want to convert them to date fields, you must create join segments to the date
conversion table for each one. This adds even more columns to the list of fields in the
development tools.
Here are some suggestions for keeping the list of available fields to a manageable size:
 Create the date conversion table with fewer columns (only the ones that your use
regularly).
 Create DB2 Web Query business views over your synonyms. This allows you to create
and organize a subset of columns to display in the report development tools. See Defining
joins in SQL views on page 58 for more information about business views.

810

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

 Set the columns Access Property to INTERNAL to hide the infrequently used columns in
the synonym. This gives you the ability to preserve the columns in the date conversion
table, while not showing them in the development tools. If they are needed for some
reports you can simply unhide them by unchecking the INTERNAL setting. Figure A-27
provides an example of how to hide DC_MONTH_NAME so that it does not appear in the
list of available columns in the report development tools.

Figure A-27 Defining a column that does not appear in list of available columns

Attention: Existing reports that reference hidden columns (those whose INTERNAL
setting for ACCESS PROPERTY is selected) will continue to run. However, if you attempt
to open such a report in the report development tools, the request will fail with a Field not
found in master file error. In those cases, you must edit the synonym and remove
(uncheck) the INTERNAL setting for ACCESS PROPERTY.

Using SQL Views and functions to convert to dates


A third technique for performing date conversions is to leverage the power of SQL functions
and reference them in SQL views. SQL functions such as DATE, YEAR, and DAYOFWEEK
can be used in an SQL SELECT statement to efficiently perform the conversions. Depending
on the legacy date data type and format, it may be necessary to use other functions such as
DIGITS and SUBSTRING. In some cases, this may result in a SELECT statement that is
somewhat lengthy. But you can hide this complexity from your report developers by creating
an SQL view over this statement and then a DB2 Web Query synonym over the view.

Appendix A. Date and time functionality

811

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

An example SQL view that uses multiple SQL functions for date conversions (over the
LEGACY_ORDER_HEADER table) is provided in the QWQCENT library. This view, named
ORDER_HEADER_VIEW, is shown in Example A-1.
Example: A-1 ORDER_HEADER_VIEW definition

CREATE VIEW ORDER_HEADER_VIEW AS


WITH t1 (
order ,
cust ,
orderdate ,
shipdate ,
shpvia ,
ordsts ,
ordamt ,
totlin ,
invnum ) AS
(SELECT order, cust,
DATE(SUBSTRING(DIGITS(orddat),5,4) || '-' || SUBSTRING(DIGITS(orddat),1,2)
|| '-' || SUBSTRING(DIGITS(orddat),3,2)),
DATE(SUBSTRING(DIGITS(shpdat),5,4) || '-' || SUBSTRING(DIGITS(shpdat),1,2)
|| '-' || SUBSTRING(DIGITS(shpdat),3,2)),
shpvia, ordsts, ordamt, totlin, invnum
FROM legacy_order_header )
SELECT order, cust, orderdate, YEAR(orderdate) AS orderyear,
DAYOFWEEK_ISO(orderdate) AS orderdow,
CASE
WHEN DAYOFWEEK_ISO(orderdate) = 1 THEN 'MON'
WHEN DAYOFWEEK_ISO(orderdate) = 2 THEN 'TUE'
WHEN DAYOFWEEK_ISO(orderdate) = 3 THEN 'WED'
WHEN DAYOFWEEK_ISO(orderdate) = 4 THEN 'THU'
WHEN DAYOFWEEK_ISO(orderdate) = 5 THEN 'FRI'
WHEN DAYOFWEEK_ISO(orderdate) = 6 THEN 'SAT'
WHEN DAYOFWEEK_ISO(orderdate) = 7 THEN 'SUN'
ELSE ''
END AS orderdayname,
shipdate, shpvia, ordsts, ordamt, totlin, invnum FROM t1
The above example performs the following:
 Converts legacy date fields ORDDAT and SHPDAT into true dates and returns them in the
derived columns named ORDERDATE AND SHIPDATE.
 Creates a second derived column named ORDERYEAR by referencing the derived
column ORDERDATE in the SQL function YEAR. This column returns the year portion of
the date.
 Creates a third derived column named ORDERDOW by referencing the derived column
ORDERDATE in the SQL function DAYOFWEEK_ISO. This column returns the integer
value of the day of the week.
 Creates a fourth derived column named ORDERDAYNAME by referencing the derived
column ORDERDATE in the SQL function DAYOFWEEK_ISO and performing some logic
in a CASE statement to return the name of the day of the week.
Notice the use of the WITH keyword to create SQL common table expressions. If you are not
familiar with common table expressions, they can be thought of as temporary views that only
812

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

exist during the execution of the query. By using them, you can define a result table with a
table-identifier (T1 above) that can be specified as the table name in any FROM clause of the
SELECT statement. Because the example uses derived columns that reference other derived
columns (ORDERDATE), a common table expression is used. It allows you to define
ORDERDATE in one place and reduce the query's complexity by minimizing the amount of
text, especially when ORDERDATE is referenced multiple times in the query.
To create the same type of report (as the previous examples) that uses this SQL view, take
the following steps:
1. Create a DB2 Web Query synonym over the view. Specify cen_ for the metadata prefix.
2. Create a new report in InfoAssist, using the new view synonym.
a. Drag the ORDERYEAR field into the By field container in the Query pane.
b. Drag the ORDERDOW field into the Across field container in the Query pane. Similar
to the report in the previous section, make it an invisible field so that the columns are
sorted by the numeric value of the day of the week rather than alphabetically by the
name of the day of the week.
c. Drag the ORDERDAYNAME field into the Across field container in the Query pane.
Make sure it is after ORDERDOW.
d. Drag the ORDAMT field into the Sum field container in the Query pane and select it.
e. Add comma inclusion and floating currency formatting to the ORDAMT field in the
report.
3. When finished, the report definition should look like the example provided in Figure A-28.

Figure A-28 Report using SQL view for date conversions

Appendix A. Date and time functionality

813

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

4. Run the report. It should look like the example provided in Figure A-29.

Figure A-29 Results of report using SQL view for date conversions

5. Save your report as Date conversion using SQL view.

Comparing the date conversion techniques


At this point, you may be wondering whether it matters what date conversion technique you
implement. From a functional standpoint, the answer is no. All three methods will provide
reliable date conversion results. However, from a report-performance perspective, the answer
is yes. Pushing the date conversion logic down to the database engine does provide
significant report performance advantages, but exactly to what degree will always vary,
depending on factors such as system resources, system activity, available indexes, the
number of rows retrieved, and the number of columns converted. But to give you some idea of
what gains can potentially be realized, a mini-benchmark was found to compare the
performance results of the two techniques. The benchmark used a 6,000,000 row ORDERS
table. The DB2 Web Query reports used were essentially identical to the two that you created
in the above date conversion exercise.
Each version of the report was run 20 times and the run time (the time between when the
user selected the report and when the report was displayed to the browser) was recorded and
averaged. The results are displayed in Table A-5.
Table A-5 Results
Date conversion technique

Average run time


(20 executions)

DB2 Web Query functions (BIFs)

1 minute, 55 seconds

Date conversion table

5.2 seconds

SQL functions using SQL. prefix

5.4 seconds

SQL functions in an SQL view

5.2 seconds

The reason why the date conversion table and SQL function techniques perform so much
better (than the DB2 Web Query BIFs) is because the conversion logic processing is pushed
down to the DB2 engine. However, these are two vastly different approaches:
 Performing database joins to locate the row with the data that is already converted
 Performing the conversions dynamically
If SQE processes the requests, both have the ability to cache the results so that subsequent
requests perform better. As you can see in the above benchmarks results, the date dimension
table performed slightly better, particularly as more conversion functions were added.

814

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

In addition, performing the conversion in SQL views and functions may require a fairly
elaborate view definition and does require some degree of SQL knowledge to implement. The
date conversion table, on the other hand, can be implemented by someone with limited SQL
skills.
Performance notwithstanding, the best technique is purely subjective. For simplicity, most
report developers would probably prefer to use the DB2 Web Query BIFs. Use of the BIFs
may provide acceptable performance in your environment, particularly for smaller databases.
Consequently, the suggested approach is to try using the DB2 Web Query BIFs first. If the
performance is not satisfactory, then consider using one of the other two techniques.
Attention: IBM and Information Builders development teams are working on ways to
improve the performance of the DB2 Web Query built-in functions, particularly those used
for date conversion. The goal is to pass as much of that logic to the database engine as
possible. DB2 Web Querys ability to internally translate the BIF to the appropriate SQL
function would provide the best of both worldsreport developers could use the BIFs for
date conversions and deliver a report that performs well.
When deciding between the date conversion table or SQL function/view method, most people
would likely find the date conversion table method to be a bit more flexible and easier to
implement. Because the information resides in a table that can be viewed and maintained, it
is easier for many to conceptualize. Implementing customized columns like fiscal year/quarter
and a Super Bowl Sunday flag is also easy because you can manually set these values in the
table and view the data. And after all, there is no SUPERBOWLSUNDAY SQL function (not
yet anyway), though one could add syntax to the view to join it with another table that has this
information.

Converting date fields in Oracles JD Edwards World application


Oracles JD Edwards World application has a very large install base on the IBM i platform.
The database for this system stores dates in a specific nonstandard format. Consequently,
many JD Edwards World customers that use DB2 Web Query must know how to handle this
specific type of date conversion.
Date fields in World are typically defined as ZONED (6,0) and are in the format CYYDDD
broken down as follows:
 C represents the century indicator:
0 for any date prior to January 2000
1 for any date on or after January 1, 2000
 YY represents the 2-digit year. Dates for the year 2012 would be stored as 12.
 DDD represents the number of the day of the year, counting from January 1. So for August
27, 2012, these digits would contain the value 239.
For August 27, 2012, the full value for this field is 112239 and for August 27, 1999, it is
009239.

Appendix A. Date and time functionality

815

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

To convert this field to a true DB2 Web Query date, use one of the following (assume that the
JDE World file is F43090 and the date field is PCCEFJ):
 DB2 Web Query BIF
Use the following expression (where PCCEFJ is the World date field):
DATECVT (((GREGDT (PCCEFJ , 'I8')) + 19000000), 'I8YYMD', 'MDY')
An example is shown in Figure A-30.

Figure A-30 Converting JDE World date

816

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ax01.fm

 Date conversion table


To implement the date conversion table method for JDE World date fields, create a join
from the World file to the date conversion table using the World date field (in this case
PCCEFJ) and DC_JDE_JULIAN_DATE as the join columns. Figure A-31 shows an
example of how to define this join in the DB2 Web Query synonym.

Figure A-31 Using date conversion table to convert JDE World date

 SQL functions/view
If you prefer the SQL functions and view technique, use something like the following to
convert the field to a date:
SELECT DATE(DIGITS( DECIMAL(pccefj + 1900000 , 7 ,0))) AS conv_date FROM f43090

Appendix A. Date and time functionality

817

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Converting other common legacy date formats


IBM i customers have represented their date fields in many different formats over the years.
Some of the more common ones and how to convert them (for each of the three techniques)
are provided in Table A-6.
Table A-6 Legacy date conversion table
Example
legacy date
field name

Legacy data
type

Legacy
date
Format

Legacy
example
(August 31,
2012)

DB2 Web Query BIF


Expression

Date conversion
table

SQL function

CH_MDYY

CHAR(8)

MDYY

08312012

DATECVT(CH_MDYY,
'A8MDYY', 'MDYY')a

Join CH_MDYY to
DC_MDYY_CHAR in
DATE_CONV table

DATE(SUBSTRING(CH_MDYY,5,4) ||
'-' || SUBSTRING(CH_MDYY,1,2)||
'-' || SUBSTRING(CH_MDYY,3,2))

CH_YYMD

CHAR(8)

YYMD

20120831

DATECVT( CH_YYMD,
'A8YYMD', 'MDYY' )a

Join CH_YYMD to
DC_YYMD_CHAR in
DATE_CONV table

DATE(SUBSTRING(CH_YYMD,1,4) ||
'-' || SUBSTRING(CH_YYMD,5,2)||
'-' || SUBSTRING(CH_YYMD,7,2))

ZN_MDYY

ZONED (8,0)

MDYY

08312012

DATECVT( ZN_MDYY,
'I8MDYY', 'MDYY' )a

Join ZN_MDYY to
DC_MDYY_ZONED in
DATE_CONV table

DATE(SUBSTRING(DIGITS(ZN_MDYY)
,5,4) || '-' ||
SUBSTRING(DIGITS(ZN_MDYY),1,2)
|| '-' ||
SUBSTRING(DIGITS(ZN_MDYY),3,2)
)

ZN_YYMD

ZONED (8,0)

YYMD

20120831

DATECVT( ZN_YYMD,
'I8YYMD', 'MDYY' )a

Join ZN_YYMD to
DC_YYMD_ZONED in
DATE_CONV table

DATE(SUBSTRING(DIGITS(ZN_YYMD)
,1,4) || '-' ||
SUBSTRING(DIGITS(ZN_YYMD),5,2)
|| '-' ||
SUBSTRING(DIGITS(ZN_YYMD),7,2)
)

PK_MDYY

PACKED (8,0)

MDYY

08312012

DATECVT( PK_MDYY,
'P8MDYY', 'MDYY' )a

Join PK_MDYY to
DC_MDYY_DEC in
DATE_CONV table

DATE(SUBSTRING(DIGITS(PK_MDYY)
,5,4) || '-' ||
SUBSTRING(DIGITS(PK_MDYY),1,2)
|| '-' ||
SUBSTRING(DIGITS(PK_MDYY),3,2)
)

PK_YYMD

PACKED (8,0)

YYMD

20120831

DATECVT( PK_YYMD,
'P8YYMD', 'MDYY' )a

Join PK_YYMD to
DC_YYMD_DEC in
DATE_CONV table

DATE(SUBSTRING(DIGITS(pk_yymd)
,1,4) || '-' ||
SUBSTRING(DIGITS(pk_yymd),5,2)
|| '-' ||
SUBSTRING(DIGITS(pk_yymd),7,2)
)

ZN_JUL5

ZONED (5,0)

YDDD
Julian
Date

12243

GREGDT(ZN_JUL5,
'I6YMD')

Join ZN_JUL5 to
DC_JULIAN in
DATE_CONV table

DATE(CASE
WHEN
INTEGER(SUBSTRING(DIGITS(ZN_JU
L5),1,2)) > 40 THEN '19'
ELSE '20'
END
||
SUBSTR(CHAR(ZN_JUL5),1,5))
)

Note: Year threshold in this


example is set to 40
ZN_JUL7

818

ZONED (7,0)

YYDDD
Julian
Date

2012243

GREGDT( ZN_JUL7,
'I8YYMD' )

IBM i DB2 Web Query for i Implementation Guide

Join ZN_JUL to
DC_JULIAN in
DATE_CONV table

DATE(SUBSTR(CHAR(ZN_JUL),1,7))

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Example
legacy date
field name

Legacy data
type

Legacy
date
Format

Legacy
example
(August 31,
2012)

DB2 Web Query BIF


Expression

Date conversion
table

SQL function

CH_MDY

CHAR(6)

MDY

083112

DATECVT(CH_MDY,
'A6MDY', 'MDYY')

Join CH_MDY to
DC_MDY_CHAR in
DATE_CONV table

DATE(CASE
WHEN
INTEGER(SUBSTRING(CH_MDY,5,2))
> 40
THEN '19'
ELSE '20'
END
||
SUBSTRING(CH_MDY,5,2) ||
'-' ||
SUBSTRING(CH_MDY,1,2)|| '-'
||
SUBSTRING(CH_MDY,3,2))

Note: Year threshold in this


example is set to 40.
CH_YMD

CHAR(6)

YMD

120831

DATECVT(CH_YMD,
'A6YMD', 'MDYY')

Join CH_YMD to
DC_YMD_CHAR in
DATE_CONV table

DATE(CASE
WHEN
INTEGER(SUBSTRING(CH_YMD,1,2))
> 40 THEN '19'
ELSE '20'
END
||
SUBSTRING(CH_YMD,1,2) ||
'-' ||
SUBSTRING(CH_YMD,3,2)|| '-'
||
SUBSTRING(CH_YMD,5,2))

Note: Year threshold in this


example is set to 40.
ZN_MDY

ZONED (6,0)

MDY

083112

DATECVT( ZN_MDY,
'P6MDY', 'MDYY' )

Join ZN_MDY to
DC_MDY_ZONED in
DATE_CONV table

DATE(CASE
WHEN
INTEGER(SUBSTRING(DIGITS(ZN_MD
Y),5,2)) > 40
THEN '19'
ELSE '20'
END
||
SUBSTRING(DIGITS(ZN_MDY),5,2)
|| '-' ||
SUBSTRING(DIGITS(ZN_MDY),1,2)|
| '-' ||
SUBSTRING(DIGITS(ZN_MDY),3,2))

Note: Year threshold in this


example is set to 40.
ZN_YMD

ZONED (6,0)

YMD

120831

DATECVT( ZN_MDY,
'P6YMD', 'MDYY' )

Join ZN_YMD to
DC_YMD_ZONED in
DATE_CONV table

DATE(CASE
WHEN
INTEGER(SUBSTRING(DIGITS(ZN_YM
D),5,2)) > threshold THEN '19'
ELSE '20'
END
||
SUBSTRING(DIGITS(ZN_YMD),5,2)
|| '-' ||
SUBSTRING(DIGITS(ZN_YMD),1,2)|
| '-' ||
SUBSTRING(DIGITS(ZN_YMD),3,2))

Note: Year threshold in this


example is set to 40.

Appendix A. Date and time functionality

819

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Example
legacy date
field name

Legacy data
type

Legacy
date
Format

Legacy
example
(August 31,
2012)

DB2 Web Query BIF


Expression

Date conversion
table

SQL function

PK_MDY

PACKED (6,0)

MDY

083112

DATECVT( PK_MDY,
'P6MDY', 'MDYY' )

Join PK_MDY to
DC_MDY_DEC in
DATE_CONV table

DATE(CASE
WHEN
INTEGER(SUBSTRING(DIGITS(PK_MD
Y),5,2)) > 40
THEN '19'
ELSE '20'
END
||
SUBSTRING(DIGITS(PK_MDY),5,2)
|| '-' ||
SUBSTRING(DIGITS(PK_MDY),1,2)|
| '-' ||
SUBSTRING(DIGITS(PK_MDY),3,2))

Note: Year threshold in this


example is set to 40.
PK_YMD

ZONED (6,0)

YMD

120831

DATECVT( PK_YMD,
'P6YMD', 'MDYY' )

Join PK_YMD to
DC_YMD_DEC in
DATE_CONV table

DATE(CASE
WHEN
INTEGER(SUBSTRING(DIGITS(PK_YM
D),5,2)) > threshold THEN '19'
ELSE '20'
END
||
SUBSTRING(DIGITS(PK_YMD),5,2)
|| '-' ||
SUBSTRING(DIGITS(PK_YMD),1,2)|
| '-' ||
SUBSTRING(DIGITS(PK_YMD),3,2))

Note: Year threshold in this


example is set to 40.
ZN_CEN
ZN_YEAR
ZN_MONTH
ZN_DAY

ZONED
ZONED
ZONED
ZONED

(2,0)
(2,0)
(2,0)
(2,0)

CC
YY
MM
DD

20
12
08
31

DATECVT( ((ZN_CEN *
1000000) + (ZN_YEAR
* 10000) + (ZN_MONTH
* 100) + ZN_DAY),
'I8YYMD', 'YYMD' )

Join legacy date


fields to the
following columns
in DATE_CONV
table:
DC_CC
DC_YY
DC_MM
DC_DD

DATE(DIGITS(ZN_CEN) ||
DIGITS(ZN_YEAR) || '-' ||
DIGITS(ZN_MONTH)|| '-' ||
DIGITS(ZN_DAY))

CC
YY
MM
DD

20
12
08
31

DATECVT( (CH_CEN ||
CHYEAR || CH_MONTH
|| CH_DAY),
'A8YYMD', 'YYMD' )

Join legacy date


fields to the
following columns
in DATE_CONV
table:
DC_CC_CHAR
DC_YY_CHAR
DC_MM_CHAR
DC_DD_CHAR

DATE(CH_CEN || CH_YEAR || - ||
CH_MONTH|| - || CH_DAY)

(Each
component of
the date is
stored in a
separate zoned
decimal
field.)
CH_CEN
CH_YEAR
CH_MONTH
CH_DAY

CHAR(2)
CHAR(2)
CHAR(2)
CHAR(2)

(Each
component of
the date is
stored in a
separate
character field.)

a. Denotes that the DB2 Web Query function is translated to SQL for optimal performance

820

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

DB2 Web Query date built-in functions


In this section we present a few of the more common DB2 Web Query built-in functions that
you can do with dates. These functions are described in more detail in the help text included
with Developer Workbench.

DPART: Extracting a date component from a date field


The DPART function extracts a specified component from a date field and returns it in
numeric format.
The format for DPART is as follows:
DPART (datevalue, 'component', output)
datevalue (Date) - A full component date.
component (Alphanumeric) - The name of the component to be retrieved enclosed in
single quotation marks. Valid values are:

YEAR, YY - Returns the year component

MONTH, MM - Returns the month component

DAY, DAY-OF-MONTH, DD - Returns day of month

QUARTER, QQ - Returns quarter

output (Integer) - The field that contains the result, or the integer format of the output
value enclosed in single quotation marks.
Example assuming SHIPDATE column contains the date value 2012/09/22
DPART(SHIPDATE, 'DD', 'I2')
returns 22.
Note: The use of DPART results in the generation of an SQL statement to submit to the
DB2 engine (to carry out the date arithmetic). This is important because it will result in
better query performance. In fact for this very reason, the Date Decompose feature in the
Metadata Editor uses DPART to break up the date components.

DATEADD: adding or subtracting a date unit to or 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 concept. In the following function, the date field must have a format like YYMD,
MDY, or JUL. Increment must be an integer.
DATEADD(date, Y/M/D/WD/BD, increment)
Figure A-32 demonstrates adding 11 days (D) to the order date to calculate the ship date.

Appendix A. Date and time functionality

821

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure A-32 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, for example, YYMD.
If you want to add 11 days to ORDERDATE in the previous example and do not need to worry
about business or weekdays, you can replace the DATEADD with the following values:
ORDERDATE + 11
This creates a SHIPDATE of 11 days in the future.
Note: In many cases, the use DATEADD will result in the generation of an SQL statement
to submit to the DB2 engine (to carry out the date arithmetic). This is important because it
will result in better query performance. Some components such as BD (Business Days)
have no SQL equivalent, and thus can not be translated. You can verify SQL translation by
requesting a Run With SQL trace request within InfoAssist. A translated request would look
similar to the one shown in Figure A-33.

Figure A-33 Translated DATEADD to SQL request

822

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

DATEDIF: calculating the difference between two dates


A similar function to DATEADD is DATEDIF. 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 DATEDIF. You can
create a define field that simply subtracts two dates, as shown in Figure A-34.

Figure A-34 Simple subtraction of two date fields

ORDERDATE - SHIPDATE
The resulting value is based on the least significant component in the order and ship dates.
For example, if one of the dates is defined as YYM, then your results are in months. If both
dates are defined down to the day level, then your results are in days.
The DATEDIF function provides the same capability but allows the developer to provide a
specific unit component for the output. The format for DATEDIF is as follows:
DATEDIF('from_date', 'to_date', 'component')
from_date (Date) - The start date from which to calculate the difference. Can be a field
or a constant, for example, 20120101.
to_date (Date) - The end date from which to calculate the difference. Can be a field or
a constant, for example, 20120922.
component (Alphanumeric). The unit of the value returned by the function. Can be one
of the following (enclosed in single quotation marks):

Y indicates a year unit.

M indicates a month unit.

D indicates a day unit.

WD indicates a weekday unit.

BD indicates a business day unit.

Appendix A. Date and time functionality

823

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

When using DATEDIF, the format of the define field must be defined as an I8 field as shown in
Figure A-35:

Figure A-35 DATEDIF

Note: Once again, for query performance considerations, it is important to note that both
techniques described in this section will result in the generation of an SQL statement to
submit to the DB2 engine (to carry out the date arithmetic). You can verify this by
requesting a Run With SQL trace request within InfoAssist. You should see a result similar
to the one shown in Figure A-36.

Figure A-36 Example of date arithmetic passed to SQL and DB2 engine

DATEMOV: moving 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. Table A-7 lists the possible values for move-point.
DATEMOV(date, move-point)
The date field must be a full date, for example, MDYY or YYJUL.
Note: The DATEMOV function is NOT translated to SQL. This can result in less than
optimal performance because the DB2 Web Query reporting server engine (and not the
DB2 for i engine) processes the request.

824

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Table A-7 Values for move-point


Move-point

Meaning

EOM

End of month

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 a non-business day

WD+

Current weekday or next weekday (if weekend)

BD+

Current business day or next business day if current is a non-business day

Example: Dynamic Date Range report


In this section you create a report that gives the user the ability to select a dynamic range of
rows based on two input parameters:
 An input date
 A number of days
The report will calculate a date range based on the two input fields. The date range is defined
as follows:
 beginRange: the specified number of days before the input date
 endRange: the specified number of days after the input date
The report will then return rows in which the order date within is the specified date range. For
example, if the user entered 20120915 for the date and 10 for the number of days, the report
would return rows on or between September 5, 2012, and September 25, 2012.
To create this report, take the following steps:
1. Create a new report using InfoAssist and select cen_orders at the data source.
2. Create a DEFINE field named inDate2. The format is YYMD and the expression is
DATECVT(&inDate, 'I8YYMD', 'YYMD'). An example is shown in Figure A-37.

Appendix A. Date and time functionality

825

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure A-37 DEFINE field for inDate2

This define field automatically creates the prompt for an input parameter named &inDate
(when the report is run). This is an example of an implicit input parameter. It then converts
the input parameter to a true date field.
Attention: Do not create an input parameter for &inDate in the Selection criteria tab.
3. Create a DEFINE field named beginRange. The format is YYMD and the expression is
DATEADD( inDate2, 'D', (0-&daysRange)), as shown in Figure A-38.

Figure A-38 DEFINE field beginRange

826

IBM i DB2 Web Query for i Implementation Guide

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Similar to above, this define field will create the prompt for an input parameter named
&daysRange (when the report is run). Again, you do not create an explicit input parameter
for &daysRange. The DEFINE field will return a date that is the specified number of days
less than the specified input date.
4. Create a DEFINE field named endRange. The format is YYMD and the expression is
DATEADD( inDate2, 'D', &daysRange), as shown in Figure A-39.

Figure A-39 DEFINE field endRange

This DEFINE field will return a date that is the specified number of days greater than the
specified input date.
Important: The order in which you create these DEFINE fields is very important. This is
because the second and third DEFINE fields contain expressions that reference the first
DEFINE field. If you define them out of order, the expression will fail because it will be
unable to find and resolve DEFINE field inDate2.
5. Click on the Data tab to and select Advanced Filter icon as shown in Figure A-40

Figure A-40 Advanced Filter

6. Create two screending conditions for the ORDERDATE column:


The first condition is GREATER THAN OR EQUAL TO the beginRange DEFINE field
The second condition is LESS THAN OR EQUAL TO the endRange DEFNE field.
Appendix A. Date and time functionality

827

8063ax01.fm

Draft Document for Review August 30, 2013 2:37 pm

Select WHERE for both conditions. An example is shown in Figure A-41.

Figure A-41 Dynamic Date Range Report selection criteria

7. Return to the Field Selection tab and complete the report by selecting the following Sort by
and Sum report columns:
Sort by: ORDERDATE, PRODUCTTYPE
Sum: COSTOFGOODSSOLD, REVENUE
An example is provided in Figure A-42.

Figure A-42 Sort by and Sum columns

8. Save your report as Dynamic Date Range.


9. Click Quit to return to the DB2 Web Query launch page.
10.Run the new Dynamic Date Range report.
11.Specify 20121111 for the inDate parm and 5 for daysRange.

828

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ax01.fm

12.Click Run. The report returns rows for orders between 11/06/2012 and 11/16/2012, as
shown in Figure A-43.

Figure A-43 Dynamic Date Range report results

Appendix A. Date and time functionality

829

8063ax01.fm

830

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ax02.fm

Draft Document for Review August 30, 2013 2:37 pm

Appendix B.

DB2 Web Query System


Variables
System variables are predefined and automatically supplied by the system when a procedure
references them. System variables have names that begin with a single ampersand (&).
Examples of these variables are &FOCFEXNAME, which indicates the name of the report
that is running, and &DATE, which indicates the current date.
The following table lists the system variables available in DB2 Web Query.

Variable
&DATE
&DATEfmt

Format or value
MM/DD/YY
Any date format.

&DMY
&DMYY

DDMMYY
DDMMCCYY

&FOCCODEPAGE

Any integer value

&FOCFEXNAME

Copyright IBM Corp. 2012. All rights reserved.

Description
Returns the current date.
Returns the current date, where fmt can
be any valid date format. Because
many date format options can be
appended to the prefix DATE to form
one of these variable names, you
should avoid using DATE as the prefix
when creating a variable name.
Returns the current date.
Returns the current (four-digit year)
date.
Returns the code page being used by
the server.
Returns the name of the FOCEXEC
running. This variable differs from the
&FOCFOCEXEC variable because
&FOCFOCEXEC returns the name of
the calling FOCEXEC only.

831

8063ax02.fm

Draft Document for Review August 30, 2013 2:37 pm

&FOCFIELDNAME

NEW
OLD
NOTRUNC

&FOCFOCEXEC
&FOCMODE
&FOCNEXTPAGE

AS400
0

&FOCQUALCHAR

.:!%|\

&FOCREL

release number

&FOCSBORDER

ON
OFF

&FOCUSER
&MR_FULL_FEXNAME

832

&MDY
&MDYY

MMDDYY
MMDDCCYY

&TOD
&YMD
&YYMD

HH.MM.SS
YYMMDD
CCYYMMDD

IBM i DB2 Web Query for i Implementation Guide

Returns a string indicating whether long


and qualified field names are
supported. A value of OLD means that
they are not supported; NEW means
that they are supported; and
NOTRUNC means that they are
supported,but unique truncations of
field names cannot be used.
Returns the fully qualified path for the
procedure.
Identifies the operating environment.
Variable whose value is determined by
the last page number used by the last
report. Its value is one more than the
last page number used in the last
report.
Returns the character used to separate
the components of qualified field
names.
Identifies the FOCUS Release number
(for example, 6.5 or 6.8).
Whether solid borders are used in
full-screen mode.
Returns the connected user ID. Similar
to the GETUSER function.
Returns the full FEX name. This is the
same name that appears in the DB2
Web Query Managed Reporting (MR)
interface from the web browser.
Returns the current date.
Returns the current (four-digit year)
date.
Returns the current time.
Returns the current date.
Returns the current (four-digit year)
date.

Draft Document for Review August 30, 2013 2:37 pm

8063ax03.fm

Appendix C.

Change management
considerations
Change Management is the process of exporting DB2 Web Query resources from a source
system and importing that content to a target DB2 Web Query environment. This appendix
describes the export/import process using the provided Change Management utilities.

Copyright IBM Corp. 2012. All rights reserved.

833

8063ax03.fm

Draft Document for Review August 30, 2013 2:37 pm

Change Management overview


To run Change Management, these privileges are needed:
 Export
Administrator: User who is in WebQueryAdministrator group
Developer: User who is in folder-dev group. This user will be able to add repository
objects but will not be able to add metadata to a change management package. The
Reporting Server node (from which metadata is selected) is only visible to
Administrators.
 Import
Administrator: User who is in WebQueryAdministrator group.
Note: The target system must be running the same version of DB2 Web Query as the
source system.
Using the Change Management utility, these types of resources in Web Query can be
exported and imported:
 Repository objects within the top level folder:
Subfolders
Procedures (Reports, Charts, Dashboards, Documents)
HTML
Images
Stylesheets
Schedules
Distribution Lists
 Synonyms
.MAS (master files)
.ACX (access files
Note: Developer is only allowed to export repository objects because developer does not
have access to the Reporting Server node.

Change Management Scenarios


The following scenarios describe where the Change Management utility can be leveraged:
1. Application development/test/delivery
Developers periodically make revisions to DB2 Web Query content and move those changes
to a test environment for testing and user feedback. Once those changes are tested and
approved, it is promoted to the production environment. This process could be implemented
by Change Management.
2. ISV bundling an application

834

IBM i DB2 Web Query for i Implementation Guide

8063ax03.fm

Draft Document for Review August 30, 2013 2:37 pm

ISV develops applications and sells them to customers. Change Management allows them to
export the applications as a package and then move the package to the system on customer
site. After importing the package, the applications are deployed on the target system.
3. Backup and Restore
To prevent applications from being lost or badly changed, the applications should be backed
up and restored periodically. Administrator can export applications to packages for backup
purpose via Change Management and then restore them to another system or locally by
importing the packages if recovery is needed.

Exporting Change Management Package


In the Change Management Export facility, a developer or administrator selects the objects to
export in order to build a change management package. This package is a folder on the
Integrated File System (IFS) which is deployed to the target environment to be imported. The
template or manifest of this package is referred to as a Scenario - it contains a list of all the
objects to be included in the package. Therefore, the first step in the Export process is to
define the scenario.
Take the following steps to create a Scenario:
1. Sign in DB2 Web Query as an administrator or developer.
2. From the Resource Tree of the BI portal, left click on Change Management to expand
Change Management tree. Right click on Export and select New Scenario as in
Figure 26-10.

Figure 26-10 Create New Scenario

Appendix C. Change management considerations

835

8063ax03.fm

Draft Document for Review August 30, 2013 2:37 pm

3. The new scenario window appears. Type the scenario name CenturyElectronic_cm as
shown in Figure 26-11 and then press OK.

Figure 26-11 New Scenario

4. The Change Management export utility is presented as show in Figure 26-12. From this
interface you select the resources (both metadata and reporting objects) to export to the
target system. Because this is a new scenario, the list is initially empty.

Figure 26-12 Export Scenario

Note: : If you do not see the Reporting Server node, this means you are not logged in as
an Administrator. The Reporting Server node (from which metadata is selected) is only
visible to Administrators.
Notice that in the resource tree there are two nodes which you can expand and select
elements from:
 DB2 Web Query
Contains objects from the DB2 Web Query repository such as reports, charts, dashboards,
compound documents, and html files. You can select elements to export at the top level folder,
subfolder, or individual repository object level.
 Reporting Servers
836

IBM i DB2 Web Query for i Implementation Guide

8063ax03.fm

Draft Document for Review August 30, 2013 2:37 pm

Contains the metadata (synonyms). You can select metadata elements to export at the
application folder level or by selecting individual synonyms.
There are two ways to select resources from the resource tree and add them to the scenario:
 Right click the object and choose either Select With Subtree or Select Folder Only.
Select With Subtree - Selects the folder and all the content in the folder (including all
subfolders and their contents).
Select Folder Only - Selects the folder with no content.
 Drag and drop the objects from the tree to the right panel. If you drag a folder to the panel,
the Select with Subtree action is taken.
If Private content is selected, the With Private Content box is automatically selected. If a
Published folder containing private content is selected, there is an option to include private
content by checking the With Private Content box in the scenario listing. If checked, all of the
private content in that folder and its subfolders will be exported.
Note: If With Private Content box is selected, the private content will only be imported if
the owner of that private content already exists in the target environment.
If a subfolder is selected, its parent folder must exist in the target system.
 Also notice the following two settings at the top of the scenario interface as shown in
Figure 26-13.
With Rules. This option is unselected by default and it should be not selected.
Retain Handles. This option should be selected if the source Web Query 2.1.0
environment was migrated from 1.1.1 or 1.1.2. During the migration, the 1.1.* version
Hrefs are used as the 2.1.0 version handles. Moving these handles to the target
environment will allow codes that contain the earlier style to continue to work.

Figure 26-13 With Rules

5. Drag and drop top level folder Century_Electronic in DB2 Web Query tree into the right
panel.

Notice that the Century_Electronic top level folder now appears in the scenario listing in the
right hand panel. Also notice that in the Resource Tree, a strikethrough format has been
applied to that top level folder name. This lets you know that the object is already part of the
scenario (preventing you from adding it again).

Appendix C. Change management considerations

837

8063ax03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 26-14 Scenario Listing

6. Select synonyms under Century_Electronic in Reporting Servers tree and add them to
the right panel as shown in Figure 26-15.

Figure 26-15 Add resources to the scenario

7. 7.Save this scenario by left clicking Save button as shown in Figure 26-16

Figure 26-16 Save the scenario

8. The scenario has been saved, but as described previously, it is merely a template. To
actually create a change Management package based on this scenario, you must export it.
Do this by clicking the Export Scenario button as shown in Figure 26-17.

838

IBM i DB2 Web Query for i Implementation Guide

8063ax03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 26-17 Export Scenario

9. After the export is finished, press OK.


Export Packages are stored in the IFS in the following directory (where a subfolder by the
same name as the scenario is created):
/qibm/UserData/qwebqry/base80/cm/export/

Importing Change Management Package


In this section we will explain how to import a Change Management Package:
1. On the source system copy the entire subfolder CenturyElectronic_cm under
the/qibm/UserData/qwebqry/base80/cm/export/
2. On the target system paste the subfolder to the following subfolder
/qibm/UserData/qwebqry/base80/cm/import/
3. Sign in DB2 Web Query on the target system as an administrator.
4. From the resource tree of the BI portal, click on Change Management to expand the
Change Management tree. Under Import you should see the CenturyElectronic_cm
package (placed there from step 2 above).
5. Right click on CenturyElectronic_cm and select Import as in Figure 26-18 on page 840.

Appendix C. Change management considerations

839

8063ax03.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 26-18 Menu to Import

The import package interface appears as shown in Figure 26-19 .

Figure 26-19 Import Package

The following options appear on the Import Package dialog window:


 Content Resource. Valid options are:
Add New Resources Only(do not replace): Does not update existing Resources on
the target system
Add New and Update Existing Resources: Both add new resources and update
existing resources.
 Security Resources. These options should not be selected and are reserved for future
use.

840

IBM i DB2 Web Query for i Implementation Guide

8063ax03.fm

Draft Document for Review August 30, 2013 2:37 pm

6. Press OK. The message popped up indicates the status of importing. When finished, you
should see the Import successful window as shown in Figure 26-20. Figure 26-20

Figure 26-20 Import Successful message

7. Upon a successful import, the resources in CenturyElectronic_cm are imported as shown


in Figure 26-21. You may need to refresh the contents of the resource tree to see the
imported content.

Figure 26-21 Imported Content

Note: : If you want to see the details of the export or import requests, the log file of Change
Management activity is:
/qibm/Userdata/qwebqry/base80/logs/impex.log

Appendix C. Change management considerations

841

8063ax03.fm

842

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

Draft Document for Review August 30, 2013 2:37 pm

8063ax04.fm

Appendix D.

Configuring Developer
Workbench
Developer Workbench is the PC based tool that provides several DB2 Web Query
development and administrative features that are not available from the products browser
interface. In this chapter we review the tools configuration steps and how to set up several
default options.

Copyright IBM Corp. 2012. All rights reserved.

843

8063ax04.fm

Draft Document for Review August 30, 2013 2:37 pm

Configuring Developer Workbench


To configure Developer Workbench:
1. Because Developer Workbench is a PC application, you must first install the licensed
program 5733-WQX on the developers PC. The Workbench product files, once delivered
separately, are part of the product installation in V2.1 and can be found at the path
depicted in Figure 26-22 on the integrated file system (IFS) after the licensed program
install in complete:

Figure 26-22 Location of Developer Workbench installation executable

2. After completing the Workbench install, when you first launch the program, you must
configure the software to address your IBMi server. This is similar to the one-time setup
required for other IBMi client server products like Access and Navigator. Figure 26-23
below shows this initial screen. You will add a connection for your IBMi system under the
WebFOCUS Environments following the next steps:

Figure 26-23 Initial Workbench pane

a. Right-click WebFOCUS and select Add.


b. In the next window (Figure 26-24), complete these steps:

844

IBM i DB2 Web Query for i Implementation Guide

8063ax04.fm

Draft Document for Review August 30, 2013 2:37 pm

i. Type a description of your System i environment.


ii. For Host Name/IP Address, type a name.
iii. For Port, verify that 12331 is selected.
Tip: If you changed the DB2 Web Query default port number, you must clear the
Use Default box and specify your installations port number.
iv. For HTML Alias, ensure that it is /webquery_html.
v. Click OK.

Figure 26-24 IP Address Configuration for the WorkBench to IBMi connection

Appendix D. Configuring Developer Workbench

845

8063ax04.fm

Draft Document for Review August 30, 2013 2:37 pm

3. The first time that you open the System i environment or connection that you just added,
you will be prompted to enter your IBMi credentials, in a pop-up window. Sign on with your
administrator or developer authorized profile. See Figure 26-25 on page 846.
Tip: Select the Remember my User Name and Password on this computer option
during this sign-on if you desire not to be prompted with these sign-on windows again
for this IBMi connection.

Figure 26-25 Workbench Logon window

Before going further with this chapter, you should verify you have created a folder under the
Century Electronics folder and named it: Assignment 09 - Exploring and comparing other
Dashboard options. Place your work from this chapter into this folder.
You will now be able to expand the menu trees under your connection and begin to review
metadata or develop applications in the workbench. There are two primary areas beneath the
connection: Data Servers and Repository as shown in Figure 26-26.

846

IBM i DB2 Web Query for i Implementation Guide

8063ax04.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 26-26 Expanding the tree - Web Query work area for your IBMi

In the right pane of Figure 26-27, you see the metadata files, you master (.mas) and access
(.acx) files. Remember that the master file contains the field names and formats for your
table. The access file contains information about the actual name and location of the physical
table and the primary keys for the table. Nearly all your work is done with the master files.

Figure 26-27 Master data and Access files

When you edit metadata with the synonym editor, you get a number of view choices for
reviewing your data relationships. The following figures show two of these views for the
CEN_ORDERS cluster. There are more detailed field-by-field views available as well.

Appendix D. Configuring Developer Workbench

847

8063ax04.fm

Draft Document for Review August 30, 2013 2:37 pm

Figure 26-28 Table relationships - modeling view depicted in Workbench

Figure 26-29 Table relationships - segment view depicted in Workbench

The source code or procedures that store your report definitions are located in DB2 tables in
the repository library. This is a change from prior releases when these files were stored in the
IFS. You may see performance and security improvements from this change. You see them as
*.FEX files under the Repository tree in folders that you create. A suggested strategy is a
company folder for production and a development folder for content creation. You will expand
the Repository branch as shown in Figure 26-30 when you want to create a new report or
modify an existing one in the workbench. The workbench will launch the InfoAssist
component.

848

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ax04.fm

Figure 26-30 Tutorials under the Century top level folder

Appendix D. Configuring Developer Workbench

849

8063ax04.fm

Draft Document for Review August 30, 2013 2:37 pm

Setting Developer Workbench default options


Developer Workbench has a set of options that can be tailored to an individual user. To
access these options, select Window Options (Figure 26-31). We use the tailoring
options in later tutorials.

Figure 26-31 Displaying Developer Workbench options

Figure 26-32 shows the General options tab.

Figure 26-32 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. On the Explorer tab, select the Show Desktop
on Explorer tree option (Figure 26-33).
Showing your Windows desktop tree within Developer Workbench has definite benefits. The
obvious benefit is the ability 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.

850

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

8063ax04.fm

An additional benefit is the ease with which you can copy items from your PC hard drive to the
DB2 Web Query folder structure. You might want to move style sheets, company logos,
pictures, and other PC files between the different file structures.

Figure 26-33 Explorer options

For more details about using Developer Workbench, refer to the online help text and the
OLAP chapter in this document.

Appendix D. Configuring Developer Workbench

851

8063ax04.fm

852

IBM i DB2 Web Query for i Implementation Guide

Draft Document for Review August 30, 2013 2:37 pm

(0.5 spine)
0.475<->0.873
250 <-> 459 pages

(1.0 spine)
0.875<->1.498
460 <-> 788 pages

(1.5 spine)
1.5<-> 1.998
789 <->1051 pages

8063spine.fm

853

To determine the spine width of a book, you divide the paper PPI into the number of pages in the book. An example is a 250 page book using Plainfield opaque 50# smooth which has a PPI of 526. Divided
250 by 526 which equals a spine width of .4752". In this case, you would use the .5 spine. Now select the Spine width for the book and hide the others: Special>Conditional
Text>Show/Hide>SpineSize(-->Hide:)>Set . Move the changed Conditional text settings to all files in your book by opening the book file with the spine.fm still open and File>Import>Formats the

Conditional Text Settings (ONLY!) to the book files.


Draft Document for Review August 30, 2013 2:37 pm

IBM i DB2 Web Query for i


Implementation Guide

IBM i DB2 Web Query for i


Implementation Guide
IBM i DB2 Web Query for i Implementation Guide

IBM i DB2 Web Query for i Implementation Guide

(0.2spine)
0.17<->0.473
90<->249 pages

(0.1spine)
0.1<->0.169
53<->89 pages

Conditional Text Settings (ONLY!) to the book files.

854

(2.5 spine)
2.5<->nnn.n
1315<-> nnnn pages

8063spine.fm

To determine the spine width of a book, you divide the paper PPI into the number of pages in the book. An example is a 250 page book using Plainfield opaque 50# smooth which has a PPI of 526. Divided
250 by 526 which equals a spine width of .4752". In this case, you would use the .5 spine. Now select the Spine width for the book and hide the others: Special>Conditional
Text>Show/Hide>SpineSize(-->Hide:)>Set . Move the changed Conditional text settings to all files in your book by opening the book file with the spine.fm still open and File>Import>Formats the

Draft Document for Review August 30, 2013 2:37 pm

IBM i DB2 Web Query for i


Implementation Guide

IBM i DB2 Web Query for i


Implementation Guide

(2.0 spine)
2.0 <-> 2.498
1052 <-> 1314 pages

Draft Document for Review August 30, 2013 2:39 pm

Back cover

IBM DB2 Web Query for i


Version 2.1
Implementation Guide
Follow the best
practice guides to
simplify report
development
Take our reporting to
the next level of
Business Intelligence
Learn DB2 Web Query
by using the
easy-to-follow
tutorials

Business Intelligence (BI) is a broad term relating to


applications designed to analyze data for purposes of
understanding and acting on the key metrics that drive
profitability in an enterprise. Key to analyzing that data is
providing fast, easy access to it while delivering it in formats
or tools that best fit the needs of the end user.
At the core of any business intelligence solution are end
user query and reporting tools that provide intuitive access
to data supporting a spectrum of end users from executives
to power users, from spreadsheet aficionados to the
external Internet consumer.
IBM DB2 Web Query for i offers a set of modernized
tools for a more robust, extensible and productive reporting
solution than the popular Query for System i (also known
as Query/400) tool. DB2 Web Query for i preserves
investments in the reports developed with Query/400 by
offering a choice of importing definitions into the new
technology or continuing to run existing Query/400 reports
as is. But it also offer significant productivity and
performance enhancements by leveraging the latest in DB2
for i query optimization technology.
This IBM Redbooks publication provides a broad
understanding of the new DB2 Web Query product. It
entails a group of self-explanatory tutorials to help you get
up to speed quickly. Overall, this book is designed for IT
users. You can use Part 2, Tutorials for DB2 Web Query
on page 159, as stand-alone tutorials for anyone who is
developing their own queries.

SG24-8063-00

ISBN

INTERNATIONAL
TECHNICAL
SUPPORT
ORGANIZATION

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

You might also like