Tải bản đầy đủ (.pdf) (34 trang)

Tài liệu Chapter 9: Creating Queries docx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.53 MB, 34 trang )

Chapter 9:

Creating Queries

Contents
Overview .................................................................................................................. 9–2
Creating and Saving a New Query ........................................................................ 9–3
Defining a Filter in a Query.................................................................................... 9–9
Creating Restricted Key Figures......................................................................... 9–10
Creating a New Formula—Percentage Change InfoObject .............................. 9–12
Creating a Calculated Key Figure ....................................................................... 9–14
Working with BW Queries: Additional Functions ............................................. 9–16
Review ................................................................................................................... 9–34

Report Development Tools

9

In this chapter you will learn
how to:
Create and save a new
query
Define filters in a query
Create restricted key
figures and calculated key
figures in a query
Create new formulas in a
query
Work with drilldown,
currency conversion,
charts, and other BW


query functions

9–1


Chapter 9: Creating Queries
Overview

Overview
In chapter 8 you learned how to:
<

Build a workbook template

<

Insert an existing query into a workbook

<

Save a workbook to the InfoCatalog

Queries define the structure of a workbook in the Business Explorer (BEx) Analyzer. In the
previous chapter you learned how to insert Bungee Software’s Sales Analysis query into a
workbook. With the help of a guided tour, you will now learn how to create the same query.
During the query building process, you will learn how to define filters, create restricted key
figures, and create calculated key figures. Later in the chapter we cover additional features
and functions to help you work with BW queries.

1


Create a workbook
Create a workbook
template (optional)
template (optional)

2

Insert desired query (or queries)
Insert desired query (or queries)
into a workbook
into a workbook

3

Enhance workbook layout
Enhance workbook layout
and functionality (optional)
and functionality (optional)

4

Create a new query or
Create a new query or
modify an existing query
modify an existing query

Chapter 9

5


Enable access to a workbook
Enable access to a workbook
through the BEx Browser
through the BEx Browser

Chapter 10

Chapter 8

You are here

Before Getting Started
Before you start building a query, it is important to have a clear understanding of the user
requirements. For instance, Bungee Software executives primarily request sales revenue and
gross profit data, grouped by organization, product, customer, and sales employee. Thus,
the relevant characteristics are Sales Organization, Distribution Channel, Division, Material,
Material Group, Customer, and Sales Employee. The relevant key figures are Sales Revenue
and Gross Profit. Users can include key figures and characteristics in one or more queries.

9–2

Reporting Made Easy


Chapter 9: Creating Queries
Creating and Saving a New Query

In this example, we separate the sales revenue and the gross profit information into two
different queries:

<

Sales analysis query (0D_SD_DEMO_Q0001): First, you will learn how to build the sales
analysis query, including the creation of restricted key figures.

<

Gross profit analysis query (0D_SD_DEMO_Q0002): Next, you will learn to build the
gross profit analysis query, including the creation of calculated key figures.

Creating Queries Based on the SAP DemoCube
Before you can start creating the queries covered in this chapter, you must make sure that
the SAP-delivered DemoCube is available in your BW system.
The SAP DemoCube is available with BW Release 1.2B (patch 8). To work with the
sample queries shown in this guide, you may need to activate the contents of the SAP
DemoCube and upload the data to your system. For help activating the SAP DemoCube,
see your system administrator. Information on the SAP DemoCube can also be found in
chapter 11.

Now let us return to the BEx Analyzer to start creating the sales analysis query.
Guided Tour

Creating and Saving a New Query
1. To create a new query,
New from the
choose
Business Explorer toolbar.

1


Report Development Tools

9–3


Chapter 9: Creating Queries
Creating and Saving a New Query

2. If you are already logged
on to the BW system,
jump to step 3. If not,
follow the onscreen
prompts to log on to the
BW system.
3. Choose

.

3

4. Choose the InfoCubes for
new query folder to get an
expanded list of the demo
cubes.

4

5. Expand the SAP Demo
area and choose the SAP
DemoCube.

6. Choose OK.

5

6

9–4

Reporting Made Easy


Chapter 9: Creating Queries
Creating and Saving a New Query

Take a few moments to
familiarize yourself with the
Define query: New query
window. You can define
queries simply by dragging
and dropping available
objects (from the left side) to
the Definition area on the
right.
7. Expand the SAP
DemoCube InfoCube to
view the Key figure and
Dimensions folders.

Query toolbar: See
next page to learn

more.
7

You can drag and drop
characteristics and key
figures to the Filter, Free
Characteristics, Columns,
and Rows areas,
depending on how you
want to set up your
queries.

Query layout appears in
this window.

Characteristic: A criterion (for example, plant, material, company code, etc.) used to select
data.
Dimension: A logical grouping of characteristics.
Key Figure: A value you can report on.
Free Characteristics: Fields that can be defined to provide values according to whatever
criteria you select.

Report Development Tools

9–5


Chapter 9: Creating Queries
Creating and Saving a New Query


The Query Toolbar
To help you become familiar with the Query toolbar, the following table shows how the
various buttons are used during query definition.

Button

Use to…
Transfer a query to a workbook.
Exit the query.
Create a new query.
Open an existing query.
Save a query.
Save a query with a different name.
Delete a query.
View query information, maintain the display format, and release the
option of OLE DB for OLAP.
Check the definition of a query.
View where a query is used in all workbooks.
Switch between displaying or maintaining a query.
View the context menu to display the technical names of the fields in
Query definition.
Open the BEx help file.

9–6

Reporting Made Easy


Chapter 9: Creating Queries
Creating and Saving a New Query


8. Define Rows: From the
Organization dimension,
drag the Company code
into the Rows area.
9. Define Columns: From
the Key figure folder and
the Time dimension, drag
Sales Revenue and Calendar
Year into the Columns
area.
10. Define Free
Characteristics (using
drag and drop):
From the Organization
dimension, drag Sales
organization,
Distribution channel,
and Division.
From the Customer
dimension, drag Soldto-Party/Industry.
From the Sales employee
dimension, drag Sales
employee.
From the Product
dimension, drag
Material group and
Material SAP (Demo).
From the Time
dimension, drag

Calendar year/quarter.

10

9

8

Note: The format of the query is
shown in the lower right corner.

You may want to avoid expanding the tree in the Available objects area unless necessary.
Because there are thousands of items available (especially for customers and materials), an
expanded listing could take some time to navigate. In Release.1.2B, you can have a default
setting that only lists the first 100 available objects.

Report Development Tools

9–7


Chapter 9: Creating Queries
Creating and Saving a New Query

11. Use drag-and-drop to
change the sequence of
the InfoObject. For
instance, to re-position
the InfoObject, Sales
Employee in the Free

Characteristics area, drag
the Sales Employee
InfoObject and drop it at
the Material InfoObject
area.

12. The InfoObject Sales
Employee is repositioned
after the Material SAP.

11

13

13. Choose Save.

12

14. In Technical name, enter a
name for the query (for
example, ZDEMO).
15. In Description, enter a
description for the query
(for example, Sales
Analysis).

14

15


16. Choose OK to exit the
Save query screen.
You have now created and
saved a basic query called
Sales Analysis.

9–8

16

Reporting Made Easy


Chapter 9: Creating Queries
Defining a Filter in a Query

Defining a Filter in a Query
You can use filters to show or hide values depending on your needs.
1. Expand the
Version dimension.
2. Drag 0D_VTYPE into the
Filter area.
3. Select 0D_VTYPE, rightclick the mouse and
choose Restrict to restrict
the view of the data (for
example, Actual or Plan
views).

4. To view the actual data,
choose the Single value

tab.
5. Click
Display to get a
list of possible entries if
needed. Choose the value
Actual.

3
1
2

4

5

6. Choose OK.

6

Restricting characteristics
With the definition of a query it is possible to restrict characteristics to a single
characteristic value, a value interval, a hierarchy node or a characteristic value variable.
For instance, you can create a query, in which all of the InfoCube data is restricted, using
the characteristic, Calendar Year and restricting the value interval year 1997 to 1998.

Report Development Tools

9–9



Chapter 9: Creating Queries
Creating Restricted Key Figures

7. The result of this query
will show the value type
Actual.
7

You have successfully set a
filter for your query.

Creating Restricted Key Figures
Restricted key figures are key figures with restricted values. For example, in Columns you
can define the restricted key figures to limit the display of values within a calendar year
instead of using the characteristic, Calendar year to display the value for all available
calendar years. We will use Sales Revenue to restrict the display to values which fall in
calendar years 1998 and 1997.
1. Using the Sales Analysis
query, choose
from the
Available objects area.

1

2

2. Right-click and select New
restricted key figure.

9–10


Reporting Made Easy


Chapter 9: Creating Queries
Creating Restricted Key Figures

3. On the Restricted key figure
screen, choose a key
figure (for example, Sales
Revenue) from the
Available objects area and
drag it into the New
restricted key figure folder
in the Definition area.

5
3

4. From the Time dimension
drag Calendar year to the
Definition area.
5. Choose a characteristic
(such as Calendar Year),
right-click the mouse, and
choose Restrict.

6. We will now define the
restriction for Calendar
year to be used for the

Sales Revenue key figures.
In this example, only
entries for 1998 will be
shown.

4

6

7. Choose OK.

7

Report Development Tools

9–11


Chapter 9: Creating Queries
Creating a New Formula—Percentage Change InfoObject

8. Enter the Technical name
and Description of the
restricted key figure.

11
8

9. You can define how the
number of decimal places

will be displayed.
10. Use currency conversion
(if needed) to assign the
currency in which the
workbook values are to be
displayed. For more
information on currency
conversion, see chapter
11.

10

9

11. Choose OK.

Repeat steps 1 through 12 to
create the restricted key
figure, 1997 Sales Revenue.
12. Drag the restricted key
figures, 1998 Sales Revenue
and 1997 Sales Revenue
and drop them into the
Columns area. The result
shows the defined 1998
and 1997 sales revenues
restricted by the
characteristic, Calendar
year.


12

Note: Restricted key figures and calculated key figures are InfoCube dependent.

Creating a New Formula—Percentage Change InfoObject
In the Bungee Software Sales Analysis report, there is a % Change column. To define
formulas for structure elements in queries, SAP provides five different percent functions.
For more information see Tips & Tricks in chapter 11. In the Sales Analysis report, we use the
SAP-delivered % Percentage variance function.

9–12

Reporting Made Easy


Chapter 9: Creating Queries
Creating a New Formula—Percentage Change InfoObject

1. Using the Sales Analysis
query, choose
.
2. Right-click Structure and
select New formula.

1

A popup window appears,
where we can define a new
formula (percentage variance
function).

3. Place the cursor in the
Formula area.
4. From the Structure
elements folder in the
Operands area, choose
1998 Sales Revenue.
Double-click 1998 Sales
Revenue to move it to the
Formula area.
5. From the Operators folder
in the Functions area,
choose the Percentage
functions folders. Doubleclick % Percentage
variance. The % symbol
now appears in the
Formula area.

2

7

8

3

4
6

5


9

6. Repeat step 4 above and
choose the InfoObject,
1997 Sales Revenue.
7. Enter a description, %
Change.
8. Choose Check to verify
whether the formula is
syntactically correct.

Report Development Tools

9–13


Chapter 9: Creating Queries
Creating a Calculated Key Figure

9. Choose OK.
10. A new InfoObject,
, now
appears in the Columns
area.

13

11. Choose
Transfer
Query in Workbook to

transfer the Sales Analysis
query into a workbook.

10

Using the approach shown in
the preceding pages, you can
also create a query for Gross
Profit Analysis. For
illustration purposes, we will
not repeat all the steps to
build such a query, but rather
focus on creating a calculated
key figure.

Creating a Calculated Key Figure
Calculated key figure implies that key figures can be calculated based on a formula. For
example, the gross profit calculation for Bungee Software Inc. would be: Sales revenue
minus the cost of goods sold. In this section you will see how to create the key figure gross
profit.
1. Using the Gross Profit
Analysis query of SAP SD
DemoCube Workbook,
choose the
Key figure folder from the
Available objects area.

1

2


2. Right-click the mouse and
choose New calculated key
figure.

9–14

Reporting Made Easy


Chapter 9: Creating Queries
Creating a Calculated Key Figure

3. Enter a description,
Gross Profit.

3

4. Place the cursor in the
Formula area.
5. To define the formula,
first double-click Sales
Revenue (in the Operands
area).
6. Choose the
function.

8

4

6

7
5

minus

7. Double-click
.
8. To check the formula,
choose the Check button.
9. Choose OK.
10. Enter the Technical name
and Description of the
calculated key figure.

9

13
10

11. You can define how the
number of decimal places
will be displayed.
12. Use the currency
conversion (if needed) to
assign the currency in
which the workbook
values are to be
displayed. For more

information on currency
conversion, see chapter
11.

12

11

13. Choose OK.

Report Development Tools

9–15


Chapter 9: Creating Queries
Working with BW Queries: Additional Functions

14. A calculated key figure,
Gross Profit now appears
in the Calculated key figures
folder.
15. Drag the calculated key
figure, Gross Profit, and
drop it in the Columns
area (under Structure).

14
15


Calculated Key Figures vs. New Formula
The formula that is defined for calculated key figures is InfoCube-dependent.
That means the calculated key figure is available for every query in that
InfoCube. You can also define a query-specific formula: To create a queryspecific formula, from the Columns area, choose
Then, right-click
and choose New formula to define a new formula (similar to steps 3 through 9
in the calculated key figure section above). The formula that is defined under
Structure in the Column/Row area is query-specific.

Working with BW Queries: Additional Functions
In the first part of this chapter you saw how simple queries are created. The remainder of
the chapter is devoted to additional features and functions of BW queries.
To help you get more out of BW queries, we will explore the following functions:
<
<

Disabling the interactive drilldown capability (restricting users from changing saved
data in workbooks)

<

Selecting filter values for characteristics

<

Drilling down or across (slice & dice)

<

Sorting data


<

Positioning/hiding the totals

<

Converting currencies

<

9–16

Suppressing the display of repeated text and/or key values

Displaying reports graphically

Reporting Made Easy


Chapter 9: Creating Queries
Working with BW Queries: Additional Functions

Suppressing the Display of Repeated Texts and/or Key Values
You can restrict given values from being repeatedly displayed in a list. For example, to list
data by company code and sales organization in the Sales Analysis report, the company code
for U.S. and Europe is displayed multiple times. Follow the steps shown below to keep
redundant or repeated text/key values from being displayed.

In Queries

1. Using the Gross Profit
Analysis query to
suppress repeated display
in a query, choose
Query properties.

1

2. Select the Suppress repeated
texts display option.
3. Choose OK.

2

3

Report Development Tools

9–17


Chapter 9: Creating Queries
Working with BW Queries: Additional Functions

In Workbooks
1. To suppress the display of
repeated key values in a
workbook field, such as
Company Code, choose the
column where the key

value is located.
2. Right-click and choose
Properties.
1

2

3. From the Display tab
select Suppress repeated key
values.
4. Choose OK.
3

4

Refresh Formatting on Data Refresh
This default option guarantees that formatting is adjusted after refreshing
updated data. To display data more quickly, you can deselect this function.
Display Scaling Factors for Key Figures
This function enables the user to display the scaling factor for key figures, for
example, displaying $3000000 as $3000 for easier reading.

9–18

Reporting Made Easy


Chapter 9: Creating Queries
Working with BW Queries: Additional Functions


5. The result of the
suppressing the repeated
key value, Company Code,
is shown at right.

5

Disabling Interactive Drilldown
Interactive functions, such as navigating or refreshing, enable the users to stop report views
from being changed.
1. Choose the key value
column (for example,
Company Code).
2. Right-click and choose
Properties.

1

2

3. From the Interaction tab,
choose Enable Interactive
Functions.
4. Choose OK.

3

4

Report Development Tools


9–19


Chapter 9: Creating Queries
Working with BW Queries: Additional Functions

Save and Reuse Variable Values
If variables that are ready for input are used in a report, you can enter
desired values or confirm the default values when embedding the query in
an Excel worksheet. To save and reuse variable values, choose the Save and
reuse variable values option.
Query ID
The technical identification number of the query is displayed as the query ID
and cannot be changed.

Selecting Filter Values for Characteristics
1. To display only the U.S.based company codes,
choose a Company Code
cell with the value US.
2. Right-click and choose
Filter and drill down
according to, then Sales
Organization.
2

1

3. The report results are now
restricted to U.S.

company codes and
displayed by Sales
Organization. In this
example, Company Code
2000 is the key and US is
the description.

9–20

3

Reporting Made Easy


Chapter 9: Creating Queries
Working with BW Queries: Additional Functions

Slice & Dice: Drilling Down
Users can view the
information by “exchanging”
the current display (by Sales
Organization) with a different
area (for example, Material
Group, or even get more
product detail by further
drilling down to Material).
1. Choose the Sales
Organization column.

1


2. Right-click and choose
Exchange Sales
Organization with, then
Material Group.

2

3. Choose the Material Group
column.
4. Right-click and choose
Insert drill down according
to, then Material.

3

Report Development Tools

4

9–21


Chapter 9: Creating Queries
Working with BW Queries: Additional Functions

The report now displays the
drilldown results. The data is
now organized by Material
Group and Material.


Slice & Dice: Drilling Across
Instead of viewing the information vertically (drill down), you can also display the
information horizontally (drill across).
1. To drill across, choose
Calendar Year/Quarter.
2. Right-click and choose
Drill down → Across.
1
2

9–22

Reporting Made Easy


Chapter 9: Creating Queries
Working with BW Queries: Additional Functions

The screen at right shows the
results of drilling down by
Material, and drilling across
by Calendar Year/Quarter.
3. The Material information
is displayed vertically.
4. The Calendar Year/Quarter
is displayed horizontally.

5
3


Sorting Data
Users can sort the
characteristics or key figures
in ascending or descending
order. For example, to find
the top-selling material we
can sort the sales revenue in
descending order.
1. Choose a key figure
column (for example,
1998 Sales).

1

2. Right-click and choose
Sort descending.
2

Report Development Tools

9–23


Chapter 9: Creating Queries
Working with BW Queries: Additional Functions

3. The result indicates that
Barrio Brothers achieved
the highest sales in 1998.

4. Sales of Kung Fu Grandma
decreased by 52 percent
in 1998 compared to 1997.
Note: The annotations in the
textbox discuss possible
reasons for the dismal sales of
Kung Fu Grandma.

3

Optional: To sort
characteristics, choose a
characteristics column (for
example, Material). Rightclick and choose Sort Material
→ Descending according to
name.

4

Positioning/Hiding the Totals Row
Users can change how the totals row is displayed. The totals row can be displayed in the top
left or the bottom right. If needed, the totals row can be hidden from view.
1. Choose a cell that is
related to a characteristic,
such as Material, and
right-click the mouse.
2. Choose All chars →
Suppression of total rows →
Never (to hide the totals
rows).

3. Choose All chars →
Position of totals row to
change the position of the
totals row.

1

3

2

9–24

Reporting Made Easy


Chapter 9: Creating Queries
Working with BW Queries: Additional Functions

Converting Currencies
Since Bungee Software has operations in U.S. and Europe, sales revenue is recorded in
multiple currencies.
Currency conversion enables users to translate the values of the query into a joint target
currency, database currency, or currencies according to the query definition. Therefore, it is
possible to display the values in various currencies or unify currency handling and display
the values as one currency.
In the example shown below, the sales revenue currency is being changed from U.S. dollars
(USD) to Deutsche marks (DEM).
1. Choose a key figure (for
example, 1998 Sales).

2. Right-click and choose
Currency Translation →
According to target
currency.

1

2

Report Development Tools

9–25


×