More Related Content
Similar to OLAP Reporting In CR v2
Similar to OLAP Reporting In CR v2 (20)
OLAP Reporting In CR v2
- 2. Slide 2 Copyright © 2005 Business Objects S.A. All rights reserved.
What is OLAP Reporting In CR?
CR provides a data “view” of an OLAP cube, presented in the form
of a grid.
Conceptually, a “view” consists of axes, the dimensions on those axes, and
the members chosen from those dimensions.
The “view” of an OLAP grid is constructed with 3 different axes:
row, column, and slice. (show picture).
The row and column axes of an OLAP grid must contain at least 1 dimension
each.
• Multiple members of a dimension can be chosen on the row and column axes. Multiple
dimensions can be “stacked” on a single axis.
The dimensions on the slice axis indicate the specific “slice” of the cube that
we want in the report.
A report can have multiple OLAP grids, each grid representing a
different “view” of the cube and possibly “views” from different
cubes.
“Views” can be inherited and used to query data for charts and
maps.
- 3. Slide 3 Copyright © 2005 Business Objects S.A. All rights reserved.
An OLAP Grid
Parts of an OLAP grid:
Row/column labels
• Row labels indicate the row dimension members chosen for the “view”
• Column labels indicate the column dimension members chosen the “view”
Grid cells
• Contain a type of measurable value, ie. sales, unit costs, profits, expenses, etc.
– A view may have a “measures” dimension, in which case multiple types of measurable
values can be displayed if the dimension is on the row/column axis, or a single type of
measure if the dimension is on the slice axis. (show diagram)
Section heading
• Contains labels which indicate the member chosen for each dimension on the slice axis
Each row/column of an OLAP grid represents data for a dimension
member, a member instance when there are stacked dimensions.
(show diagram)
- 4. Slide 4 Copyright © 2005 Business Objects S.A. All rights reserved.
Using SOFA
SOFA = Seagate OLAP Framework Architecture
SOFA is the SDK used by CR and OLAPI to provide access to OLAP data sources.
CR uses the COM Wrapper interface to SOFA. The 2 main COM dlls are CoData.dll (contains API
for view manipulation and querying) and CoUtilities.dll (contains API to retrieve properties of a
cube).
sofa.hpp (under //depot/Reporting/<stream>/crystalreports/cpp/src/include) is included by all
source files which need to use SOFA. It includes the compiled SOFA IDL headers.
The COM interface ISCOViewpoint is used to represent the “view” of a cube. Each OLAP grid in
CR holds reference to an ISCOViewpoint object.
SOFA supports connections to:
MS Analysis Services 7 and 2000
SAP BW
Holos
Essbase
On UNIX, only SAP BW, Holos and Essbase
For more information about SOFA architecture, please refer to documentation under:
http://vanshr01.crystald.net/rdweb/Documents/Technology/OLAP/SOFA
http://olapzone:8080/
- 5. Slide 5 Copyright © 2005 Business Objects S.A. All rights reserved.
SOFA Interfaces
All the SOFA COM interfaces we use in CR and CRPE are included in
sofa.hpp
In our code, we do not use SOFA COM interfaces directly – that is why in
sofa.hpp we see DECLARE_CSOLEINTERFACE_PTR(ISCOViewpoint);
The macro DECLARE_CSOLEINTERFACE_PTR implements a wrapper class
for the COM interfaces which provides smart pointer functionality. See
iunkrel.hpp.
Handles ADDREF and RELEASE
There is another macro OBTAINED_INTERFACE which we use to increase
the reference count and track where the reference count is changed.
Typically we will see:
{
CSISCOViewpoint csIViewpoint;
// code to set the ISCOViewpoint to csIViewpoint by reference
…
OBTAINED_INTERFACE (csIViewpoint); // ADDREF on ISCOViewpoint
…
// leaving method – RELEASE will automatically be called on ISCOViewpoint
}
- 6. Slide 6 Copyright © 2005 Business Objects S.A. All rights reserved.
Connections to OLAP cubes
Each OLAP grid has a connection (through SOFA) to an
OLAP cube.
A report can also have a connection to an OLAP cube
through the CRDB_OLAP driver.
The CRDB_OLAP driver in turn connects to the OLAP cube using
SOFA.
The CRDB_OLAP (crdb_olap.dll) provides a relational connection to
the cube, giving access to all the metadata (dimension member
names). Each dimension of the cube is treated as a database field,
with database tables for each member level hierarchy. It is not a
“flattening” driver, supporting relational queries on the cube. (show
diagram).
- 7. Slide 7 Copyright © 2005 Business Objects S.A. All rights reserved.
Connecting to OLAP cubes
Whether through SOFA directly or through CRDB_OLAP driver, connection
information is stored in a URI string
The URI string contains information about the:
• type of OLAP server
• server name
• cube name
• user ID
• password
Syntax of the URI string is defined by SOFA.
A sample URI string for an MSOLAP connection:
• occa:odbo://;provider="MSOLAP.1",SERVERTYPE="SERVER",SERVER="localhost",USER="",PWD="",CATALOG="FoodMart
2000",CUBE="Sales"
The URI string is stored in Crystal Reports, as a BSTR member of RDOlapCubeInfo class.
• password information is not stored
• URI string is encrypted when saved
When opening a saved OLAP report, CR will attempt to connect to the cube using the
blank password. If logon fails, then CR will prompt for the user ID and password.
To establish a cube connection, pass the full URI string (including password) to
ISCOCube::Open method.
In CR, cube connections are established in method RDOlapCubeInfo::getCube in cubeinfo.cpp.
In CRDB_OLAP, it is DbServerHandle::logon in olapcommon.cpp.
These methods are good places to set breakpoints when debugging connection issues.
- 8. Slide 8 Copyright © 2005 Business Objects S.A. All rights reserved.
Creating a view of the cube
In order to access data from an OLAP cube, we need to create a
view – an ISCOViewpoint object.
The viewpoint must be opened against the cube. The
ISCOViewpoint::Open method should be called. The definition of
ISCOViewpoint::Open in olapdata.h:
virtual /* [helpstringcontext][helpcontext][id] */ HRESULT
STDMETHODCALLTYPE Open(
/* [optional][in] */ VARIANT Source,
/* [defaultvalue][in] */ long ViewAxes,
/* [defaultvalue][in] */ long SliceAxes,
/* [optional][in] */ VARIANT Repository,
/* [optional][in] */ BSTR Name) = 0;
In CR we use OLAPUtil::OpenViewpoint where we just pass in the
ISCOCube object as the source and the ISCOViewpoint object to be
open.
- 9. Slide 9 Copyright © 2005 Business Objects S.A. All rights reserved.
Querying viewpoint for data
ISCOViewpoint is used to query metadata (row/column dimension
member names) and cell data.
Steps for querying metadata:
Use ISCOViewpoint to query for the ISCODataResultSet
Use ISCODataResultSet to get the ISCOAxisResultSets
Use ISCOAxisResultSets to get the ISCOAxisResultSet for a specific axis
Set the start and end range of metadata to query on ISCOAxisResultSet
Use ISCOAxisResultSet to get the ISCOMemberSequence
ISCOMemberSequence is an iterator on the axis metadata – can retrieve the
instance member name and move to the next row/column
Steps for querying cell data:
Use ISCOViewpoint to query for the ISCODataResultSet
Set the start and end range of cell data to query on ISCODataResultSet
Use ISCODataResultSet to get the ISCOCellSequence
ISCOCellSequence is an iterator on all the cell data – can retrieve the
numeric data of a cell and move to the next cell
- 10. Slide 10 Copyright © 2005 Business Objects S.A. All rights reserved.
OLAP value grid
Metadata and cell data are stored in a value grid object called
DSOLAPGrid.
DSSpilledOLAPGridManager stores all DSOLAPGrid objects in a
report document. DSSpilledOLAPGridManager belongs to the
DSOlapGridManager of the report document. DSOlapGridManager
also manages all the grid instance specific information through a
DSObjectInstanceManager.
Each instance of an OLAP grid object should have an associated
value grid.
Instances of OLAP grid objects are defined by their “slice” values –
the dimension members on the slice axis. In CR, it is possible that a
single OLAP grid object have multiple instances if using paged
dimensions.
- 11. Slide 11 Copyright © 2005 Business Objects S.A. All rights reserved.
Fetching OLAP value grid
Need the OLAP value grid (DSOLAPGrid) for formatting.
Workflow (see also
DSOlapGridManager::fetchValueGrid):
PFFormattedOLAPGridObject will ask the DSOlapGridManager for
the value grid of an OLAP grid object.
DSOlapGridManager will ask the DSObjectInstanceManager for the
DSObjectInstance specified by the OLAP grid and the containing
section’s data context.
DSOlapGridManager will ask the DSSpilledOLAPGridManager for the
value grid specified by the DSObjectInstanceKey of the OLAP grid’s
DSObjectInstance.
If a value grid exists, DSSpilledOLAPGridManager will return it.
Otherwise, DSOlapGridManager will create a new DSOLAPGrid and
store it in the DSSpilledOLAPGridManager.
- 12. Slide 12 Copyright © 2005 Business Objects S.A. All rights reserved.
Fetching row data per page
When populating the OLAP value grid, we only query SOFA for the
rows of data required to format the page – formatting OLAP grid
rows on demand.
Formatting OLAP grid rows on demand was implemented mainly for
performance reasons when formatting large OLAP grids which
span multiple vertical pages. Querying for a subset of row
metadata/cell data is quicker than querying for all the rows.
Result: Formatting the first page should be quick. This is desirable
because the first page is what the customer sees first.
The range of rows to query for is an approximation, calculated by
taking the height of the page and divided by the minimum height of
each grid row. (see
PFFormattedOLAPGridObject::calculateMetadataRange)
Formatting OLAP grid columns on demand is not implemented,
mainly because use scenarios of OLAP grids spanning many
horizontal pages is limited.
- 13. Slide 13 Copyright © 2005 Business Objects S.A. All rights reserved.
Paged Dimensions
A feature in CR where OLAP grids are placed in groups created
based on the “paged” dimension selected.
A group is created for each dimension member level of the
members selected for the “paged” dimension. The dimension
member level is treated as a database field, and the records are the
names of the selected members.
For every member of a level, a new group instance is created, which
contains a formatted OLAP grid.
A “paged” dimension is displayed as a slice dimension in the
section heading, where the displayed value is the dimension
member in which the containing group was created for. In fact, a
“paged” dimension is a dimension that resides on the slice axis.
“Paged” dimensions can only be created from the OLAP Report
Creation Wizard.
It is because of “paged” dimension that we have crdb_olap.dll,
which creates a database table for each dimension, and database
field for each member level.
(Live Demo)
- 14. Slide 14 Copyright © 2005 Business Objects S.A. All rights reserved.
Viewpoint Hierarchy
In simple case of a single OLAP grid in a report, there is only 1 viewpoint used by the formatted
instance and the design object.
A viewpoint can be linked to (inherited from) another viewpoint.
It is the same procedure as to how a viewpoint is “opened” against an ISCOCube source, except that an
ISCOViewpoint is used as the source.
See uses of OLAPUtil::OpenViewpoint method.
Linked/inherited viewpoints are used when there are paged dimensions.
Each grid instance (DSOlapGridInstance) has its own viewpoint which inherits from the design object
(RDOlapGridObject) viewpoint.
The viewpoint of the design object inherits from the template viewpoint opened against the cube. (see diagram)
The viewpoints of charts and maps inherit from the viewpoint of the RDOlapGridObject.
The behaviour between inherited viewpoints and their parent viewpoints is defined by a “link
mode”.
By default, the link mode between inherited viewpoints and parent viewpoints is such that changes made to the
parent viewpoint is also reflected in the child viewpoints
In CR, we explicitly set the link mode of the inherited viewpoints such that changes made to the inherited viewpoints
do not affect the parent viewpoint
Example: In a paged OLAP report, if you drill down on a row dimension member of a grid, the other grid instances
within the same group will have drill down performed on them as well. It is because the drill down is actually
performed on the RDOlapGridObject. Each grid instance has a different slice dimension value, but does not affect
the slice dimension value of the RDOlapGridObject viewpoint (demo)
There are specific parts of a viewpoint which we can set the link mode: ISCOAxes, ISCOAxisDimension,
ISCOFilters, ISCOFormats, ISCOSorts
See the CoLink enum defined in olapdata.h for the different link mode types.
- 15. Slide 15 Copyright © 2005 Business Objects S.A. All rights reserved.
OLAP Parameters
There are 3 types (corresponding to the types of
dimensions):
Row and column dimension parameters
• Parameter can define multiple discrete string values corresponding to the member
names
Slice dimension parameter
• Parameter can define a single discrete string value corresponding to a member
name
Page dimension parameter
• Parameter can define multiple discrete string values corresponding to the member
names
• The member names can only be from a single dimension hierarchy level
• A record selection formula is generated, using the page dimension parameter to
filter out records. See VWizReportFactory::changeSelectionFormulaForParameters
method for details. (show sequence pics)
All OLAP parameters are String type parameters
- 16. Slide 16 Copyright © 2005 Business Objects S.A. All rights reserved.
Active-X Controls
CR makes use of some Active-X controls available from
SOFA.
Ie. OLAP Connection Browser dialog, Member Selector dialog,
Calculated Members dialog
For exact listing of controls, see sofa.hpp
These Active-X controls are the same ones used by
OLAPi
(show pictures)