IBM I DB2 Web Query For I Version 2.1 Implementation Guide
IBM I DB2 Web Query For I Version 2.1 Implementation Guide
IBM I DB2 Web Query For I Version 2.1 Implementation Guide
SG24-8063-00
Robert Andrews
Theo Br
Gene Cobb
Rick Flagler
Kei Fujii
Hector Gongora
Doug Mack
Simona Pacchiarini
Septia Sukariningrum
Yu Yu Wang
ibm.com/redbooks
8063edno.fm
SG24-8063-00
8063edno.fm
Note: Before using this information and the product it supports, read the information in Notices on
page xiii.
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
21
22
24
25
26
30
34
35
36
iii
8063TOC.fm
147
148
148
148
149
149
150
150
152
152
157
8063TOC.fm
169
170
171
173
175
177
179
185
186
189
191
192
195
201
205
206
206
211
216
218
219
223
224
225
225
226
229
231
232
238
241
241
245
247
248
248
252
255
258
261
269
270
276
278
279
283
Contents
8063TOC.fm
vi
285
287
294
296
297
298
299
300
301
303
305
307
309
309
311
312
312
316
324
331
341
342
352
358
358
363
366
366
371
374
374
381
390
392
393
394
394
394
396
398
402
404
411
411
416
419
8063TOC.fm
423
424
425
426
426
429
432
433
445
455
456
456
456
456
456
457
457
458
458
459
460
462
466
466
466
471
477
478
478
478
482
488
488
490
494
495
495
496
496
497
501
506
512
513
541
542
542
542
545
553
553
Contents
vii
8063TOC.fm
viii
556
561
566
576
577
581
583
584
584
586
588
588
589
590
594
596
598
605
606
606
606
606
607
608
611
612
614
616
621
622
624
624
624
626
631
632
632
632
632
633
634
634
639
640
641
647
647
647
647
648
653
8063TOC.fm
658
661
662
669
672
672
679
685
686
686
686
686
687
687
687
688
691
692
693
693
693
693
696
697
698
699
715
716
716
716
718
727
729
730
730
731
740
741
745
745
745
746
747
747
749
751
Contents
ix
8063TOC.fm
753
753
753
754
754
757
759
760
760
760
760
763
763
764
764
767
768
768
768
771
772
772
775
778
781
782
782
783
784
785
785
785
786
789
794
811
814
815
818
821
821
821
823
824
825
8063TOC.fm
834
834
835
839
Contents
xi
8063TOC.fm
xii
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.
xiii
8063spec.fm
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
8063spec.fm
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
Notices
xv
8063spec.fm
xvi
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.
xvii
8063pref.fm
xviii
8063pref.fm
Preface
xix
8063pref.fm
xx
8063pref.fm
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
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
xxii
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:
8063p01.fm
8063ch01.fm
Chapter 1.
8063ch01.fm
8063ch01.fm
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.
8063ch01.fm
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).
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
8063ch01.fm
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.
8063ch01.fm
Browser client
IBM i
Version 2.1
HTTP
Applet
Reporting server
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 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
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.
8063ch01.fm
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.
10
8063ch01.fm
11
8063ch01.fm
Data type
DB2 CLI
CLI API
DB2 Heritage
File
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.
12
8063ch02.fm
Chapter 2.
13
8063ch02.fm
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.
14
8063ch02.fm
Object type
QWEBQRYX
*LIB
QWEBQRY
*LIB
QWQREPOS
*LIB
QWQCENT
*LIB
QSYS/QWQADMIN
*USRPRF
QSYS/QWQ0000000
*AUTL
QWEBQRY/QWEBQRYJOB
*JOBD
QUSRSYS/QWQADMIN
*MSGQ
15
8063ch02.fm
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.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.
16
8063ch02.fm
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.
17
8063ch02.fm
18
8063ch02.fm
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.
11331
12331
11332
12332
11333
12333
11334
11335
12335
11336
12336
11338
12338
11339
12339
19
8063ch02.fm
20
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:
In this chapter we will cover the details of the metadata and how it relates to DB2 Web Query
for i.
21
8063ch03.fm
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
8063ch03.fm
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.
23
8063ch03.fm
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
24
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:
25
8063ch03.fm
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
8063ch03.fm
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.
27
8063ch03.fm
28
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.
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.
29
8063ch03.fm
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
7. The process of creating metadata is now complete. Close the message box.
30
8063ch03.fm
3. You are presented with the Select Adapter window, select *LOCAL and click on OK
(Figure 3-10).
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.
31
8063ch03.fm
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
8063ch03.fm
6. You are presented with a message confirming the synonym creation(Figure 3-13 on
page 34). Select Close.
33
8063ch03.fm
8063ch03.fm
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
> PROVEOO
. . . . . SCHEMA
. . . . . . . FRGNKEYS
> *TABLE
*YES
*YES
> POO_
*NONE
> SIMONA
*NO
*YES
> *NONE
*NO
35
8063ch03.fm
2. In the metadata pane right click on the metadata you want to delete and select Delete
(Figure 3-16 on page 37).
36
8063ch03.fm
3. You will receive a message asking you to confirm deletion. Click on OK.
37
8063ch03.fm
3. You will receive a message prompting you to confirm delete. Select Yes (Figure 3-18).
38
8063ch03.fm
/qibm/UserData/qwebqry/apps/simona_10
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
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.
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
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
8063ch03.fm
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.
41
8063ch03.fm
3. You will be presented with a message box confirming that the sysnonym has been
refreshed, as shown in Figure 3-23. Select OK.
42
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.
43
8063ch03.fm
> ANART00F
> PROVEOO
. . . . . SCHEMA
> *TABLE
> POO_
*NONE
> SIMONA
*NO
*YES
> *REFRESH <<<<< NOTICE!!!
*YES, *NO
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
8063ch03.fm
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.
45
8063ch03.fm
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
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.
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.
47
8063ch03.fm
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
8063ch03.fm
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.
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
50
8063ch03.fm
51
8063ch03.fm
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.
52
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.
5. In the next window, from the tabbed selections, click the Key Constraints tab and then
click Add.
53
8063ch03.fm
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.
7. In the window that contains the various tabs (Figure 3-33), click OK.
54
8063ch03.fm
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.
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.
55
8063ch03.fm
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
8063ch03.fm
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.
57
8063ch03.fm
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.
58
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.
59
8063ch03.fm
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.
60
8063ch03.fm
61
8063ch03.fm
62
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).
63
8063ch03.fm
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).
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
8063ch03.fm
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.
65
8063ch03.fm
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.
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.
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
8063ch03.fm
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).
67
8063ch03.fm
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
8063ch03.fm
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
69
8063ch03.fm
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.
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
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.
71
8063ch03.fm
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.
72
8063ch03.fm
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).
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.
73
8063ch03.fm
4. Set the name of the library - QWQCENT - and select Next (Figure 3-57 on page 74).
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
8063ch03.fm
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)
75
8063ch03.fm
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.
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
8063ch03.fm
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.
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.
77
8063ch03.fm
78
8063ch03.fm
2. Right click on cen_orders and select Open (Figure 3-64 on page 79).
3. The synonym editor opens up. Right click on field ORDERDATE and select Decompose
Date (Figure 3-65)
79
8063ch03.fm
4. The synonym gets updated with four new field representing the date base component, as
shown in Figure 3-66.
80
8063ch03.fm
81
8063ch03.fm
3. You are presented with a panel (Figure 3-68) where you can select the decomposition
items: Day, Month, Quarter and Year. Select OK.
4. In Figure 3-69 on page 83 you can see the decomposition results. Save your synonym and
exit.
82
8063ch03.fm
83
8063ch03.fm
Sample Data
Data Profiling
Statistics
Count
Key Analys
84
8063ch03.fm
85
8063ch03.fm
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
8063ch03.fm
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!
87
8063ch03.fm
1
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
8063ch03.fm
89
8063ch03.fm
Note: Only change the USAGE portion - if you change the ACTUAL section you end up
with a database mismatch!
1
2
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
8063ch03.fm
91
8063ch03.fm
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.
92
8063ch03.fm
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.
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.
93
8063ch03.fm
1
2
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
8063ch03.fm
1
3
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
95
8063ch03.fm
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
8063ch03.fm
8. Right click on the Other options icon and select Save as shown in Figure 3-87.
97
8063ch03.fm
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.
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
8063ch03.fm
4
3
5
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.
99
8063ch03.fm
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
8063ch03.fm
101
8063ch03.fm
102
8063ch03.fm
3. The synonym editor opens up. Right click on segment ORDERS and select Insert
Compute (Figure 3-95 on page 104).
103
8063ch03.fm
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
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
8063ch03.fm
COSTFGOODSSOLD (#3) then type in *100 as shown in Figure 3-97 on page 105. When
you are done select OK.
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.
105
8063ch03.fm
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
8063ch03.fm
107
8063ch03.fm
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
8063ch03.fm
2
3
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.
109
8063ch03.fm
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
8063ch03.fm
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.
111
8063ch03.fm
112
8063ch03.fm
2. Right click on your synonym - here we use cen_orders - and select Open (Figure 3-106)
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).
113
8063ch03.fm
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.
114
8063ch03.fm
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
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).
115
8063ch03.fm
7. You will be brought back to the Filter Property View pane, select APPLY as shown in
Figure 3-111.
116
8063ch03.fm
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).
117
8063ch03.fm
Data Servers -> EDASERVE -> Applications -> <yourfoldr> as shown in Figure 3-114.
Double click on the synonym where you want to define the filter.
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
8063ch03.fm
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
119
8063ch03.fm
120
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.
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).
121
8063ch03.fm
122
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).
123
8063ch03.fm
124
8063ch03.fm
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
5. Right click on Dimension and select Insert New Time Dimension. as show in
Figure 3-122.
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.
125
8063ch03.fm
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.
8. You will notice that a full time decomposed dimension is populated, as shown in
Figure 3-125 on page 127.
126
8063ch03.fm
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).
127
8063ch03.fm
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.
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
8063ch03.fm
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.
129
8063ch03.fm
Segment (File)
Field
Value (Row level security)
No Print (Column level security)
130
8063ch03.fm
2. Once in the synonym, select the icon representing the DBA function on the tool bar, as
shown in Figure 3-131.
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).
131
8063ch03.fm
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).
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.
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
8063ch03.fm
7. Right click on Read and select Insert Noprint Restriction (Figure 3-136).
133
8063ch03.fm
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
8063ch03.fm
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.
If you need to define the same rule for another user you have to repeat the process, starting
from #4.
135
8063ch03.fm
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) .
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
8063ch03.fm
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).
6. Right click on the name of the rule and select Insert Read Access (Figure 3-144).
7. Right click on Read and select Insert Value Restriction (Figure 3-145).
137
8063ch03.fm
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.
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
8063ch03.fm
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).
139
8063ch03.fm
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.
12.In the main DBA pane you can see the whole rule (Figure 3-150).
13.Save the synonym using the save icon in the tool bar (Figure 3-151 on page 141).
140
8063ch03.fm
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.
141
8063ch03.fm
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
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
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).
4. A new folder is created, right click on it and select Rename to give it a meaningful name
(Figure 3-155).
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
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
8063ch03.fm
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.
145
8063ch03.fm
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.
9. To use a Business View in development simply select the view name when developing a
new report in Info Assist.
146
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.
147
8063ch04.fm
Role Description
WebQueryAdministrator
Can perform all functions in Web Query and can access all
folders.
DevWorkBench
148
Group Name
Role Description
Folder-run
Folder-analyst
8063ch04.fm
Group Name
Role Description
Folder-dev
Folder-dba
Folder-sched
Folder-admin
Note: Just because a user has access to a report does not mean he will be able to run
it.
149
8063ch04.fm
150
8063ch04.fm
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.
151
8063ch04.fm
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).
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
8063ch04.fm
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.
153
8063ch04.fm
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
8063ch04.fm
In the above example, we see that the report is hidden and published.
155
8063ch04.fm
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.
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.
156
8063ch04.fm
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.
157
8063ch04.fm
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.
The elements will appear in the folder in ascending order of the Sort Order value. An example
is shown in Figure 4-11.
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
8063p02.fm
Part 2
Part
159
8063p02.fm
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.
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
8063ch05.fm
Chapter 5.
161
8063ch05.fm
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
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.
163
8063ch05.fm
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!
164
ORDERS
INVENTORY
PLANT
STORES
DATE_CONV
8063ch05.fm
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.
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.
165
8063ch05.fm
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.
166
8063ch05.fm
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.
167
8063ch05.fm
168
8063ch06.fm
Chapter 6.
169
8063ch06.fm
170
8063ch06.fm
171
8063ch06.fm
The new user is added to the users list as shown in Figure 6-5 on page 173.
172
8063ch06.fm
173
8063ch06.fm
The user is added to the WebQueryAdministrator group as shown in Figure 6-7 on page 175.
174
8063ch06.fm
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.
175
8063ch06.fm
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
8063ch06.fm
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.
177
8063ch06.fm
Note: You can also add users by dragging and dropping the selected users into a
group.
The user is added to the Century_Electronics-dev group, as shown in the following image.
178
8063ch06.fm
179
8063ch06.fm
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.
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
8063ch06.fm
A list of all group profiles appear as shown in Figure 6-15 on page 181.
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.
181
8063ch06.fm
The group profile is added to the Selected Groups panel as shown in Figure 6-17 on
page 182.
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
8063ch06.fm
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).
183
8063ch06.fm
Figure 6-20 Associated group proffiles are not disoplayed in Users in Group panel
184
8063ch06.fm
New
Creates a new user.
Edit
Edits the user attributes.
Delete
Deletes the user.
Groups
Opens a submenu that contains the following options:
185
8063ch06.fm
Remove from: Opens a dialog box to remove the user from one, more, or all
groups.(See Figure 6-23.)
186
8063ch06.fm
Or:
Right-click the report and select Security Owner Select the new owner (see
Figure 6-25 on page 188).
187
8063ch06.fm
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
8063ch06.fm
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..
189
8063ch06.fm
190
8063ch07.fm
Chapter 7.
191
8063ch07.fm
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.
192
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.
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.
193
8063ch07.fm
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
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
The process of creating metadata is now complete. Close the message box
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.
195
8063ch07.fm
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).
196
8063ch07.fm
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.
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
197
8063ch07.fm
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.
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
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.
199
8063ch07.fm
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
8063ch07.fm
201
8063ch07.fm
2. Right click on cen_orders and select Open (Figure 7-16 on page 202).
3. The synonym editor opens up. Right click on field ORDERDATE and select Decompose
Date (Figure 7-17)
202
8063ch07.fm
4. The synonym gets updated with four new field representing the date base component, as
shown in Figure 7-18.
203
8063ch07.fm
5. Save your synonym selecting the SAVE option from the More Options icon pulldown, as
shown in Figure 7-19.
204
8063ch08.fm
Chapter 8.
205
8063ch08.fm
206
8063ch08.fm
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.
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.
207
8063ch08.fm
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.
208
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.
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.
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.
209
8063ch08.fm
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.
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
8063ch08.fm
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.
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.
211
8063ch08.fm
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.
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
8063ch08.fm
5. Click OK.
Another way to do this formatting is by directly type I10MC in the format field as in
Figure 8-17.
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.
213
8063ch08.fm
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
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
8063ch08.fm
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.
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.
215
8063ch08.fm
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
8063ch08.fm
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.
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
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.
218
8063ch08.fm
219
8063ch08.fm
5
6
220
8063ch08.fm
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.
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.
221
8063ch08.fm
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.
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
8063ch08.fm
17.Close InfoAssist
223
8063ch08.fm
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.
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
8063ch08.fm
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.
225
8063ch08.fm
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.
226
8063ch08.fm
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
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.
227
8063ch08.fm
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.
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
8063ch08.fm
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.
19.Run the report by click Run button. The result will be as shown in Figure 8-50 below.
229
8063ch08.fm
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.
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.
230
8063ch08.fm
3. You see that data bars appears on the right side of Revenue values as in Figure 8-56.
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.
231
8063ch08.fm
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.
232
8063ch08.fm
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.
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.
9. Run the report. The result for the first three Product Category will be as in Figure 8-62 on
page 233.
10.You see that in Figure 8-62 the subtotals applied for both Revenue and Gross_Profit field.
233
8063ch08.fm
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.
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
8063ch08.fm
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.
235
8063ch08.fm
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
8063ch08.fm
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.
237
8063ch08.fm
Figure 8-69 Sample Summary Report with Gross Profit Subtotals based on Product Type
238
8063ch08.fm
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
239
8063ch08.fm
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.
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
8063ch08.fm
241
8063ch08.fm
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.
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.
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
8063ch08.fm
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.
243
8063ch08.fm
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.
While Figure 8-83 shows the wrong Gross Profit length since Gross Profit for Audio,
Camcorders, and Video numeric value is not showed.
244
8063ch08.fm
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.
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.
245
8063ch08.fm
7. Test the Margin you just created by creating a simple report as shown in below.
246
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.
247
8063ch09.fm
Figure 9-1 Report Result using DB2 Web Query Date function
248
8063ch09.fm
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.
249
8063ch09.fm
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
8063ch09.fm
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.
251
8063ch09.fm
10.Now all the report you create in the future will use the Engray_theme style by default!
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
8063ch09.fm
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.
253
8063ch09.fm
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.
9. After you type the new title, click OK. Figure 9-15 shows the Edit Title dialog window.
254
8063ch09.fm
2. You see Define menu shows up. Fill the fields as Figure 9-17 below and click OK.
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.
255
8063ch09.fm
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
8063ch09.fm
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.
257
8063ch09.fm
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.
258
8063ch09.fm
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.
259
8063ch09.fm
MonthName Field
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.
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
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.
7. Click the Run button. The sample result of several fetched record will be as in Figure 9-25
below.
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.
261
8063ch09.fm
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.
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
8063ch09.fm
WeekOfYear fields
should be deleted
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.
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.
263
8063ch09.fm
5. A new menu that contain list of master files shows up. Choose CEN_DATE_CONV, and
click OK. See Figure 9-30.
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
8063ch09.fm
7. A new red line appears between ORDERDATE and DC_DATE. Right click on the redline
and choose Edit as in Figure 9-32.
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.
265
8063ch09.fm
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.
10.Run the report to see the result as shown in Figure 9-35 on page 267.
266
8063ch09.fm
267
8063ch09.fm
268
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.
269
8063ch10.fm
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.
270
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.
5. Next, put Revenue in Sum field under Query panel, followed by Gross_Profit.
271
8063ch10.fm
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.
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
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.
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.
11.Double click the icon to show the Table of Contents as shown in Figure 10-9.
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.
273
8063ch10.fm
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.
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
8063ch10.fm
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.
275
8063ch10.fm
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.
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.
3. Now, click on the Accordion button. Accordion function is part of Features group, still
under Format menu. See Figure 10-16.
276
8063ch10.fm
4. Run the report. The first report you see as in Figure 10-17.
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.
277
8063ch10.fm
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.
278
8063ch10.fm
3. Run the report to see the result as in Figure 10-21 on page 279.
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.
279
8063ch10.fm
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.
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
8063ch10.fm
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.
7. An Edit Title menu shows up. Change the title to Return Percentage, and click OK as in
Figure 10-26.
8. Run the report. You can find the sample report result as in Figure 10-27 below.
281
8063ch10.fm
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.
10.Run the report again. Notice the difference between report layout that use and doesnt use
Stack Measures function.
282
8063ch10.fm
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.
283
8063ch10.fm
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.
284
8063ch10.fm
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.
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
285
8063ch10.fm
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.
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
8063ch10.fm
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.
287
8063ch10.fm
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
8063ch10.fm
8. Still under Format menu, expand Features group menu and click on Active Report
Options as in Figure 10-42.
289
8063ch10.fm
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
8063ch10.fm
Next, to change the report to be password protected, go to Advanced tab as in Figure 10-45
on page 292.
291
8063ch10.fm
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.
12.After you correctly input the password, you can see your active report as in Figure 10-47
on page 293.
292
8063ch10.fm
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.
14.The visualization bars appears right beside each revenue records as in Figure 10-49.
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.
293
8063ch10.fm
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.
The report is now sorted based on Product Category in ascending way. See Figure 10-52 on
page 295 for your reference.
294
8063ch10.fm
The report is now sorted based on Revenue in descending way. Notice the red box in
Figure 10-54.
295
8063ch10.fm
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.
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
8063ch10.fm
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.
After you select the menu, a new window showing the pie chart result appears as in
Figure 10-58.
297
8063ch10.fm
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.
298
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.
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.
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
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.
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.
300
8063ch10.fm
Notice that the Figure 10-64 result is the same as you created in Figure 10-58 on page 298.
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
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.
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.
8063ch10.fm
Line Chart
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.
303
8063ch10.fm
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.
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
8063ch10.fm
305
8063ch10.fm
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.
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.
Click OK after you finish do the configuration. You can see the sample result as in
Figure 10-76 on page 307 below.
306
8063ch10.fm
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.
307
8063ch10.fm
3. Notice that in the field where you add the comment in it, there is an asterisk sign in the
field.
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.
308
8063ch10.fm
1.
2.
3.
4.
ActiveX is now enabled and you can save your Active Reports.
309
8063ch10.fm
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.
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
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
311
8063ch11.fm
Figure 11-1 Final Result of Pie chart : Revenue / Gross Profit by Product Type
312
8063ch11.fm
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.
313
8063ch11.fm
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
8063ch11.fm
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
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.
315
8063ch11.fm
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.
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
8063ch11.fm
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
317
8063ch11.fm
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.
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.
8063ch11.fm
10.Click OK.
11.Select Format tab -> Chart Types group -> Other icon as shown in Figure 11-15.
12.Select Horizontal Percent Bars chart as shown in Figure 11-16 on page 320.
319
8063ch11.fm
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
8063ch11.fm
14.Right click on any the EARLY bar (blue colored bar), and select Series Color as shown in
Figure 11-18.
321
8063ch11.fm
Audio
Product Type
Camcorders
Cameras
Office
Video
0%
20%
40%
EARLY
ONTIME
60%
80%
100%
LATE
15.Select yellow.
16.Follow the same steps, to change the color of ONTIME and LATE as in Figure 11-20.
322
8063ch11.fm
Audio
Product Type
Camcorders
Cameras
Office
Video
0%
20%
40%
EARLY
60%
ONTIME
80%
100%
LATE
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.
323
8063ch11.fm
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
8063ch11.fm
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
325
8063ch11.fm
4. Click OK.
5. Select Format tab -> Chart Types group -> Other chart.
7. Select the Data tab and Detail (Define) icon. A new menu pops-up.
326
8063ch11.fm
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.
327
8063ch11.fm
15.Right Click X Axis, select rotate, then select 45 as in Figure 11-29 on page 329.
328
8063ch11.fm
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
329
8063ch11.fm
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
8063ch11.fm
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
331
8063ch11.fm
4. Click OK.
5. Select Format tab -> Chart Type group -> Other icon.
332
8063ch11.fm
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
334
8063ch11.fm
13.Edit Minimum Value to 1.0, Maximum Value to 59.0 as in Figure 11-45 on page 336.
335
8063ch11.fm
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
8063ch11.fm
337
8063ch11.fm
22.Click General Options tab, change Color and Border Color on Gauge Needle as in
Figure 11-51.
338
8063ch11.fm
24.Click Axis Scale & Labels tab, change Minimum values as shown Figure 11-53
339
8063ch11.fm
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
8063ch12.fm
12
Chapter 12.
341
8063ch12.fm
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
8063ch12.fm
2. In the New Folder pane specify the name for this new folder, Assignment 05 - Adding
filters to Report as shown below.
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.
343
8063ch12.fm
4. Info Assist opens up, select synonym CEN_ORDERS as your data source and click on
OK (Figure 12-5 on page 345).
344
8063ch12.fm
345
8063ch12.fm
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.
346
8063ch12.fm
2
1
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).
347
8063ch12.fm
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
8063ch12.fm
1
2
349
8063ch12.fm
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
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
8063ch12.fm
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.
351
8063ch12.fm
352
8063ch12.fm
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.
3. Right click on one of the filters already set and select Open Advanced Filter
(Figure 12-18 on page 354).
353
8063ch12.fm
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
5. Make sure the COUNTRY condition is selected then select Insert Before as shown in
Figure 12-20 on page 355.
354
8063ch12.fm
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.
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.
355
8063ch12.fm
8. When you are done the advanced filters panel should look like Figure 12-23 on page 356.
Select OK to confirm your choices.
9. Save your report as 5c - Revenue Advanced Filter and run it. It should look like
Figure 12-24.
356
8063ch12.fm
357
8063ch12.fm
358
8063ch12.fm
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.
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).
359
8063ch12.fm
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.
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).
360
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.
361
8063ch12.fm
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
18.Enable the 3D effect and make it look better. Select Format tab and select 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.
362
8063ch12.fm
20.Run your report. Figure 12-35 shows the result of running this report.
363
8063ch12.fm
c. Enter FROM_DATE to Variable; field, and enter Star Date (YYYYMMDD) to Prompt: field for
your users. Click OK.
364
8063ch12.fm
26.Save and run your report. Figure 12-39 shows the results of running this report.
365
8063ch12.fm
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
8063ch12.fm
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.
367
8063ch12.fm
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
8063ch12.fm
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.
369
8063ch12.fm
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
8063ch12.fm
3. Find the Profit field and drag in to the SUM aggregation item in the Query pane, as shown
in Figure 12-47.
371
8063ch12.fm
4. In the data pane locate your Europe filter and drag it in the filter pane (Figure 12-48 on
page 372).
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).
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
8063ch12.fm
373
8063ch12.fm
Info Assist provide the InfoMini funtionality that can easily help in accomplishing this task.
374
8063ch12.fm
375
8063ch12.fm
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.
5. Right click on Dimension and select Insert New Time Dimension. as show in
Figure 12-54.
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
8063ch12.fm
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.
8. You will notice that a full time decomposed dimension is populated, as shown in
Figure 12-57 on page 378.
377
8063ch12.fm
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).
378
8063ch12.fm
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.
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.
379
8063ch12.fm
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
8063ch12.fm
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.
381
8063ch12.fm
2. Info Assist opens up, select synonym CEN_ORDERS as your data source and click on
OK (Figure 12-64 on page 383).
382
8063ch12.fm
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 ().
383
8063ch12.fm
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.
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
8063ch12.fm
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).
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.
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.
385
8063ch12.fm
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
386
8063ch12.fm
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.
387
8063ch12.fm
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.
388
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.
389
8063ch12.fm
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.
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
8063ch12.fm
3
2
1
3. Save your report as 5f - InfoMini Rev & Cost Format and close it.
391
8063ch12.fm
392
8063ch13.fm
13
Chapter 13.
Assignment #6 : Detail/print
reports
In this chapter perform the following:
393
8063ch13.fm
Poor Profit
6a - Basic SummaryReport
PRODUCTCATEGORY
6b - SummaryReportProductCategory
Good Profit
PRODUCTCATEGORY
6d - ChartGoodProfit
PRODUCTNUMBER
6c - DetailReportProductNumber
394
8063ch13.fm
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:
Margin
395
8063ch13.fm
Product Number
Product Name
Sum fields:
396
8063ch13.fm
Margin
397
8063ch13.fm
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.
398
8063ch13.fm
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:
Margin
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.
399
8063ch13.fm
400
8063ch13.fm
401
8063ch13.fm
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).
402
8063ch13.fm
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.
In the next section we will refine this chart so that it will suit to our application.
403
8063ch13.fm
404
8063ch13.fm
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.
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).
405
8063ch13.fm
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
8063ch13.fm
407
8063ch13.fm
Your chart should look now like in Figure 13-20 on page 408.
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
8063ch13.fm
409
8063ch13.fm
410
8063ch13.fm
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. .
411
8063ch13.fm
412
8063ch13.fm
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).
8. Enter parameter name PRODUCTCATEGORY and select Product Category from the
list box.
413
8063ch13.fm
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
8063ch13.fm
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):
415
8063ch13.fm
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
8063ch13.fm
417
8063ch13.fm
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
8063ch13.fm
419
8063ch13.fm
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
8063ch13.fm
421
8063ch13.fm
422
8063ch14.fm
14
Chapter 14.
423
8063ch14.fm
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.
424
8063ch14.fm
Definition
Dimension
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.
425
8063ch14.fm
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.
9. Click Column Totals in the expanded Report ribbon(Figure 14-4 on page 427).
426
8063ch14.fm
12.Select the currency symbol down arrow and then choose Floating
currency.(Figure 14-7)
427
8063ch14.fm
428
8063ch14.fm
17.To create a new heading in the Query panel, right-click CountOrderNumber to see the
field specific submenu.
18.Select Change Title and type the new title Count.Click OK.
19.Click Save, save the report with the name 7a - Revenue summary.
20.Run the report. You have completed your initial summary report.
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
429
8063ch14.fm
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.
430
8063ch14.fm
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.
431
8063ch14.fm
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.
8063ch14.fm
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).
433
8063ch14.fm
Right-click the column heading Revenue and select Visualize (Figure 14-21).
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.
434
8063ch14.fm
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.
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).
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.
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.
435
8063ch14.fm
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).
436
8063ch14.fm
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.
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).
14.Click Run. Figure 14-30 shows the results of running this report.
437
8063ch14.fm
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).
438
8063ch14.fm
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).
439
8063ch14.fm
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.
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
8063ch14.fm
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.
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.
441
8063ch14.fm
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.
442
8063ch14.fm
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
443
8063ch14.fm
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.
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
8063ch14.fm
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:
445
8063ch14.fm
446
8063ch14.fm
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.
447
8063ch14.fm
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.
448
8063ch14.fm
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.
6. At this point you can click Run. However, for demonstration purposes, click OK to see the
full Selection Criteria pane.
449
8063ch14.fm
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.
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
8063ch14.fm
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.
451
8063ch14.fm
9. In the Measures pane (Figure 14-51) select the Revenue check box. Then click the
Revenue name.
10.In the Revenue pane (Figure 14-52), if we want to see a Top 3 analysis report:
a.
b.
c.
d.
e.
452
8063ch14.fm
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.
453
8063ch14.fm
454
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.
455
8063ch15.fm
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.
8063ch15.fm
DB2 Web Query and shows various charts and reports giving several different views of
Product Type information.
457
8063ch15.fm
Figure 15-2 A Web Query document dashboard PDF viewed on mobile devices
458
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
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.
459
8063ch15.fm
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
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.
461
8063ch15.fm
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.
462
8063ch15.fm
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.
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.
463
8063ch15.fm
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.
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
8063ch15.fm
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
465
8063ch15.fm
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.
466
8063ch15.fm
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.
467
8063ch15.fm
Click here
468
8063ch15.fm
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.
469
8063ch15.fm
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.
470
8063ch15.fm
5. Save your document to your folder by pressing the save icon as shown in Figure 15-23.
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.
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.
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.
471
8063ch15.fm
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
8063ch15.fm
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.
473
8063ch15.fm
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.
474
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.
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.
475
8063ch15.fm
476
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.
477
8063ch16.fm
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.
478
8063ch16.fm
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.
479
8063ch16.fm
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
8063ch16.fm
Use the Figure 16-5 to establish the query area for the Revenue line chart.
Use the Figure 16-6 on page 481 to establish the query area for the Profit pie chart.
Finally, use the Figure 16-7 to establish the query area for the Warranty pie chart.
481
8063ch16.fm
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.
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
8063ch16.fm
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.
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.
483
8063ch16.fm
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
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
485
8063ch16.fm
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.
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
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.
487
8063ch16.fm
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.
488
8063ch16.fm
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.
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.
489
8063ch16.fm
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.
490
8063ch16.fm
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.
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.
491
8063ch16.fm
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.
8063ch16.fm
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.
493
8063ch16.fm
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
494
8063ch16.fm
495
8063ch16.fm
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
496
8063ch16.fm
497
8063ch16.fm
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.
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
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.
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.
499
8063ch16.fm
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
8063ch16.fm
7. Now that your three reports are created, you will be able to include them in a new
compound document created with Developer Workbench
501
8063ch16.fm
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
8063ch16.fm
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:
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
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
8063ch16.fm
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.
505
8063ch16.fm
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
8063ch16.fm
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.
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
507
8063ch16.fm
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.
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
8063ch16.fm
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 .
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
509
8063ch16.fm
510
8063ch16.fm
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.
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.
511
8063ch16.fm
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.
512
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.
513
8063ch16.fm
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
8063ch16.fm
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.
515
8063ch16.fm
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
8063ch16.fm
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.
517
8063ch16.fm
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
8063ch16.fm
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.
519
8063ch16.fm
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.
520
8063ch16.fm
16.Right-click on the chart area and select Select Data as shown in Figure 16-62.
521
8063ch16.fm
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.
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
8063ch16.fm
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.
523
8063ch16.fm
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
8063ch16.fm
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.
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.
525
8063ch16.fm
When you are done, Sheet 1 should look like the example shown in Figure 16-72.
526
8063ch16.fm
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.
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.
527
8063ch16.fm
528
8063ch16.fm
529
8063ch16.fm
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
8063ch16.fm
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.
531
8063ch16.fm
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.
532
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.
45.Activate the each of the Refresh Controls and select Preserve Cell Formatting as shown in
Figure 16-81.
533
8063ch16.fm
534
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.
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.
535
8063ch16.fm
7. Click Save
8. Close the Administration Console
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
8063ch16.fm
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.
537
8063ch16.fm
538
8063ch16.fm
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.
539
8063ch16.fm
Figure 16-89 Completed Sales Dashboard using Excel and Spreadsheet Client
540
8063ch18.fm
17
Chapter 17.
541
8063ch18.fm
542
8063ch18.fm
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.
543
8063ch18.fm
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
8063ch18.fm
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.
545
8063ch18.fm
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
8063ch18.fm
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.
547
8063ch18.fm
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
8063ch18.fm
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.
549
8063ch18.fm
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.
550
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.
10.Then we will see the schedule is in the Schedules folder as shown in Figure 17-11 on
page 552.
551
8063ch18.fm
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
8063ch18.fm
553
8063ch18.fm
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
8063ch18.fm
555
8063ch18.fm
556
8063ch18.fm
557
8063ch18.fm
558
8063ch18.fm
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.
559
8063ch18.fm
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
8063ch18.fm
2. After the Basic Scheduling Tool pops up, click Distribution as shown in Figure 17-22, and
then click Folder Location button.
561
8063ch18.fm
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.
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
8063ch18.fm
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.
563
8063ch18.fm
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
8063ch18.fm
565
8063ch18.fm
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
8063ch18.fm
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.
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.
567
8063ch18.fm
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.
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
8063ch18.fm
569
8063ch18.fm
8. Then we can see FTP Distribution List 1 is created as shown in Figure 17-34 on page 570.
570
8063ch18.fm
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.
571
8063ch18.fm
11.Select Distribution List in the type comobox, and then click the Name button as shown in
Figure 17-37.
572
8063ch18.fm
573
8063ch18.fm
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
8063ch18.fm
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.
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
575
8063ch18.fm
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.
576
8063ch18.fm
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.
577
8063ch18.fm
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
8063ch18.fm
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.
579
8063ch18.fm
F3=Exit F4=Prompt
F24=More keys
F5=Refresh
S8f45fc9bs5414s4075sb346sa631f1eeb6a1
*CURRENT
F12=Cancel
580
Character value
8063ch18.fm
The Web Query Administrator can view the Server Status by clicking the Server Status
button as shown in Figure 17-47.
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.
581
8063ch18.fm
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.
582
8063ch19.fm
18
Chapter 18.
583
8063ch19.fm
584
8063ch19.fm
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.
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
585
8063ch19.fm
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
8063ch19.fm
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.
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
587
8063ch19.fm
Configure one or more db2 web query Servers and set up user security to access
Mobile Faves.
Store and view previously-run history for viewing offline, and for your future
reference.
This approach provides more features and faster acces than using the mobile web page
shown in the previous section.
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
588
8063ch19.fm
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.
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
589
8063ch19.fm
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
8063ch19.fm
3. Select the Format tab. If the Output types group is not expanded, Click the Ouput Types
icon on the ribbon to expand it.
4. Click the Active Report icon on the ribbon to change the output format of this 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.
591
8063ch19.fm
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.
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
8063ch19.fm
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.
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.
593
8063ch19.fm
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.
11.Tap Assignment 12 - Going mobile to display the reports that are available.
12.Tap the Report to run it.
Please wait until the Save icon appears on the top left hand side.
594
8063ch19.fm
14.Change the Name of the report to 1a Revenue Summary by Product Category offline
and tap the save icon
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.
595
8063ch19.fm
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.
8063ch19.fm
Tap Mobile Faves icon. This will take you to the intial Mobile Faves screen
597
8063ch19.fm
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.
598
8063ch19.fm
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.
599
8063ch19.fm
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
8063ch19.fm
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.
601
8063ch19.fm
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
8063ch19.fm
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
603
8063ch19.fm
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
8063ch21.fm
19
Chapter 19.
605
8063ch21.fm
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.
606
8063ch21.fm
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.
607
8063ch21.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).
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
8063ch21.fm
3. Expand Adapters Configured DB2 cli. Right click on *LOCAL and Create
Synonym as shown in Figure 19-3.
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.
609
8063ch21.fm
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
8063ch21.fm
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.
611
8063ch21.fm
to the end user, you could simply build the stored procedure directly over the stored
procedure synonym and skip the join steps.
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.
612
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.
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.
613
8063ch21.fm
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.
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
8063ch21.fm
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.
5. Click Ok
615
8063ch21.fm
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.
616
8063ch21.fm
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.
617
8063ch21.fm
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
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
8063ch21.fm
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.
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.
619
8063ch21.fm
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.
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
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.
620
8063ch21.fm
Figure 19-25 Completed report from stored procedure with Plant code selection
621
8063ch21.fm
622
8063ch21.fm
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).
623
8063ch21.fm
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.
624
8063ch21.fm
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.
625
8063ch21.fm
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
8063ch21.fm
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.
627
8063ch21.fm
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.
628
8063ch21.fm
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.
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
629
8063ch21.fm
630
8063ch22.fm
20
Chapter 20.
631
8063ch22.fm
8063ch22.fm
QRYDFN object is called by using the STRQMQRY ALWQRYDFN (*YES) command, which
prompts the user for 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.
633
8063ch22.fm
634
8063ch22.fm
2. In the New Folder dialog box for tittle type: Assignment 15 - Query/400 Modernization
and click OK
3. Right click Assignment 15 - Query/400 Modernization folder. From the list presented
select Metadata and then edit.
635
8063ch22.fm
4. In the next Window Click on Adapters. Right click the Query/400 adapter and then click
Create Synonym
636
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.
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.
637
8063ch22.fm
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.
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.
638
8063ch22.fm
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.
639
8063ch22.fm
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.
.
The last QRYDFN objects (PARMQRY1) accepts an input parameter at run time. In our
example it is using PRODTYPE 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
8063ch22.fm
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
641
8063ch22.fm
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
8063ch22.fm
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).
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.
643
8063ch22.fm
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.
6. Select Product Type from the Data Pane and drag it to the new created Group 2 ribbon.
7. Click the Format tab and change the report output format from HTML to Active Report on
the Output Types ribbon.
644
8063ch22.fm
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.
645
8063ch22.fm
14.A dialog box pops up requesting some information. Leave the defaults and click Save
Report
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
8063ch22.fm
647
8063ch22.fm
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.
648
8063ch22.fm
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.
649
8063ch22.fm
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).
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
8063ch22.fm
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.
651
8063ch22.fm
652
8063ch22.fm
653
8063ch22.fm
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.
8. Right-click the report (the box that you just drew) and select Reference existing
procedure and select the active report (Figure 20-33).
654
8063ch22.fm
10.You are presented with a list of parameters that are referenced by this report
(Figure 20-34).
a.
b.
c.
d.
e.
Figure 20-34 Selecting the parameter control types - Before (left), After (right)
655
8063ch22.fm
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.
656
8063ch22.fm
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.
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.
657
8063ch22.fm
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.
658
8063ch22.fm
659
8063ch22.fm
Figure 20-39 Adding ALL via control Properties and settings in Workbench
660
8063ch22.fm
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.
661
8063ch22.fm
662
8063ch22.fm
32.Right-click the Run report1 button control and select Hyperlink Properties.
663
8063ch22.fm
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.
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.
664
8063ch22.fm
41.In the Font window (Figure 20-46), select the styling for your heading:
a.
b.
c.
d.
665
8063ch22.fm
43.In the Properties pane, click the ... button next to Background color and select a pale color
(Figure 20-47).
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
8063ch22.fm
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.
667
8063ch22.fm
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.
668
8063ch22.fm
47.Click RUN. Figure 20-50 shows the output of running this report.
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.
669
8063ch22.fm
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.
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.
670
8063ch22.fm
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.
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.
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.
671
8063ch22.fm
672
8063ch22.fm
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.
673
8063ch22.fm
4. Run the report with No Selection. It should look like the example shown in Figure 20-58.
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
8063ch22.fm
6. In the HTML Composer tool select the report icon to add a new report to the layout
(Figure 20-60).
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.
675
8063ch22.fm
676
8063ch22.fm
11.Move the elements around on the canvas as shown in the example in Figure 20-62.
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
677
8063ch22.fm
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.
678
8063ch22.fm
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.
679
8063ch22.fm
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
8063ch22.fm
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.
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
681
8063ch22.fm
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.
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.
682
8063ch22.fm
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.
683
8063ch22.fm
684
8063ch17.fm
21
Chapter 21.
685
8063ch17.fm
F0092
F0001
F0005
F9401
8063ch17.fm
F0004
F9202
F9201
For JD Edwards World 8 and 9:
F0092
F0001
F0005
F9401
F0004
F9202
F9210
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.
687
8063ch17.fm
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.
688
8063ch17.fm
4. In the new opened window, click the Adapter to open the Adapter tab, as in Figure 21-3
689
8063ch17.fm
8063ch17.fm
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.
691
8063ch17.fm
Once you have created the synonyms, you can now develop DB2 Web Query reports to
access JD Edwards World data.
692
8063ch17.fm
693
8063ch17.fm
694
8063ch17.fm
4. In the new opened window, click the Adapter to open the Adapter tab, as in Figure 21-8
695
8063ch17.fm
696
8063ch17.fm
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.
697
8063ch17.fm
2. Enter the Library name of the library containing the specificed objects.
3. Click Submit to refresh the security extract.
698
8063ch17.fm
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.
699
8063ch17.fm
3. Select the JD Edwards F0911 synonym in the Select data source dialog window.
700
8063ch17.fm
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
701
8063ch17.fm
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
8063ch17.fm
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.
703
8063ch17.fm
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
8063ch17.fm
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.
705
8063ch17.fm
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.
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.
To do more advance formatting, click on the drop down and select More options
706
8063ch17.fm
The Interactive Design View dynamically reflects this change, as in Figure 21-23 on
page 708.
707
8063ch17.fm
708
8063ch17.fm
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.
709
8063ch17.fm
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
8063ch22a.fm
22
Chapter 22.
711
8063ch22a.fm
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!
712
8063p03.fm
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
713
8063p03.fm
714
8063ch23.fm
23
Chapter 23.
715
8063ch23.fm
716
8063ch23.fm
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
Database
result set
Report
Figure 23-1 Flow of DB2 Web Query report run request
717
8063ch23.fm
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.
718
Operation
SQL equivalent
SELECT
SELECT DISTINCT(.)
8063ch23.fm
Operation
SQL equivalent
FROM
WHERE
HAVING
Ordering rows.
ORDER BY
FROM...WHERE...
Define field
FUNCTON(COLUMN)
719
8063ch23.fm
Operation
SQL equivalent
Compute field
FUNCTON(SUM( ) )
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
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
Arithmetic expressions
NEWSAL/D12.2 =
((CURR_SAL + OTIME_SAL) x 1.1) - 100;
720
8063ch23.fm
Expression
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);
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.
721
8063ch23.fm
Creation of logical
table structures (JOIN)
Aggregating rows
(SUM/COUNT)
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
8063ch23.fm
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
Complex calculations
Sophisticated formatting
Generate graphs
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.
Description
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
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,
723
8063ch23.fm
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
Interface-managed join
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
Aggregation on a non-translatable
DEFINE
724
8063ch23.fm
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.
725
8063ch23.fm
relationships, DB2 Web Query is able to understand the join syntax that must be created and
generates the appropriate SQL statement.
726
8063ch23.fm
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
727
8063ch23.fm
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
8063ch23.fm
729
8063ch23.fm
satisfaction, make sure that the indexes exist over all join fields, order by fields, and fields that
are aggregated.
Database design
Query Engine used
Indexes
Available hardware
Number of concurrent users
730
8063ch23.fm
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.
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:
In addition, SQE provides many more features than CQE. Among them are:
731
8063ch23.fm
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.
732
8063ch23.fm
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.
3. In System i Navigator open a connection to your system and launch a Run SQL Scripts
window.
733
8063ch23.fm
4. Paste the statement from your clipboard into the Run SQL Scripts window. This is shown
in Figure 23-7.
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
8063ch23.fm
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.
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.
735
8063ch23.fm
2. Right-click SQL Performance Monitors and select New SQL Performance Monitor,
as shown in Figure 23-10.
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.
736
8063ch23.fm
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.
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.
737
8063ch23.fm
On the final dialog window for SQL Performance Monitor Wizard, click Finish.
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).
738
8063ch23.fm
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.
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.
739
8063ch23.fm
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
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.
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
741
8063ch23.fm
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.
742
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).
743
8063ch23.fm
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
8063ch23.fm
745
8063ch23.fm
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.
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
8063ch23.fm
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.
747
8063ch23.fm
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
748
8063ch23.fm
749
8063ch23.fm
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.
750
8063ch23.fm
751
8063ch23.fm
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
8063ch23.fm
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:
753
8063ch23.fm
23.6.4 Matrics
The measurement data was summarized into four key metrics:
Seconds
3.000
Qry400 *qrydfns
Web Query *qrydfns
2.500
SQL
2.000
Web Query
1.500
1.000
0.500
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
8063ch23.fm
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.
755
8063ch23.fm
160.00
140.00
Qry400 *qrydfns
120.00
100.00
SQL
80.00
60.00
Web Query
SQL Full Open / Reopt
40.00
20.00
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.
756
8063ch23.fm
MB in Base Pool
3500
3000
Qry400 *qrydfns
2500
2000
SQL
Web Query
1500
1000
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
3.240
0.64
147.26
3188
SQL
0.116
24.82
3.65
2164
Web Query
1.213
3.60
16.20
2676
0.189
11.07
8.80
2164
1.263
3.11
22.30
3000
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.
757
8063ch23.fm
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
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.
759
8063ch24.fm
760
8063ch24.fm
Client Repository
Application
Directories
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.
761
8063ch24.fm
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.
Role Description
WebQueryAdministrator
DevWorkBench
762
Group Name
Role Description
Folder-run
Folder-analyst
Folder-dev
Folder-dba
Folder-sched
8063ch24.fm
Group Name
Role Description
Folder-admin
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.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
MUdomain profile
Folder-run
MDdomain profile
Folder-dev, Folder-dba
MRADMIN
WebQueryAdministrator
MRSCHEDULE
Folder-sched
763
8063ch24.fm
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.
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
Domain
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.
764
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.
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.
765
8063ch24.fm
766
8063ch26.fm
25
Chapter 25.
767
8063ch26.fm
768
8063ch26.fm
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.
769
8063ch26.fm
770
8063ch27.fm
26
Chapter 26.
771
8063ch27.fm
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.
772
8063ch27.fm
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.
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
773
8063ch27.fm
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
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
8063ch27.fm
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.
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.
775
8063ch27.fm
3. Defining this synonym is a two-step process. You will first see a panel similar to
Figure 26-7.
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
8063ch27.fm
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
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.
777
8063ch27.fm
778
8063p04.fm
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
779
8063p04.fm
780
8063ax01.fm
Appendix A.
781
8063ax01.fm
Description
Format or
value
Example (for
October 07,
2012)
&DATE
MM/DD/YY
10/07/2012
&DMY
DDMMYY
071012
&DMYY
DDMMCCYY
07102012
&MDY
MMDDYY
100712
&MDYY
MMDDCCYY
10072012
&TOD
HH.MM.SS
15.50.07
&YMD
YYMMDD
121007
&YYMD
CCYYMMDD
20121007
&DATEWtr
Name of day
of week
Wednesday
&DATEMtrDYY
Name of
month DD,
YYYY
October 7,
2012
&DATEWtr,
&DATEMtrDYY
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
8063ax01.fm
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
Month
Year
YY
Four-digit year
Translate month
Translate month
TR
tr
Quarter
Day of week
Day of week
WR
Day of week
wr
Day of week
JUL
Julian format
YYJUL
Julian format
783
8063ax01.fm
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
784
Format
Display
YMD
12/09/22
Y.M.D
12.09.22
Y-M
12-09
YBMBD
Y|M|D
8063ax01.fm
In WHERE screening
In arithmetic expressions
785
8063ax01.fm
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.
786
8063ax01.fm
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.
787
8063ax01.fm
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.
11.The USAGE field changes to MDYY. Click the save icon to save this change.
788
8063ax01.fm
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).
789
8063ax01.fm
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.
790
8063ax01.fm
e. In InfoAssist, create a New define field by selecting the Data and selecting the Detail
(Define) icon, as shown in Figure A-6.
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.
791
8063ax01.fm
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.
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
8063ax01.fm
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.
793
8063ax01.fm
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
Julian date
Date (a true DB2 date field)
Fiscal year
Fiscal quarter
8063ax01.fm
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:
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
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?
795
8063ax01.fm
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.
Column Name
Data
Length
Length
Description
DC_DATE
DATE
DC_JDE_JULIAN_DATE
DECIMAL
DC_MDYY_DEC
DECIMAL
DC_MDYY_ZONED
NUMERIC
DC_MDYY_CHAR
CHAR
DC_YYMD_DEC
DECIMAL
DC_YYMD_ZONED
NUMERIC
DC_YYMD_CHAR
CHAR
DC_MDY_DEC
DECIMAL
DC_MDY_ZONED
NUMERIC
DC_MDY_CHAR
CHAR
DC_YMD_DEC
DECIMAL
DC_YMD_ZONED
NUMERIC
796
8063ax01.fm
DC_YMD_CHAR
CHAR
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
DC_DOW_ISO
INTEGER
DC_DOY
INTEGER
DC_WOY
INTEGER
DC_WOY_ISO
INTEGER
DC_QOY
INTEGER
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
DC_DAY_NAME
CHAR
DC_QUARTER_NAME
CHAR
DC_WEEKEND
CHAR
Weekend Flag (Y or N)
DC_HOLIDAY
CHAR
Holiday (Y or N)
DC_DAY_BEFORE_HOLIDAY
CHAR
DC_DAY_AFTER_HOLIDAY
CHAR
Day AfterHoliday (Y or N)
DC_FULL_MOON
CHAR
Full Moon (Y or N)
DC_SEASON
CHAR
DC_FISCAL_YEAR
INTEGER
DC_FISCAL_QUARTER
INTEGER
DC_MONTH_NAME
CHAR
DC_MONTH_ABRV
CHAR
DC_JULIAN
NUMERIC
DC_CYYMMDD
DECIMAL
DC_EXCEL_DATE
INTEGER
797
8063ax01.fm
DC_WEEK_STARTING_DATE
DATE
DC_WEEK_ENDING_DATE
DATE
DC_SAME_DAY_LAST_YEAR
DATE
DC_CURRENT_DAY
CHAR
DC_CURRENT_WEEK
CHAR
DC_CURRENT_MONTH
CHAR
DC_CURRENT_QUARTER
CHAR
DC_CURRENT_YEAR
CHAR
DC_CURRENT_YTD
CHAR
DC_CURRENT_DAY_LAST_YEAR
CHAR
DC_CURRENT_WEEK_LAST_YEAR
CHAR
DC_CURRENT_MONTH_LAST_YEAR
CHAR
DC_CURRENT_QUARTER_LAST_YEAR
CHAR
DC_CURRENT_YEAR_LAST_YEAR
CHAR
DC_CURRENT_YTD_LAST_YEAR
CHAR
DC_PREVIOUS_MONTH
CHAR
DC_PREVIOUS_FISCAL_YEAR
CHAR
DC_CURRENT_FISCAL_YEAR
CHAR
DC_PREVIOUS_FISCAL_YTD
CHAR
DC_CURRENT_FISCAL_YTD
CHAR
DC_NTH_DAY_OF_WEEK_OF_MONTH
INTEGER
798
8063ax01.fm
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.
799
8063ax01.fm
800
8063ax01.fm
801
8063ax01.fm
6. As demonstrated in Figure A-16, find and select the cen_date_conv synonym and click
Select.
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
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).
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.
803
8063ax01.fm
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
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.
805
8063ax01.fm
13.Specify ORDDAT as the segment name. When you are finished, your synonym will look
like the example provided in Figure A-21.
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);
806
8063ax01.fm
807
8063ax01.fm
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.
808
8063ax01.fm
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.
5. Run the report. The results should look identical to those in Figure A-26 on page 810.
809
8063ax01.fm
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
8063ax01.fm
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.
811
8063ax01.fm
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
8063ax01.fm
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.
813
8063ax01.fm
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
1 minute, 55 seconds
5.2 seconds
5.4 seconds
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
8063ax01.fm
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.
815
8063ax01.fm
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.
816
8063ax01.fm
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
817
8063ax01.fm
Legacy data
type
Legacy
date
Format
Legacy
example
(August 31,
2012)
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))
)
818
ZONED (7,0)
YYDDD
Julian
Date
2012243
GREGDT( ZN_JUL7,
'I8YYMD' )
Join ZN_JUL to
DC_JULIAN in
DATE_CONV table
DATE(SUBSTR(CHAR(ZN_JUL),1,7))
8063ax01.fm
Example
legacy date
field name
Legacy data
type
Legacy
date
Format
Legacy
example
(August 31,
2012)
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))
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))
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))
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))
819
8063ax01.fm
Example
legacy date
field name
Legacy data
type
Legacy
date
Format
Legacy
example
(August 31,
2012)
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))
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))
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' )
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' )
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
8063ax01.fm
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.
821
8063ax01.fm
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.
822
8063ax01.fm
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):
823
8063ax01.fm
When using DATEDIF, the format of the define field must be defined as an I8 field as shown in
Figure A-35:
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
824
8063ax01.fm
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
PWD
Prior weekday
PBD
WD-
BD-
WD+
BD+
825
8063ax01.fm
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.
826
8063ax01.fm
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.
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
827
8063ax01.fm
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.
828
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.
829
8063ax01.fm
830
8063ax02.fm
Appendix B.
Variable
&DATE
&DATEfmt
Format or value
MM/DD/YY
Any date format.
&DMY
&DMYY
DDMMYY
DDMMCCYY
&FOCCODEPAGE
&FOCFEXNAME
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
&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
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.
833
8063ax03.fm
834
8063ax03.fm
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.
835
8063ax03.fm
3. The new scenario window appears. Type the scenario name CenturyElectronic_cm as
shown in Figure 26-11 and then press OK.
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.
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
8063ax03.fm
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.
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).
837
8063ax03.fm
6. Select synonyms under Century_Electronic in Reporting Servers tree and add them to
the right panel as shown in Figure 26-15.
7. 7.Save this scenario by left clicking Save button as shown in Figure 26-16
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
8063ax03.fm
839
8063ax03.fm
840
8063ax03.fm
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
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
841
8063ax03.fm
842
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.
843
8063ax04.fm
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:
844
8063ax04.fm
845
8063ax04.fm
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.
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
8063ax04.fm
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.
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.
847
8063ax04.fm
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
8063ax04.fm
849
8063ax04.fm
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
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.
For more details about using Developer Workbench, refer to the online help text and the
OLAP chapter in this document.
851
8063ax04.fm
852
(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
(0.2spine)
0.17<->0.473
90<->249 pages
(0.1spine)
0.1<->0.169
53<->89 pages
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
(2.0 spine)
2.0 <-> 2.498
1052 <-> 1314 pages
Back cover
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.