Top Banner
7/27/2019 SAP Queries Guide http://slidepdf.com/reader/full/sap-queries-guide 1/186 Queries Guide BI/Query 8497-1M  ™
186

SAP Queries Guide

Apr 13, 2018

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 1/186

Queries Guide

BI/Query

8497-1M

 ™

Page 2: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 2/186

8497-1M

Hummingbird Ltd.

1 Sparks Avenue, North York, Ontario, Canada M2H 2W1Telephone (Canada and USA): +1-877-FLY HUMM (+1-877-359-4866)Telephone (Worldwide): +1-416-496-2200

Fax: +1-416-773-5825BBS: +1-416-496-9233E-mail: [email protected] Site: www.hummingbird.comFTP: ftp.hummingbird.com

RESTRICTED RIGHTS LEGEND. Unpublished rights reserved under the copyright laws of the United States. The SOFTWAis provided with restricted rights. Use, duplications, or disclosure by the U.S. Government is subject to restrictions as set forth insubparagraph (c) (1) (ii) of The Rights in Technical Data and Computer Software clause at DFARS 252.227-7013, subparagraph (c)and (2) (a) (15) of the Commercial Computer Software-Restricted Rights clause at 48 CFR 52.227-19, as applicable, similar clausesthe FAR and NASA FAR Supplement, any successor or similar regulation.

Copyright © 2000 Hummingbird Ltd. All rights reserved. BI/Analyze, BI/Analyze CubeCreator, BI/Broker, BI/Broker Admin,BI/Broker Repository, BI/Query, BI/Query Admin, BI/Query Reports, BI/Query Reports Chart Editor, BI/Query Update,BI/Query User, BI/Suite, BI/Web, BI/Web Personal Portfolio, Genio Designer, Genio Engine, Genio Met@Data Explorer, GeniMet@Data Studio, Genio MetaLink, Genio Repository, Genio Scheduler, and Genio Suite are trademarks of Hummingbird Ltd. anits subsidiaries.BI/Suite makes use of the Blowfish library, an SSL implementation written by Eric Young, © 1995–1997, Eric Young. All rights reser

Adobe, Acrobat, and Acrobat Reader are trademarks of Adobe Systems Incorporated.DB2 is a trademark, and OS/2 is a registered trademark, of International Business Machines Corporation.Hyperion Essbase OLAP Server is a trademark of Hyperion Solutions Corporation.Ingres/Net is a trademark of Computer Associates International, Inc. Java is a trademark of Sun Microsystems, Inc.MetaCube is a registered trademark of Informix Software, Inc.Microsoft, Microsoft Excel, Microsoft Word, Visual Basic, Windows, Windows 95, Windows 98, and Internet Explorer are registertrademarks, and Windows NT is a trademark, of Microsoft Corporation.NCR TeraCube and Teradata are registered trademarks, and WinCLI is a trademark, of NCR Corporation.Netscape, Navigator, and Communicator are trademarks of Netscape Communications Corporation.Oracle and SQL*Net are registered trademarks of Oracle Corporation.

Palm is a trademark of Palm, Inc. Quicksheet is a trademark of Cutting Edge Software, Inc.Photo clipart copyright © 1996 PhotoDisc, Inc.SequeLink is a trademark of Intersolv, Inc.Sybase is a registered trademark of Sybase, Inc.WhiteLight Server is a trademark of WhiteLight Systems, Inc.All other copyrights, trademarks, and tradenames are the property of their respective owners.

DISCLAIMER . Hummingbird software and documentation has been tested and reviewed. Nevertheless, Hummingbird Ltd. makewarranty or representation, either express or implied, with respect to the software and documentation included. In no event willHummingbird Ltd. be liable for direct, indirect, special, incidental, or consequential damages resulting from any defect in the softwadocumentation included with these products. In particular, Hummingbird Ltd. shall have no liability for any programs or data used these products, including the cost of recovering such programs or data.

Information in this document is subject to change without notice and does not represent a commitment on the part of HummingbiLtd. Not all copyrights pertain to all products.

This guide contains proprietary information that is protected by copyright. All rights are reserved. This guide may not be photocopreproduced, or translated into another language, in whole or in part, without prior written consent from Hummingbird.

This edition published October 2000. Available in PDF format only.

Printed in Canada.

Page 3: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 3/186

Contents

 Welcome to BI/Query 3

About This Guide 3

Conventions 3

Illustrations 4

Related Documentation 4

Guides 4

Online Help 5

Technical Support 5

Contacting Technical Support 6

Troubleshooting Using the Trace Utility 7

Professional Services 7

Contacting Professional Services 8

The Business Intelligence Product Line 8

Hummingbird Genio Suite 8

Hummingbird BI/Suite 9

Contacting Hummingbird Sales 12

Basic Concepts 15

Working with Data Models 15

Data Objects 15

Attributes 16

Relationships 16

Building Queries 17

Buttons 18

Turning Data into Reports 18

Getting Started 21

Installing BI/Query 21

Starting BI/Query

Finding the Administrator Layerin a Split Data Model

Connecting

Using a Default Connection File

Using Another Connection File

Entering Additional Information

Disconnecting

Building Queries

Selecting Attributes

Qualifying Queries

Using the Qualification Tree

Using the Data Values Icon

Reversing Qualifications

Applying Multiple Qualifications

Combining Qualifications

Restricting Qualifications with Operators Performing Calculations

Applying Functions to Attributes

Creating Attributes That Perform

Calculations

Ordering Query Results

Ordering Columns

Sorting Rows

Submitting Queries

Saving Queries

Loading Queries

Saving Results

Contents

Page 4: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 4/186

iv Contents

Formatting Data 71

 Entering Data 71

Default Format 71

Matching Display Formatting 71

Numbers 72

Dates 73

Invalid Entries 73

Converting Two-digit Years 73

Displaying Data 75

Formatting Numbers 76

Formatting Dates 77

Inserting and Deleting Characters 77

Substituting Values 78

Data Values Files, Prompts, andVariables 83

Data Values Files 83

Naming and Storing Data Values Files 85Creating Data Values Results Files 86

Creating Data Values Query Files 90

Using Data Values Files to Alias Data 93

Prompts 96

Naming and Storing Prompts 97

Creating Single Prompts 97

Group Prompts 98

Conditional Prompts 101

Importing Prompts 106

Variables 107

Creating Variables

Specifying Attributes and Operators

Including Functions

Including Variables

Including Prompts

Importing Variables from a File

Using Variables to Supply User Names

Building Advanced Queries

Qualifying One Attribute withAnother

Qualifying an Attribute with a

Subquery

Modifying the SQL

Modifying a Query for Selected

Results

Narrowing the Range of Results

Combining Queries

Appending One Results Set to Another

 Joining One Column to Another

 Editing Combined Queries

Using the Super Query window

Editing a Component Query

Editing an Operation

Correcting Errors

Creating Dynamic Relationships

Building Queries with a Circular Path

With a Correlation

Without a Correlation

Page 5: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 5/186

Content

Exporting Information 155

 Exporting Queries 155

 Exporting Results 156

Copying and Pasting Results 157

Saving Results to a File 157

Exporting Results to an Application 158

Preparing Results for Export 159

Specifying Results Options 159

Setting Export Options 161

 Exporting to Excel Using DDE 163

Common DDE Commands 163

Setting Export Options for Excel 164

Using Two Commands 164

Using the First Command only on Startup 165

Issuing Two Commands to Obtain

the Effect of Three 165

Combining Three Results Sets 166

Sending Current Results to Excel 167

Running a Macro That Calculates a

12-month Moving Total 168

 Export Results Using Mail 169

Index 171

Page 6: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 6/186

Page 7: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 7/186

 Welcome to BI/Query

About This Guide 3

Conventions 3Illustrations 4

Related Documentation 4

Guides 4

Online Help 5

Technical Support 5

Contacting Technical Support 6

Troubleshooting Using the Trace Utility 7

Professional Services 7

Contacting Professional Services 8

The Business Intelligence Product Line 8

Hummingbird Genio Suite 8

Hummingbird BI/Suite 9

Hummingbird BI/Broker 10

Hummingbird BI/Web 10

Hummingbird BI/Query 10

Hummingbird BI/Analyze 11

Contacting Hummingbird Sales 12

Page 8: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 8/186

Page 9: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 9/186

Welcome to BI/Query

 Welcome to BI/QueryHummingbird BI/Query is a query and reporting tool that allows you to

access, analyze, and present data stored in enterprise databases. When it’sinstalled with Hummingbird BI/Broker Repository, it also offers secure

scheduling and exchange of corporate data. Administrators use BI/Query

to create data models for querying. Business users query databases,

integrate data with other applications, and generate reports.

About This Guide

This guide describes how to use BI/Query to create and modify queries

in order to obtain information from corporate databases. It applies to

BI/Query Admin, BI/Query User, and BI/Query Update  for Windows

95, Windows 98, and Windows NT.

Conventions

This guide uses certain conventions to help you use it effectively.

This Is Used for This

 folder Directory, subdirectory, and folder .

italics New terms, file names, and information that you

type in the software.

Providing useful hints and suggestions.

Page 10: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 10/186

4 Welcome to BI/Query

Illustrations

The illustrations in this guide are based on fictitious data. Some

illustrations may look somewhat different than what you see on your

monitor. Nevertheless, their functionality is the same.

Related Documentation

For information about installing and using BI/Query as well as using

other Hummingbird applications, see the documentation outlined

below. (For information about these applications, see “Hummingbird

BI/Suite” on page 9.)

Guides

The following guides describe the features, functionality, and

applications of Hummingbird’s BI/Suite software.

Use This Guide To Do This

BI/Query

Installation Guide 

Determine system requirements and install

BI/Query and BI/Query Reports.

BI/Query

Data Models Guide 

Create and manage data models and updaterecords in the database.

BI/Query

Reports Guide 

Produce reports using BI/Query Reports

from data obtained using BI/Query.

BI/Broker

 Administrator’s Guide 

Configure and manage BI/Broker, and set

up the security, publishing, and scheduling

features it provides.

BI/Broker

Publishing and

Scheduling Guide 

Publish and secure data models, queries,

data sources, and reports in a common

repository using desktop applications. Also,

schedule queries, reports, and HyperCubes.

Electronic DocumentsAll guides are available

online as Adobe Acrobat

Portable Document For-

mat (PDF) files. If you

installed the documenta-

tion with the software, it’s

accessible from the Start

menu. It’s also available onthe installation CD-ROM.

To open a PDF file, you

need Acrobat Reader. It’s

provided on the installation

CD-ROM and is also

available at Adobe’s Web

site (http://www.adobe.com).

Using Acrobat 3.0 or later

allows you to take advan-

tage of its Find facility.

Page 11: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 11/186

Welcome to BI/Query

Online HelpOnline help provides step-by-step instructions for using a product. You

can access online help in a number of ways.

Technical Support

The administrator of this product in an organization should be the first

contact for technical support. (The administrator is most familiar with

the organization’s particular configuration.) If the problem isn’t

resolved, the next step depends on where the product was purchased.

BI/Analyze 

Tutorial 

Learn how to use BI/Analyze to discover

trends, patterns, and relationships in data.

BI/Analyze 

CubeCreator Guide 

Create and manage BI/Analyze multi-

dimensional data sources.

BI/Web User’s Guide  Learn how to use BI/Web to use data

models, queries, data sources, and reports in

 your Web browser. (Available in PDF

format only. See “Electronic Documents”

on page 4.)

To Do This Do This

Display contents Choose Help>Contents.

Locate specific information Choose Help>Search for Help On,

then specify what you’re looking for.

Get Help about using Help Choose Help>How to use Help.

Get Help for a dialog box Click the Help button in the dialog

box.

Use This Guide To Do This

Tool tips allow

 you to find infor-

mation about

menu commands

and toolbars. Position the

cursor over the item to dis-

play a brief description on the

status bar.

Page 12: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 12/186

6 Welcome to BI/Query

Contacting Technical Support

 You can report problems and suggest enhancements in BI/Suite

software by contacting Technical Support. Before we can investigate

 your problem, we need certain information from you. Thisinformation is outlined on our Web site on the Technical Support

page. You can use the form that’s provided, or you can provide the

information by phone or fax.

Worldwide Tel: +1-613-548-4355 (8:00 am - 8:00 pm ET)

Fax: +1-613-548-7616

E-mail: [email protected]

Web: www.hummingbird.com

FTP: ftp.hummingbird.com

Asia Pacific Tel: +1-613-548-4355

Fax: +1-613-548-7616

E-mail: [email protected]

Australia and

New Zealand

Tel: +61-2-9929-4999

Fax: +61-2-9956-6442

E-mail: [email protected]

Canada and

USA

Tel: 1-800-486-0095 (8:00 am - 8:00 pm ET)

Fax: 1-613-548-7616

E-mail: [email protected]

Deutschland Tel: +49-40-79-70-07-23 (09:00 bis 17:00 Uhr)

Fax: +49-40-79-70-07-10

E-mail: [email protected]

France Tél: +33-1-53-34-93-17 (09:00 à 18:00)

Fax: +33-1-53-34-93-05

E-mail: [email protected]

UK Tel: +44-118-902-9507

Fax: +44-118-978-9325

E-mail: [email protected]

Page 13: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 13/186

Welcome to BI/Query

Troubleshooting Using the Trace Utility

A trace utility is installed with this software to help us troubleshoot

problems that our customers are having. The trace utility simplifies

problem-solving by monitoring the activity of our products. If you’re having a problem with the software, Technical Support will ask

 you to run the trace utility, reproduce the problem you’re having, save

the trace information, and send them the resulting trace file. Technical

Support will step you through the process and provide additional

information if necessary.

When your problem involves a BI/Suite desktop application, you must

run the trace utility on the machine that’s exhibiting the problem.

To run the trace utility1 Double-click the trace.exe  file in Program Files\Hummingbird BI\

Utility.

2 Make sure tracing is enabled. (If it is, a check mark appears beside

the File>Tracing Enabled command.)

3 Make sure Corba tracing is disabled and Com tracing is enabled.

(Choose File>Preferences. In the Preferences dialog box, click the

Disable Corba Messages check box to disable Corba tracing. Make

sure the Disable Com Messages check box isn’t selected.)

4 Run a BI/Suite application. (In BI/Query, click the system icon

above the File menu, then choose Debug. In the Debug Control

Panel dialog box, choose Trace Utility (via Com) from the Trace

Output list, then click OK.)

5 Reproduce the problem.

Professional Services

Hummingbird supports its products by offering consulting and training

services worldwide. Working alongside your own technical and non-

technical staff, our Professional Services group can help you identify

areas where improved information management can enhance your

business performance. And we can supply the expertise you need to

bring these opportunities to fruition.

To make the trace

utility easy to use

and administer,

 you can run it on

only one machine at a time. If

 you try to open the utility on

another machine running

BI/Suite components, a mes-

sage box appears, stating the

name of the machine where

the utility is already running.

Page 14: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 14/186

8 Welcome to BI/Query

Hummingbird offers standard training to help users and administrators

become confident using our products. We also design courses that are

tailored to meet your organization’s specific needs. These courses can

take place at your workplace or at our own training centers.

Contacting Professional Services

To register, or for more information, pricing, and detailed course

outlines, contact Hummingbird Professional Services at:

The Business Intelligence Product Line

Hummingbird’s Business Intelligence product line offers an end-to-end

solution that encompasses the transformation of data from one source

to another as well as querying, reporting, and analysis of data.

Hummingbird Genio Suite

Hummingbird Genio Suite  is an information broker that allows

organizations to transform and exchange data from any existing data

source into any other decision support system (data warehouses or data

marts) or business application in your organization. With its modular

architecture, superior data transformation capabilities, change

management features, and data quality controls, Genio gives

organizations the control, flexibility, and efficiency they need to handle

complex transformations and ensure the quality, accuracy, and

timeliness of corporate information.

Voice +1-613-548-4355 ext. 1700

Fax +1-613-548-7801

E-mail [email protected]

Web www.hummingbird.com

Page 15: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 15/186

Welcome to BI/Query

Genio Suite includes the following components:

Hummingbird BI/Suite

Hummingbird BI/Suite  is a fully integrated, scalable business intelligence

solution that allows users to better understand their business by asking

questions about information in the corporate database, analyze the

answers for more effective decision-making, present that information in

reports, and distribute it in a variety of ways, including over the World

Wide Web.

Genio Engine A high-speed, multi-threaded broker-

based transformation engine.

Genio Designer A multi-user graphical development

environment for designing data

transformation and exchange processes.

Genio Repository An object-oriented, open repository

that can reside in any relational database

management system.

Genio Scheduler A sophisticated time- and event-based

scheduler.

Genio Met@DataStudio A design tool for creating customizedviews of metadata for business users.

Genio Met@Data

Explorer 

A metadata browser for business users.

Genio MetaLink A suite of connectivity bridges that

enables the extraction and

transformation of data and metadata

from enterprise resource planning

(ERP) applications and repositories such

as SAP.

Page 16: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 16/186

10 Welcome to BI/Query

Hummingbird BI/Broker 

Hummingbird BI/Broker  is the cornerstone of Hummingbird BI/Suite.

It’s an application server that provides shared services and a common

repository of information that users can access using Hummingbird BI

desktop applications, their Web browsers, or certain mobile computing

devices. BI/Broker manages security, scheduling, and distribution

services in a centrally managed client/server environment.

BI/Broker includes the following key components, which are fully

integrated with Hummingbird BI desktop applications:

Hummingbird BI/Web 

Hummingbird BI/Web uses the services of BI/Broker to provide query,

reporting, and Online Analytical Processing (OLAP) capability to Web

users without requiring the installation of any desktop software.

Hummingbird BI/Query 

Hummingbird BI/Query is an ad hoc query and reporting tool that

provides a comprehensive solution for accessing, analyzing, and

presenting data in a client/server environment. With its graphical

approach and intuitive interface, BI/Query gives users flexible access to

the data while maintaining organizational control.

BI/Broker Admin Manages the BI/Broker configuration.

BI/Broker

Repository

Provides the central storehouse of data

models, queries, results sets, reports, anddata sources.

User and Group

Manager 

Provides user, group, and role-based security.

Scheduler Schedules queries, reports, and HyperCubes

and distributes the results.

Page 17: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 17/186

Welcome to BI/Query 1

The BI/Query product line consists of four separate applications:

Hummingbird BI/Analyze 

Hummingbird BI/Analyze  is an Online Analytical Processing (OLAP)

tool that allows users to analyze information from various business

perspectives. Using BI/Analyze, users can drill up and down through

successive layers of detail to discover trends, patterns, and relationshipsin their data. BI/Analyze provides direct connections to a variety of

multidimensional data sources and supports the OLE DB for OLAP

standard. Using BI/Analyze CubeCreator , users can also create their own

multidimensional data sources from detailed, transactional data.

BI/Query Admin The advanced business user ’s administrative

tool. It allows users to create data models, use

them to query the corporate database, producereports, and update the database.

BI/Query User The business user  ’s ad hoc query tool. It

allows users to use a data model to query the

corporate database and produce reports.

BI/Query Update An extended version of BI/Query User. It

allows users with special access privileges to

add, modify, and delete information in

corporate databases.

BI/Query Reports A reporting tool installed with BI/Query.BI/Query Reports can present the data obtained

in BI/Query in tables, crosstabs, and charts.

Page 18: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 18/186

12 Welcome to BI/Query

Contacting Hummingbird Sales

Regional sales offices are located worldwide. For a current list of

contacts and phone numbers, contact Hummingbird Sales at:

Voice Canada and USA: 1-877-FLY HUMM (1-877-359-4866)

Worldwide: +1-416-496-2200

Fax +1-416-496-2207

E-mail [email protected]

Web www.hummingbird.com

Page 19: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 19/186

Basic Concepts

Working with Data Models 15

Data Objects 15Attributes 16

Relationships 16

Building Queries 17

Buttons 18

Turning Data into Reports 18

Page 20: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 20/186

Page 21: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 21/186

Basic Concepts 1

Basic ConceptsIn order to make informed business decisions, you need to turn the data

in your corporate database into information you can use. BI/Queryprovides you with an easy way to do that. It allows you to extract

exactly the information you need using queries based on a BI/Query

data model. You don’t need to learn SQL (Structured Query Language,

the language used for retrieving data from most databases).

 Working with Data Models

When you use BI/Query to get information from your database, you

work with a graphical representation of the data called a data model .

Data models may have one or more windows which contain data

objects and relationships.

A data model includes data objects and the relationships between them.

Data Objects

Data objects are rectangular or graphical icons that represent tables in the

database. Each data object includes categories of information found in

that table. For example, a Retailers data object might represent a table

that contains such categories as the retailer ’s name, city, country, and

credit limit. These information categories are called attributes.

Data object

Relationship

Page 22: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 22/186

16 Basic Concepts

Attributes

 You specify the categories of information you want from the database

by selecting attributes in a window that opens from the data object.

Relationships

The lines connecting the data objects indicate relationships among data

objects. Data objects connected by a relationship have at least one

category in common. For instance, the relationship between a

Regional Offices data object and a Staff data object might be that both

contain an “office name” category. Relationships may be shown with a

diamond icon and a name as well as a line.

Data objects can have more than one relationship, so that you can get

different information using the same data objects. In the example

below, you could use the works in relationship to find information

about an employee who works in a particular department; you could

also use the managed by relationship to find information about an

employee who manages a particular department.

Attributes represent categories of information to be retrieved from the database.

You can select the ones you want.

Data objects display attributes in an attribute window

If you want a data

model to display

diamond relation-

ship icons, choose

Tools>Preferences, then

select Show Relationships. If

 you want it to display rela-

tionship names as well, also

select Show Relationship

Names.

Page 23: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 23/186

Basic Concepts 1

Building Queries

In order to retrieve information using the data objects and relationships

in a data model, you must first frame a question, called a query.

To build a query, you need to know the kind of information you want.

For instance, do you want information about products sold or about

the people who sold the products? Are you trying to find out about

receivables or about credit limits? You also must decide what portion of

the available information you want. Do you want sales figures for this

 year only, or the last ten years, or just the current quarter? Do you want

receivables for all retailers, or just for those in, say, Japan?

Once you frame the question, you can begin to build the query. The

first step is selecting attribute s from at least one data object. For some

queries, that may be all you need to do. For most, however, you will

go on to qualify, or restrict, the query in various ways in order to see

 just the information that interests you.

Page 24: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 24/186

18 Basic Concepts

 You may also want to refine the query in other ways. Once you’ve

built it, you can submit it to the database or save it for later use.

Buttons

Data models may contain buttons to automate processes including

querying. You can create your own buttons to run queries. (See the

BI/Query Data Models Guide .)

Turning Data into Reports

Once you’ve gathered the data you want by querying, you may need to

present it in a report. BI/Query Reports provides a flexible reporting

environment that includes tables, crosstabs, charts, and maps to answer

every type of business question. BI/Query Reports is installed with

BI/Query. (For more information about this reporting tool, see the

BI/Query Reports user documentation.)

Qualified attributes filter

 the information

Selected attributes specify what to

retrieve from the database

Page 25: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 25/186

Getting Started

Installing BI/Query 21

Starting BI/Query 21Finding the Administrator Layer in a Split

Data Model 23

Connecting 24

Using a Default Connection File 25

Using Another Connection File 25

Entering Additional Information 26

Disconnecting 26

Page 26: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 26/186

Page 27: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 27/186

Getting Started 2

Getting StartedThis chapter describes how to start BI/Query, open a data model, and

connect to the DBMS.

Installing BI/Query

For installation instructions, see the BI/Query Installation Guide.

Starting BI/Query

BI/Query consists of three applications: User, Update, and Admin.

When you start BI/Query, the BI/Broker Login dialog box may

appear. This indicates that your corporate querying environment

includes a central storehouse for data models, queries, results, and

reports called the BI/Broker Repository. You can log in to use the

repository, or you can work offline.

If you log in, you can publish data models, queries, and reports to the

repository, set permissions on them, and retrieve them. You can also

schedule queries and reports. (For more information, see the BI/Broker

Publishing and Scheduling Guide .) If you work offline, you don’t have

access to the repository. It doesn’t affect your ability to connect to the

database; you can still submit queries and work with the results.

To start BI/Query

1 Choose Start>Programs>Hummingbird BI Suite>BI-Query User

(or BI-Query Update or BI-Query Admin).

2 If the BI/Broker Login dialog box appears, to log in to the

repository, type your user name and password. If the Domain text

box appears and is enabled, type your domain name into it. (If you’re unsure what information to provide in this dialog box, check

with your administrator.) Click OK.

OR

Page 28: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 28/186

22 Getting Started

To work without access to the repository, click Work Offline.

3 In the Welcome to BI/Query window, click the icon for the type

of data model you want to open. (The Repository Data Model

option is available only if you’ve logged in to the repository. The

New Data Model option is available only in BI/Query Admin.)

4 To open a data model you recently used, click Recent Data Model.

In the Recent Models dialog box, select the data model.

If you need to

publish, retrieve,

schedule, or set

permissions on

 your work, you can log in to

the repository at any time.Choose File>Work Online.

Page 29: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 29/186

Getting Started 2

5 To open a data model stored on your computer or local network,

click Local Data Model. In the Open Data Model dialog box, open

the data model. (If a message appears, stating that a newer version of

the data model exists either in the repository or in the database,

click Yes to open the newer version.)

6 To open a data model stored in the repository, click Repository

Data Model. In the Retrieve dialog box, locate the data model,

then click Retrieve. (If a message informs you that a newer version

of the data model exists in the database, click Yes to retrieve it.)

Finding the Administrator Layer in a Split

Data ModelA data model is either a split or a combined data model. A split data

model is stored as two files —  the administrator-layer file with the

extension . gqa and the user-layer file with the extension . gqu.

Page 30: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 30/186

24 Getting Started

No matter which BI/Query application you use, if you open a split

data model, it’s the user-layer file that opens. The user-layer file contains

a path to the administrator-layer file, which allows BI/Query to

combine the two layers. Having two layers allows users to make

customizations to individual versions of the model without changing

the core model.

However, if the administrator-layer file has been moved or renamed,

the link between it and the user-layer file will be broken. If that

happens, when you open a split data model, BI/Query can’t find the

administrator layer and displays a message. You need to locate the file,

then save the data model to save the link to the new location.

To find the administrator layer when it’s been moved or renamed

1 In the message box, click Find It.

2 In the Open Data Model dialog box, open the administrator-layer

file. (If you can’t locate it, contact your administrator.)

3 Choose File>Save.

Connecting

Before it queries the database, BI/Query must connect to the database

management system (DBMS). To do this, it uses a connection file that

contains information for that particular connection type. Typically, the

person who creates a data model includes at least one connection file

with it and sets it up to automatically connect to the DBMS each time

 you open it or each time you submit a query.

If you submit a query using a data model with an associated connection

file, BI/Query makes the connection. You can also connect yourself by

using a default connection file or by specifying another file.

If you can’t select

a button or orna-

ment in Design

Mode using

BI/Query User or BI/Query

Update, it’s because you’reusing a split data model and

the object is stored in the

administrator layer. Users can

select and modify only ele-

ments in the user layer. Any

item in a dialog box that has a

lock icon beside it was created

by the administrator and also

can’t be modified by the user.

Page 31: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 31/186

Getting Started 2

If the data model doesn’t have a connection file associated with it, you

need to see the person who created it for information on obtaining

one. (You can also create your own connection files. See the BI/Query

Data Models Guide .)

Using a Default Connection File

If the data model you’re using has a default connection file, connecting

is fast and easy.

To connect using a default connection file

1 Choose Host>Connect.

Using Another Connection File

If the data model you’re using doesn’t have a default connection file, or

if you don’t want to use the connection file assigned as the default, you

can specify another connection.

To connect using another connection file

1 Choose Host>Connections.

2 In the Connections dialog box, select a connection file from the

Connection Names list.

3 Click Connect.

Page 32: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 32/186

26 Getting Started

Entering Additional Information

If you need to supply any information that isn’t included in the

connection file, such as a password or user ID, you’re prompted for it

when you connect. If you’re unsure what information to supply, checkwith your administrator.

If you’ve been assigned the Cache Passwords permission, any additional

information that you supply is stored in memory until you close the

data model. (While the permission refers to passwords, it actually affects

all missing connection information.) If you use more than one

connection file for a data model, additional information is stored for

each connection file.

To enter connection information1 If the Enter Connection Information dialog box appears, type the

required information, then click OK.

Disconnecting

When you no longer need access to the DBMS, it’s good practice to

disconnect from it to reduce the load on the database server.

To disconnect from the DBMS

1 Choose Host>Disconnect.

Page 33: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 33/186

Building Queries

Selecting Attributes 30

Qualifying Queries 32Using the Qualification Tree 32

Qualification Text Box 33

List Icon 33

Data Values Icon 34

Operator List 34

Condition Box 35

Using the Data Values Icon 35

Data Values and Data Values Lists 35

Prompts 37

Variables 38

Reversing Qualifications 39

Applying Multiple Qualifications 40

Combining Qualifications 41

Restricting Qualifications with Operators 42

Making Comparisons 43

Matching Character Strings 44

Matching Items in a List 45

Finding a Range of Values 45

Finding Unknown Values 46

Applying Your Own Operator 46

Performing Calculations

Applying Functions to Attributes Specifying Functions

Specifying a Group Order

Grouping without Functions

Creating Attributes That Perform Calculations

Ordering Query Results

Ordering Columns

Sorting Rows

Attribute Window Sort Box

Sort Order Dialog Box

Submitting Queries

Saving Queries

Loading Queries

Saving Results

Page 34: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 34/186

Page 35: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 35/186

Building Queries 2

Building QueriesIn order to retrieve information from the database, you need to build

queries (sometimes called ad hoc queries) that ask the questions you wantanswered. To build a query, you choose categories of information and

then decide how much of the information you actually want to receive

in the results. You may want the query to perform calculations on the

data it retrieves before providing you with results. You may also want

to specify how rows are to be sorted and how columns are to be

ordered in the results.

 You build a query in the attribute window.

In the attribute window, you choose categories of information by selecting attributes.You restrict the amount of information by clicking in the Qualify column and entering

information into the qualification tree. You can also apply a function or a calculation of

your own and specify how results are to be grouped and sorted.

 You can uil

only one query ata time. To

remove the cur-

rent query and start a new

one, choose Query>New.

Even if you’ve submitted or

saved a query, it remains the

current query until you

remove it.

Group or sort results

Qualify with one or more data

values, a prompt, a variable,

another attribute, or a subquery

Apply a function toan attribute or

create your own

calculation.

Page 36: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 36/186

30 Building Queries

Once you’ve built the query you want, you can submit it to the DBMS

right away and save it for later use by yourself and others.

Selecting Attributes You specify the categories of information you want from the database

by selecting attributes in a data object. (See “Data Objects” on

page 15.) The selected attributes appear as column headings when your

query brings back the information. As soon as you select one attribute,

 you have built a query. It is up to you to decide how much more you

want your query to include.

For example, if you select the Name attribute in a Retailers data object

and then submit the query to the database, it brings back the names of

all the retailers in the database table, in a column labeled Name. If you

also select the City attribute in the same data object and submit the

query, it brings back the retailers’ names, in a column labeled Name,

and the city in which each is located, in another column labeled City.

 You can select as many attributes as you like in each data object. And

 you can select attributes from as many data objects as you like within

one data model window. (If your data model has data objects in more

than one window, you can build separate queries in each window, then

use one of several methods for combining them. See “Combining

Queries” on page 129.)

To select attributes

1 Open a data model.

2 Double-click a data object for which you want to retrieve

information.

Page 37: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 37/186

Building Queries 3

3 In the attribute window, click the attributes that represent the

categories of information you want to retrieve.

4 If an additional data object is connected by a relationship with the

first, you can select attributes for your query from that data object as

well.

5 If your query is complete, choose Query>Submit to submit it to

the database or save it for later submission (see “Saving Queries” on

page 64).

6 If you want to build a new query, choose Query>New.

Double-click a data object to view its attributes

Page 38: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 38/186

32 Building Queries

Qualifying Queries

In addition to using attributes to specify the categories of information

 you want from the database, you can use attributes to place limits on

the amount of information that you receive. The process of limiting theinformation this way is called qualifying the query.

It isn’t necessary to select an attribute in order to use it to qualify a

query. For instance, suppose that you want a list of retailers in France

and the city in which each operates. You select the Name and City

attributes. Since France is the only country you want to include in your

results, you won’t need a column labeled Country. So, although you

qualify the Country attribute to restrict it to France, you don’t select  the

Country attribute.

When you submit this query, it brings back from the database a list of

the names and cities of those retailers who operate in France.

Using the Qualification Tree

The qualification tree  displays the name of the attribute you’re qualifying

and provides the means of qualifying it. It includes the qualification text

box, the list icon, the data values icon, the operator list, and the

condition box.

Condition box

Operator

list

Qualification

 text box

Data values

icon

List

icon

Attribute

Page 39: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 39/186

Building Queries 3

Qualification Text Box 

 You can enter one or more items into the qualification text box to qualify

an attribute. For example, by qualifying the Country attribute with

France , Germany, and Spain, you can restrict the results to retailers

located in France, Germany, and Spain. You can type the values you

want. To enter more than one value by typing, press the Down Arrow

after each. Alternatively, click the list icon, then choose New Entry (see

“List Icon” on page 33). You can also select the values from a data

values list. (See “Data Values Icon” on page 34.)

 You can enter dates in a variety of formats (such as 1998/1/14,

1.14.1998, or  January 14, 1998 ) as long as BI/Query can

unambiguously determine the dates you enter. When in doubt, use the

default format specified in your Control Panel. (For more informationabout specifying date formats, see “Entering Data” on page 71.)

When you’ve finished entering a qualification in the qualification text

box, click outside the qualification tree. If you entered one value, it

appears in the qualification tree; if you entered more than one value,

the values are represented by the list icon.

Once you’ve entered a qualification, you can view and modify it by

clicking the value or the list icon.

List Icon 

 You can use the list  icon beside the qualification text box to add and

modify entries in a list of qualification values or to delete all entries.

Values that you enter in the qualification text box are displayed in a list

when you click the list icon. By clicking a value in the list, you can

display that value in the qualification text box. Alternatively, use the

If your database is

case-sensitive and

the Case-sensitive

Comparisonspreference is set, when you

type a qualification, the char-

acters must be in the case in

which they are stored in the

database. If this preference

isn’t set, case isn’t important.

List of valuesSingle value

Page 40: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 40/186

34 Building Queries

Up or Down arrow keys on your keyboard to display each value in the

qualification text box.

Data Values Icon 

The data values icon appears beside the list icon. It provides an easy

means of inserting one or more specific values (data values), prompts,

or variables into a qualification. Prompts prompt you for one or more

data values, while variables perform a user-defined operation. (See

“Using the Data Values Icon” on page 35.)

Operator List 

Use the operator list in the qualification tree to specify the type of

restriction you want. For example, you can apply the Greater Than (>)

operator to find all the records that have a value greater than the

qualification you specified. (See “Restricting Qualifications with

Operators” on page 42.)

List icon

Add a new value to the list

Remove all values from the list

Current list of values

Page 41: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 41/186

Building Queries 3

Condition Box 

The condition box appears above the attribute identified in the

qualification tree. If you specify multiple qualifications in a query, you

can use the condition box to combine them (see “Combining

Qualifications” on page 41) or give them the opposite meaning (see

“Reversing Qualifications” on page 39). You can also remove a

qualification from a query: click the condition box, then press Delete.

Using the Data Values Icon

 You’ll often want to restrict the results of your queries to one value

(such as “France”) or to some subset of the possible values (such as

“France, Spain, Portugal”). The data values icon in the qualification

tree allows you to do this in one of three ways, by specifying the data

value(s) directly or by means of a prompt  or a variable .

Data Values and Data Values Lists 

When you qualify an attribute with specific data values (such as

“France” or “Spain”), you can type the values into the qualification

Operator list

Page 42: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 42/186

36 Building Queries

text box or you can select them from a list using the Data Values icon

(or choosing Edit>Data Values). Selecting from a list of data values

avoids potential uncertainty about what values actually exist in the

database and about capitalization and spelling.

Unless the designer of the data model has disabled data values, clicking

the data values icon, then choosing Data Values, submits a default query

which retrieves all the unique values in the database for that attribute.

The values are displayed in the Data Values dialog box, where you can

select the one(s) you want to enter into a qualification.

If data values for an attribute haven’ t been disabled, clicking the data values icon and

choosing Data Values displays all the values for the attribute stored in the database.

Alternatively, users may choose to substitute data values lists for the

default data values query.

In this qualification tree, clicking the Data Values icon displays a l ist of values.

Page 43: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 43/186

Building Queries 3

If data values haven’t been disabled for an attribute, you can access all

the data values in the database instead of just those provided by the data

values list by choosing more  from the list, then clicking Load All in the

Data Values dialog box. (For more detailed information on creating and

using data values lists, see “Data Values Files” on page 83.)

To qualify an attribute with one or more data values

1 In an attribute window, click the Qualify box for an attribute.

2 With the cursor in the qualification text box, type the data value(s)

 you want to use (press the Down Arrow after each if typing more

than one). Or, click the data values icon and choose Data Values; in

the Data Values dialog box or data values list, select the values you

want, then click Insert.

3If your query is complete, choose Query>Submit to submit it tothe database or save it for later submission (see “Saving Queries” on

page 64).

Prompts 

If you create queries for reuse, whether by yourself or by others, you

may want to qualify an attribute with a prompt . A prompt will require

the person submitting the query to supply the appropriate value(s) at

the time the query is submitted. That way, the same query can retrieve

a different set of results each time. For instance, when you want toknow about retailers in France, you respond to the prompt with the

value “France” and when you want to know about retailers in Canada,

 you respond to the prompt with the value “Canada”. In the prompt

dialog box, you can type the name of a country or choose from a data

values list of countries (see “Data Values and Data Values Lists” on

page 35).

Page 44: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 44/186

38 Building Queries

 You can build a query with multiple prompts, allowing users of the

query to quickly zoom in on increasingly detailed information when

they submit the query. For more detailed information on creating and

using prompts, see “Prompts” on page 96.

To qualify an attribute with a prompt

1 In an attribute window, click the Qualify box for an attribute.

2 With the cursor in the qualification text box, click the data values

icon, then select Prompts from the list.

3 In the Prompts dialog box, select a prompt. (If the prompt you

want isn’t listed, you can create it. See “Creating Single Prompts” 

on page 97.)

4 Click Insert Prompt.

5 If your query is complete, choose Query>Submit to submit it to

the database or save it to submit later. (See “Saving Queries” on

page 64.)

Variables 

 You can also qualify a query with a variable  that silently performs anoperation you define and supplies the result as the qualification. For

instance, you might want a query to provide information for the

current date only. You can qualify the query with a variable that

When a query

prompts you for

one or more val-

ues, you can insert

them, or you can leave the

prompt blank. (Leaving itblank returns all of the possi-

ble values for the attribute.)

To view the query’s SQL, in

the attribute window, choose

Query>Show, then click

Show Prompt Values. If you

specified prompt values,

they’re displayed in the SQL.

If you didn’t, the prompt

qualification is removed from

the WHERE clause to reflect

the actual query that will besubmitted to the DBMS.

Page 45: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 45/186

Building Queries 3

determines the date at the time the query is being submitted and uses

that date to restrict the information that is returned from the database.

That way, there’s no need to prompt the person submitting the query

for today’s date. (For more detailed information on creating and using

variables, see “Variables” on page 107.)

To qualify a query with a variable

1 In an attribute window, click the Qualify box for an attribute.

2 With the cursor in the qualification text box, click the data values

icon, then select Variables from the list.

3 In the Variables dialog box, select a variable. (If the variable you

want isn’t listed, you can create it. See “Creating Variables” on

page 108.)

4 Click Insert Variable.

5 If the query is complete, choose Query>Submit to submit it to the

database or save it to submit later. (See “Saving Queries” on

page 64.)

Reversing Qualifications

When you want to exclude certain information from a query, or when

it’s easier to specify the information you don’t want rather than the

information you do (for example, all retailers except those in

Page 46: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 46/186

40 Building Queries

Germany), you can qualify the query to have the opposite meaning to

the condition specified.

To reverse a qualification

1 In an attribute window, click the condition box above aqualification.

2 Choose Query>Qualification>Negate Clause.

Applying Multiple Qualifications

When you qualify more than one attribute, or when you qualify the

same attribute more than once, you can specify whether the query must

satisfy both qualifications or either one.

To apply multiple qualifications

1 Qualify one or more attributes with one or more qualifications.

(Add a new qualification to an attribute you have already qualified

by clicking the Qualify box again.)

2 To have a query satisfy both qualifications, leave the word and  

between them in the qualification tree.

When you reversea qualification, the

word not  appears

in front of the

condition box. If you change

 your mind about the restric-

tion, click the word not  to

remove it.

Page 47: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 47/186

Building Queries 4

OR

To have the query satisfy either qualification, click the word and  tochange it to or .

Combining Qualifications

When you’ve specified two or more qualifications in a query, you can

combine them so that they take precedence over those that aren’t

combined. For example, the qualification Country = France and

Country = Germany and Credit Limit < 60,000 is ambiguous. It ’sunclear whether its purpose is to produce a) retailers located in France

or Germany, all with a credit limit of under $60,000, or b) retailers

located in Germany with a credit limit of under $60,000 plus retailers

located in France. To avoid ambiguity, you can combine this query to

read: (Country = France or Country = Germany) and Credit Limit <

60,000; the results will consist of all retailers located in France or

Germany, all  of whom have a credit limit of under $60,000.

Combining qualifications in this way is the equivalent of using brackets

in a mathematical expression —  for example, 2 x (3-1) —  to indicatethe part of the expression that should be calculated first.

Page 48: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 48/186

42 Building Queries

To combine qualifications

1 In an attribute window, select the condition boxes above the

qualifications you want to combine.

2 Choose Query>Qualification>Combine.

3 To change the condition from and  to or , click the word and .

Restricting Qualifications with Operators

When you qualify an attribute, BI/Query displays the = operator in the

qualification by default, then finds all the records in the database that

When a quali ica-

tion is combined,

 you can separate

it. Click the con-

dition box above it, then

choose Query>Qualifica-

tion>Uncombine.

Page 49: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 49/186

Building Queries 4

match the qualification(s) you specify. For example, by setting the

Country attribute equal to Spain, the results include only retailers

located in Spain.

Using the operator list in the qualification tree, you can apply otheroperators to restrict a qualification. Keep in mind that the >, >=, <,

and <= operators allow you to insert a single value when you submit

the query; the BETWEEN  and NOT  BETWEEN  operators require

two values (for an upper and lower range); the =, IN, NOT IN, and

<> operators allow you to insert one or more values.

Making Comparisons 

When you need to compare values to find, for example, those that are

larger or smaller, earlier or later in the alphabet, or equal to a value, you

can specify the value on which you want to base the comparison in the

qualification text box and apply the appropriate comparison operator.

While comparisons are typically applied to numbers, they can also be

applied to characters and dates. With characters and dates, < meansearlier in the alphabet or in chronological order; > means later.

Operator list

Page 50: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 50/186

44 Building Queries

Matching Character Strings 

 You may not be sure how an item is stored in the database, or you may

want to find records for which there is some kind of pattern. For

example, you may need information about a retailer and aren’t sure of

the spelling of the name but know that it begins with Cars. (Is it

Carson, Carsen, Carsin?) Similarly, you may need a list of retailers

whose postal code is 3011.

 You can specify the characters you want to match in the qualification

text box and apply the Begins with, Contains, or Ends with operator.

When you submit the query, BI/Query looks for all instances of values

that match the qualification you specified. You can also type the %  

symbol into the qualification text box to find a match for any string of

characters, regardless of where it falls.

The Does not begin with, Does not contain, and Does not end with operators

function in the same way as their counterparts but allow you to find

items that don’t contain the character string you specify. For example,

 you can use them to find retailers whose postal code isn’t 3011.

 You can apply these operators to character strings, not numbers or dates.

This Qualification Results in This

Credit Limit = 2,000 Credit limits exactly equal to 2,000.

Credit Limit != 2,000 All credit limits except those equal to2,000.

Credit Limit < 2,000 Credit limits less than 2,000.

Credit Limit <= 2,000 Credit limits less than or equal to 2,000.

Credit Limit > 2,000 Credit limits greater than 2,000.

Credit Limit >= 2,000 Credit limits greater than or equal to

2,000.

Page 51: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 51/186

Building Queries 4

Matching Items in a List 

When you qualify an attribute with a list, BI/Query automatically

applies the IN  operator to the list. The IN  operator allows you to find

all records that match any one item in the list. You can also find items

that don’t match those in a list.

Finding a Range of Values 

 You can qualify an attribute with a range of values to obtain results

within a particular range. The range is inclusive, retrieving the lower

value and the upper value as well as the values in between. To do so,

This Qualification Results in This

Retailer name Begins

with Sweet

Sweet  Indulgence, Sweet s to Go.

Retailer name Contains 

ist

Peppermint Twist , Dulces Irresist bles.

Zip/Postal code Ends

with 3011

F-3011, D-3011, DK-3011.

Retailer name does not  

begin with Sweet

All retailer names except those

beginning with Sweet .

Retailer name Does not

contain ist

All retailer names except those

containing ist.

Zip/Postal code Does not

end with 3011

All Zip and postal codes except those

ending with 3011.

This Qualification Results in This

Country IN  France,

Germany, Spain

France, Germany, and Spain.

Country NOT IN  

France, Germany, Spain

All countries except France, Germany,

and Spain.

Page 52: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 52/186

46 Building Queries

enter the values as a qualification list (see “List Icon” on page 33) and

apply the BETWEEN  operator. You can also find results that are

outside a particular range by applying NOT  BETWEEN . If you qualify a

character field, be sure you use the case in which the value is stored in the

database. 

Finding Unknown Values 

A NULL value occurs when no value has been entered into the

database. It doesn’t represent a zero or a character space but is instead a

placeholder for missing information. Because NULLs don’t match

anything, you can’t retrieve them using standard comparison

qualifications such as Greater Than or Less Than. To include or

exclude rows for which information hasn’t been recorded, apply the IS

NULL  or IS NOT NULL  operator to an attribute.

Applying Your Own Operator 

In addition to applying the standard SQL operators provided in

BI/Query, you can restrict a qualification using any other operator that

This Qualification Results in This

Credit Limit

BETWEEN  2,000 and

5,000

Credit limits between and including

2,000 and 5,000 (2,000, 2,456, 4,646,

5,000, and so on).

Credit Limit NOT

BETWEEN  2,000 and

5,000

Credit limits outside this range (100,

1,400, 5,001, 6,111, and so on).

This Qualification Results in This

Credit Limit IS NULL  Credit limits for which there is no value.

Credit Limit IS NOT

NULL 

Credit limits for which there is a value.

Page 53: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 53/186

Building Queries 4

 your DBMS  (database management system) supports. (For information

about the operators your DBMS supports, see the documentation for

 your DBMS.)

To apply your own operator

1 In an attribute window, select User defined  from the operator list in

the qualification tree.

2 In the Enter Text dialog box, specify an operator.

3 Click OK.

Performing Calculations

 You can use queries to perform basic calculations such as summing or

averaging results by applying a function to an attribute. You can also

carry out more sophisticated calculations by applying a user-defined

calculation to an attribute.

Applying Functions to Attributes

 Aggregate functions are mathematical operations that allow you to calculate

summary values from a set of values for an attribute. For example, you

can retrieve retailers’ total sales by applying the SUM function to the

Invoice Amount attribute. Different functions are available depending

on the attribute, DBMS, and data type you’re using.

When you apply an aggregate function to an attribute, BI/Query

automatically groups all the other attributes in the query in the order in

which you selected them. (If this order isn’t appropriate to your needs,

 you can change it. See “Specifying a Group Order ” on page 51.)

Page 54: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 54/186

48 Building Queries

Grouping organizes the data into sets and retrieves a summary value for

each set. All selected attributes to which functions haven’t been applied

are grouped to ensure that the results set doesn’t calculate a summary

value for individual members of the group. (To group attributes

without applying functions, see “Grouping without Functions” on

page 54.) The following example shows how grouping works with

aggregate functions.

Suppose the database contains the following data about retailer sales:

If you want to retrieve a list of retailers, cities, and total retailer sales,

 you might formulate a query in which you select the Name, City, and

Invoice Amount attributes (in that order) and apply the SUM function

to Invoice Amount. When you submit the query, the DBMS organizes

the data into groups (first by Name, then by City). Each row of results

in a group has identical values except the attribute to which the

function is applied.

The table below shows how the DBMS groups the data. The rows for

Billings, Toronto, represent one group, the row for Saddler, Toronto,represents another group, and so on.

Name City Invoice Amount

Sterling Ottawa $3000

Triteck Toronto $1000

Billings Toronto $3000

Sterling Ottawa $1000

Billings Toronto $4000

Saddler Toronto $5000

Triteck Ottawa $2000

Triteck Toronto $3000

Page 55: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 55/186

Building Queries 4

The DBMS then applies the sum to each group. For most DBMSs,

when the results are displayed, each group is organized alphabetically,

numerically, or chronologically. The table below shows how BI/Query

displays the results. Groups are organized first alphabetically by name,

then alphabetically by city for retailers with the same name (such as

Triteck) but located in different cities.

Name City Invoice Amount

Billings Toronto $3000

Billings Toronto $4000

Saddler Toronto $5000

Sterling Ottawa $1000

Sterling Ottawa $3000

Triteck Ottawa $2000

Triteck Toronto $1000

Triteck Toronto $3000

Name City SUM Invoice Amount

Billings Toronto $7000

Saddler Toronto $5000

Sterling Ottawa $4000

Triteck Ottawa $2000

Triteck Toronto $4000

Page 56: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 56/186

50 Building Queries

Specifying Functions 

 You can choose from a wide range of functions to calculate the results

 you want.

Apply This Function To Do This

none Leave the Function box blank.

AVERAGE Retrieve the average of all the non-null

values of an attribute or the average of

each group.

MAXIMUM Retrieve the maximum value of an

attribute in the results set or by group. (In

character data, this is the last value in the

list; for dates, it’s the most recent date, fornumbers, it’s the highest number.)

MINIMUM Retrieve the minimum value of an

attribute in the results set or by group.

(In character data, this is the first value

in the list; for dates, it’s the earliest date;

for numbers, it’s the lowest number.)

SUM Retrieve the sum of all the non-null

values of an attribute or the sum of each

group.

COUNT Retrieve the number of values that

aren’t NULL (missing) values of an

attribute or the number in each group.

AVERAGE DISTINCT Retrieve the average of all the values of

an attribute or the average of each

group, ignoring any duplicates.

SUM DISTINCT Retrieve the sum of all the values of an

attribute or the sum of each group,

ignoring any duplicates.

Page 57: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 57/186

Building Queries 5

To apply a function to an attribute

1 In an attribute window, click the attributes you want.

2 Click the Function box for an attribute, then select a function fromthe list.

3 To group the data in a different order than the order in which you

selected the attributes, click the Group box for the remaining

attributes. (The function is applied after the results are grouped.)

This query calculates the average of all retailer sales.

Specifying a Group Order 

Whenever you select more than one attribute for a query and then

either apply an aggregate function to at least one attribute or group at

least one attribute (see “Grouping without Functions” on page 54), the

COUNT DISTINCT Retrieve the number of values that

aren’t NULL (missing) values of an

attribute or the number in each group,ignoring any duplicates.

Calculation Add calculated attributes that perform

user-defined calculations in a query.

(See “Creating Attributes That Perform

Calculations” on page 55.)

Apply This Function To Do This

Page 58: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 58/186

52 Building Queries

remaining attributes must also be grouped. BI/Query automatically

groups attributes in the order in which you selected them. You can

change the group order by clicking the Group boxes in the attribute

window. For example, if you select the Name, City, and Invoice

Amount attributes (in that order), apply the SUM function to Invoice

Amount, and then run the query, BI/Query will group the Name

attribute first, then the City attribute. The results are grouped first by

Name of retailer.

If you click the Group box for City for the same query, a “1” appears

in the Group box to indicate that this attribute will be grouped first.

When you submit the query, it retrieves the names and cities of retailers

along with their total sales, as before, but now the total sales are

grouped first by city, then by retailer name.

If you look at the attribute window, you’ll see that “2” appears in the

Group box for the Name attribute and “3” in the Group box for the

Invoice Amount attribute. BI/Query has automatically grouped the

remaining attributes in the order in which you originally selected them.

When you group

attributes, you can

include a column

that counts the

number of rows in each

group. Choose Query>Modifiers>Count All.

Page 59: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 59/186

Building Queries 5

Grouping before Calculating a Function 

When you apply a function to an attribute, you can qualify the attribute

in the qualification tree in order to group results before calculating the

function. (See “Qualifying Queries” on page 32.) For example, inorder to retrieve retailers’ largest sales, you might include the Retailer

Name and Invoice Amount attributes, qualify Invoice Amount to be

greater than $50,000, and apply the SUM function to it.

When you submit this query, BI/Query eliminates the records that

don’t meet the criteria you specified, groups the results, and calculates

the sum for each group. That is, it finds all sales that are greater than

$50,000, groups them by retailer name, then sums them.

Grouping after Calculating a Function 

When you apply a function to an attribute, you can qualify the attribute

with a group qualification in order to group results after calculating the

function. The qualification is applied to the entire query, after all

aggregate functions have been calculated (including any calculated

attributes that are treated as aggregates) and the appropriate attributes

have been grouped. For example, instead of finding retailers’ largest

sales, you can find the largest retailers by summing all sales by retailer

first, then eliminating the sums that don’t meet your criteria. (For

information about calculated attributes, see “Creating Attributes ThatPerform Calculations” on page 55.)

To group results after calculating a function

1 In an attribute window, click the Function box for an attribute,

then select a function from the list.

2 Choose Query>Qualification>Group.

3 In the Group Qualification dialog box, under Columns, select the

column to which you want to apply the group qualification.

4 Click Move, then type the qualification into the available text box.

 WHERE ClauseWhen you group results

before calculating thefunction, the SQL for the

query contains a WHERE

clause.

HAVING ClauseWhen you group results

after calculating the func-

tion, the SQL for the

query contains a HAV-

ING clause.

Page 60: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 60/186

54 Building Queries

The SUM function for the Invoice Amount attribute is qualified with  >50000  to

retrieve a list of total sales greater than $50,000.

5 To include a prompt in the qualification, click Insert Prompt, thenuse the Insert Prompt dialog box to specify it. (For more

information about prompts, see “Prompts” on page 96.)

6 To include a variable in the qualification, click Insert Variable, then

use the Insert Variable dialog box to specify it. (For more

information about using variables in queries, see “Variables” on

page 107.)

7 To include the database name of another attribute to which the

qualification refers, click Insert DB Name, then use the Insert DB

Name dialog box to specify it.

8 Click OK.

Grouping without Functions 

Grouping is most often used with functions. But you can group

attributes without applying functions. In this case, grouping is similar to

using the Modifier>Distinct command to eliminate duplicates. It

divides a table into groups and returns one row for each group. For

example, a query in which the Country attribute is selected retrieves all

countries in the Retailers table.

This list displays the Count function,

all columns to which an aggregate

function has been applied, and any

calculated attributes that are

 treated as aggregates.

Page 61: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 61/186

Building Queries 5

If you group by Country, the results display one row for each group.

(Depending upon the DBMS, the results may be sorted alphabetically.

Creating Attributes That Perform Calculations

BI/Query allows you to add calculated  attributes to a data object. A

calculated attribute performs a user-defined calculation in a query. The

calculation can be based on more than one attribute from more than

one data object in a design window. For example, a data object might

include Unit Price and Unit Cost attributes that retrieve a product’s

market price and production cost, respectively. By creating a new

attribute that calculates Unit Price minus Unit Cost, you can determine

the profit made on each product. You can also apply a function (such as

an average) to an attribute in the calculation.

In a combined data model, users can edit or delete any calculatedattribute. In a split data model, users can edit or delete only calculated

attributes that they create, not those the administrator provides.

SQL for the Query Results

select retailers.country

from retailers

Canada

Canada

FranceAustralia

France

USA

USA

Canada

Australia

SQL for the Query Results

select retailers.country

from retailers group by

retailers.country

Australia

Canada

France

USA

If you’re using a

Teradata connec-tion via WinCLI

and you’re not

using ODBC, you need to

identify the type of data the

calculated attribute creates.

For all other connections, you

can either specify a data type

or use the default Automatic .

Page 62: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 62/186

56 Building Queries

To create an attribute that performs a calculation

1 In an attribute window, click the attributes you want.

2 Click the Function box for the attribute below which you want to

add the calculated attribute, then select Calculation from the list.

3 In the Edit Computed Attribute dialog box, type a name for the

attribute into the Name text box.

4 In the Expression text box, specify a calculation. (Type it in or use

the keypad. Add a space between each item.)

The Profit attribute calculates Unit Price minus Unit Cost to give profit per product.

5 To include an attribute in the expression, select the corresponding

data object from the Table/Attributes list, select an attribute, then

click Insert Attribute.

6 To ensure that the other attributes in the query are grouped when

the calculated attribute is used in a query, click Aggregate. (See“Applying Functions to Attributes” on page 47.)

7 To include a function in the expression, click Insert Function, then

use the Insert Function dialog box to specify a function.

 You can easily

edit and delete the

calculated

attributes you cre-ate. Click the Function box in

the attribute window, then

select Edit Calculation or

Delete Calculation from the

list.

The expression displays

 the database names of

 the attributes

Page 63: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 63/186

Building Queries 5

The Average Profit attribute calculates the average profit made on each product.

8 To specify a data type for the calculated attribute and whether it’s

numeric or character, click Data Type, then use the Choose Data

Type dialog box to specify the information.

9 In the Edit Computed Attribute dialog box, click OK.

Choosing a FunctionThe Insert Function dialog

box displays a list of built-

in functions. For certain

DBMSs, a list of scalar func-tions appears under Other

Functions. (A scalar func-

tion takes a predefined

number of parameters —  

usually one or two —  and

produces a value for each

result in turn. Aggregate

functions are often used

with a group by clause; sca-

lar functions aren’t.)

 You can use most scalarfunctions available in your

DBMS even if they don’t

appear under Other Func-

tions. Type the function

into the Expression text

box. (Check your DBMS

documentation for the

correct format.)

Page 64: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 64/186

58 Building Queries

Ordering Query Results

In addition to selecting attributes, qualifying the query, and using the

query to apply functions or your own calculations, you can group and

sort the information.

Ordering Columns

When the results of a query are returned, columns are displayed in the

order in which you selected the corresponding attributes in the

attribute window. For example, say that you select first the Name and

then the City attribute in a Retailers data object, then submit the

query. The results look like this:

 You can order the columns so that City comes first, then Name. The

results look like this:

 You can change the column order before you submit the query or after

 you have results. When you change the order before submitting the

query, the DBMS does the ordering. You place fewer demands on the

DBMS by changing the order in the results, since BI/Query does the

 You can e it any

operations that

 you perform on

query results

(including ordering columns

and sorting rows) from the

Super Query window. See

“Editing an Operation” on

page 139.

Page 65: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 65/186

Building Queries 5

reordering. However, if you change the column order in the results,

 you can’t save the query as a data values query file (see “Creating Data

Values Query Files” on page 90) and you can’t save the SQL for the

query as a text file (see “Saving Results to a File” on page 157.)

To order columns before submitting a query

1 In an attribute window, choose Query>Column Order.

2 In the Column Order dialog box, click a column under Ordered

Columns, then click First, Last, Up, or Down to establish the order

 you want.

3 Click OK.

To reorder columns after you have results

1 In a results window, choose Results>Reorder Columns.

2 In the Column Order dialog box, click a column under Visible

Columns, then click First, Last, Up, or Down to establish the order

 you want.

If many columns

are displayed

under Ordered

Columns, start by

clicking Unorder All to move

all the columns under Unor-

dered Columns. Click each

column, then click Move to

move it to Ordered Columns

in the order you want.

Page 66: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 66/186

60 Building Queries

3 Click OK.

Sorting Rows

When you submit a query, the rows of results are displayed as the

DBMS returns them from the database, unless you specify a different

way of sorting them. For example, suppose that you select the Name

and City attributes in a Retailers data object, then submit the query.

The first ten rows of results as they come back from the database look

like this:

If you sort the rows alphabetically by Name, the first ten rows look like

this:

Page 67: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 67/186

Building Queries 6

If you choose to sort the rows by City, the results look like this:

Rows are sorted in ascending alphabetical (A, B, C,...), numerical (1, 2,

3,...), or chronological (January 4, February 8, March 2,...) order, as

appropriate. They can also be sorted in descending (reverse) order.

Attribute Window Sort Box The quick way to sort attributes while building the query is to use the

Sort boxes in the attribute window. Query results will be sorted first by

the data returned for the attribute with 1 in its Sort box, then by the

data returned for the attribute with 2 in its Sort box, and so on.

For example, suppose that you select the Name and Credit Limit

attributes in a Retailers data object, then click the Sort boxes for Credit

Limit and Name, in that order. When you submit the query, the results

are sorted numerically by credit limit first, then alphabetically by name.

Page 68: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 68/186

62 Building Queries

 You can sort attributes from more than one attribute window or in

reverse order; you can also sort the results after you’ve submitted the

query. (See “Sort Order Dialog Box” on page 63.)

To specify a sort order in an attribute window

1 In an attribute window, click the attributes by which you want tosort.

2 Click the Sort box for each attribute in the order you want to sort

by it.

The number 1 in the Sort box for Credit Limit indicates that the rows will be sorted by

credit limit first; the number 2  in the Sort box for Name indicates that the rows will be

sorted by Name second.

Page 69: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 69/186

Building Queries 6

Sort Order Dialog Box 

Using the Sort Order dialog box, you can specify a sort order before

 you submit the query or after you have results. When you specify the

sort order before submitting the query, the DBMS does the sorting.

 You place fewer demands on the DBMS by specifying the sort order in

the results, since BI/Query sorts the results. However, if you specify

the sort order in the results, you can’t save the query as a data values

query file (see “Creating Data Values Query Files” on page 90) and you

can’t save the SQL for the query as a text file (see “Saving Results to a

File” on page 157.)

To specify a sort order in the Sort Order dialog box

1 In an attribute window, click the attributes you want, then choose

Query>Sort Order. Or, in a results window, chooseResults>Filter>Sort.

2 In the Sort Order dialog box, under Selected Columns, select those

 you want to sort by, then click Move.

Sorting first in reverse (descending) numerical order by credit limit, then

alphabetically by retailer name.

3 To determine the order, under Sort Order, select columns and click

First, Last, Up, or Down.

4 To specify reverse order, click the column, then click Descending.

5 Click OK.

For a ast way o

displaying the SortOrder dialog box

from an attribute

window, double-click the

Sort box for an attribute.

Page 70: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 70/186

64 Building Queries

Submitting Queries

Once you’ve built a query, you can submit it to the database. The

results of the query are displayed in a separate window.

 You can build your entire query and then submit it. Or you can specify

some initial qualifications, submit the query, review the results, and

then revise the query to retrieve exactly the set of results you want.

To submit a query to the database

1 Choose Query>Submit Query.

OR

Click the green light icon on the application toolbar.

Saving Queries

It’s good practice to save any query that you want to use more than

once so that you don’t have to rebuild it each time. Once a query is

saved, it can be:

• loaded, then submitted

Page 71: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 71/186

Building Queries 6

• automated by being linked to a button

• stored with the data model in the database

To save queries, you must have the Save Queries permission. You can

save a query to make it available in BI/Query. You can also save thecorresponding SQL string to make it available to other applications (see

“Exporting Queries” on page 155), provided that your query doesn’t

require manipulation of the results set (see “Ordering Query Results” 

on page 58 and “Combining Queries” on page 129).

Saving a query in a results window saves the query that generated the

results. Saving in any other window saves the current query.

BI/Query saves queries with the extension .qry and stores them in the

Queries folder by default, but you can also store them elsewhere. Data

values queries are saved in the DataVals folder. (See “Creating Data

Values Query Files” on page 90.)

If the Query>Publish command is enabled and you have the

appropriate permissions, you can also publish queries to the repository

and retrieve them. Publishing queries to the repository gives you the

ability to schedule and secure them and provides an efficient way to

share your queries with others. See the BI/Broker Publishing and

Scheduling Guide for more information.

To save a query

1 Make sure you have the Save Queries permission.

2 Build a query. (You can submit the query before or after saving it.)

3 Choose Query>Save.

4 In the Save Query dialog box, specify a file name.

Page 72: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 72/186

66 Building Queries

5 To save the query in a location other than the Queries folder, click

Export and specify the name and location of the file.

6 Click Save.

Loading Queries

 You can load and submit queries that you’ve saved as well as queries

that have been stored with the data model.

To load and submit a saved query

1 With a data model open, choose Query>Load.

2 In the Load Query dialog box, select a query from the list of Saved

Queries.

Page 73: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 73/186

Building Queries 6

3 To submit the query without first displaying it, click Submit.

ORTo display the query, click Load.

Saving Results

 You can save query results to a file in order to use them again in

BI/Query or to use them in other applications, such as word processors

and spreadsheet programs.

BI/Query saves results as two separate files with the extensions .qrd  and

.qrr. The .qrd  file contains the results stored in text format so that other

applications can open them. (BI/Query automatically supplies the .qrd  

extension when you save results.) The .qrr  file stores additional

Page 74: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 74/186

68 Building Queries

information that BI/Query needs to open the results file (such as

formats for each column and the SQL used to retrieve the results).

When you load results in BI/Query, you see only the .qrd  file. If you

need to delete a results file, delete both the .qrd  and .qrr  files.

The results are stored on your computer so that you can manipulate

them locally instead of in the database, thereby reducing the demands

on the server.

To save results

1 In the results window, choose Results>Save As>Results.

OR

To submit results directly to a file, choose Query>Submit

Query...>To File.

2 In the Save Query Result to File dialog box, specify the name and

location of the file, then click Save.

Page 75: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 75/186

Formatting Data

 Entering Data 71

Default Format 71Matching Display Formatting 71

Numbers 72

Dates 73

Invalid Entries 73

Converting Two-digit Years 73

Choosing a Date Range 74

Choosing a Date Range Type 74

Displaying Data 75

Formatting Numbers 76

Formatting Dates 77

Inserting and Deleting Characters 77

Substituting Values 78

Page 76: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 76/186

Page 77: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 77/186

Formatting Data 7

Formatting DataData formats govern how you enter numbers, dates, and text characters

and how these are displayed in query results. For example, numbers canbe represented as 99999 , 99,9999 , and 99.999 , and dates can be

represented as 1/14/1998 , 1998.1.14, and January 14, 1998 . BI/Query

lets you specify different formats for different purposes.

The Control Panel settings on your computer determine the default

data-entry and display formats. You can change the default display

format for each attribute in a query that you build. For results windows,

the display formats specified in BI/Query take precedence over the

default database formats and Control Panel settings. You can then make

the data-entry format match the new display formats you’ve set.

Entering Data

The format in which you type dates and numbers in query

qualifications, prompts, and variables is the data-entry format .

Default FormatThe default data-entry format is normally based on the Control Panel

settings on your computer. Any changes you make to these settings

take effect immediately.

To specify the default data-entry format

1 In Regional Settings in the Control Panel, specify a format.

Matching Display Formatting

Instead of using the default, you can set the data-entry format to match

the format that’s used to display query results. (For information on how

 you can set the results display format, see “Displaying Data” on

 You specify data

formats for reportsin BI/Query

Reports. (See the

BI/Query Reports Guide .)

When you set the

data-entry format

to match the

results display for-

mat, it applies to all attributes

for which you’ve specified a

display format. To use thedefault format for an attribute,

set its format to the default.

(See “Displaying Data” on

page 75.)

Page 78: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 78/186

72 Formatting Data

page 75.) Using the results display format rather than the default data-

entry format is useful when you want to display an integer (such as

2017434411) as a phone number (201-743-4411) or when a currency

is specified as a number and you want the data to appear with the

currency symbol. (You can’t change the data-entry format for character

data types.)

Avoid using an attribute format for numbers and dates that “hides” 

information. For example, with a format such as MMM/D , if you type

Sept 15, 2001 into a qualification, BI/Query inserts Sept 15, 2001 into

the SQL for the query, but displays Sep 15  in the qualification tree. If

 you change the value to Sept 25 , BI/Query interprets your change as

being a complete value (Sep 25 , not Sept 25, 2001). The “hidden” year

is lost, and the query retrieves unnecessary or incorrect data.

BI/Query hides the year when the attribute uses a “hidden” format.

BI/Query is flexible in recognizing the data you type. You can use the

format specified in the Control Panel or a comparable one. If

BI/Query is able to interpret the format, it automatically converts it to

the default data-entry format.

To specify a data-entry format that matches the attribute format

1 Choose Tools>Preferences.

2 In the Preferences dialog box, click Attribute under Qualification

Format.

3 Click OK.

Numbers

 You can type numbers (including currencies) without formatting them.

BI/Query converts them to the format you’ve specified.

Page 79: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 79/186

Formatting Data 7

Dates

 You can type dates using any format comparable to the one you’ve

specified. For example, if the date format you’ve specified is

1/14/2001, you can type dates in the format 2001.1.14, 1.14.2001,

 January 14, 2001, or even 2001 Jan 14. As long as you include the day,

month, and  year and BI/Query is able to unambiguously interpret the

format, it converts the date to the specified format.

Invalid Entries

BI/Query alerts you when you type data in a format it can’t interpret.

To return to the entry and correct it, click Cancel in the alert window.

(If you’re not sure what format to use, check the Regional Settings in

 your Control Panel.) If you want BI/Query to accept the entry you

typed, click Add { }; your entry appears within the brackets. When

 you submit a query, BI/Query enters the entry as straight text into theSQL string. This is an escape mechanism designed for users with

advanced knowledge of SQL database access.

Converting Two-digit YearsWhen you type a two-digit year or import a data source that contains

two-digit years, BI/Query converts them to four-digit years.

To ensure that

BI/Query inter-

prets dates cor-

rectly, make sure

that you type dates using all

four digits of the year.

Page 80: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 80/186

74 Formatting Data

Choosing a Date Range 

To enable BI/Query to convert two-digit years correctly, you must

first specify the start day for a 99-year range of dates in your data. For

instance, if you know that you won’t need to enter dates earlier than

1930, you can specify a range that begins with 1930. BI/Query

automatically ends the range with 2029. For this range, whenever you

enter or import a two-digit number greater than or equal to 30 (from

30 to 99), BI/Query converts it to a four-digit number that begins with

19. For instance, when you type 45, it’s converted to 1945. Whenever

 you enter or import a two-digit number less than or equal to 29 (from

00 to 29), BI/Query converts it to a four-digit number that begins with

20. For instance, when you type 15 , it’s converted to 2015 .

Choosing a Date Range Type 

Once you’ve selected a range, then you need to establish whether it’s a

sliding  or fixed  range.

The start and end years of a sliding range are incremented by one each

time the current year changes. For example, a range of 1930 to 2029

chosen in the year 1999 becomes, in the year 2000, a range of 1931 to

2030. If in the year 2000 you will no longer need to enter the two-digit

 year 30 as 1930 and will want instead to enter it as 2030, you can usethe sliding range.

The start and end years of fixed ranges don’t change. If, for example,

 you choose a range of 1930 to 2029 as a fixed range, BI/Query will

always accept the two-digit year 30 as 1930 and the two-digit year 29

as 2029, no matter in what year you enter them.

The type of date range you specify in one product applies to all

Hummingbird Business Intelligence products.

To convert two-digit years

1 Choose Tools>Date Entry.

2 In the Date Entry dialog box, type a start year for the date window.

If you change the

date window after

typing two-digit

 years, the newdate window doesn’t apply to

the dates you’ve already

entered.

Page 81: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 81/186

Formatting Data 7

3 Click Sliding or Fixed.

4 Click OK.

Displaying Data

When results are returned from the database, the format in which

they’re displayed (the display format ) may not be how you want them

represented in the results window. BI/Query offers a wide range of

display formats for formatting columns of data. You can change the

default display format for each attribute in an attribute window, and

save those changes if you have permission to save the data model. (For

information on saving a data model, see the BI/Query Data Models

Guide .) Or, after results are returned, you can specify a display format

from the results window. If you save the results set, the formats you

specify in the results window are saved with it.

 You may need to change the display format for a particular set of

results. Whether you select a single cell or an entire column, the

formatting is applied to all the results in the column.

To specify a display format

1 In an attribute window, click the question mark beside an attribute.

In the Attribute dialog box, click Edit.

OR

In a results window, select one or more cells or column headings,

then choose Results>Format.

2 In the Specify Display Format dialog box, specify a format. (For

instructions, see the sections below.)

To view an

attribute’s default

display format,

click the question

mark beside the attribute in

the attribute window.

Page 82: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 82/186

76 Formatting Data

3 Click OK.

Formatting Numbers

 You can select from a number of predefined formats for numeric data.

 You can also modify one of these formats by including, for example, a

dollar sign or percent symbol as a prefix or suffix. You can also

highlight negative values in red, hide zero values, and display values in

exponent notation.

To format numbers

1 In the Specify Display Format dialog box, click Numeric.

2 Select a format from the Predefined Formats list.

3 To modify the format, use the available text and check boxes.

4 Click OK.

Page 83: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 83/186

Formatting Data 7

Formatting Dates

 You can select from a number of predefined formats for dates, and you

can include the time.

To format dates

1 In the Specify Display Format dialog box, click Date.

2 Select a format from the Predefined Formats list.

3 To include the time, click Show Time.

4 Click OK.

Inserting and Deleting Characters

By inserting and deleting characters in character, number, and date

strings, you can adjust data formats to include punctuation, include

missing information, and exclude unwanted information. BI/Query

recognizes special characters that tell it to include or exclude characters

in the original data. For example, you can specify that telephone

numbers stored in the database in the format 6135484355x15  be

displayed as (613) 548-4355 Ext. #15 by typing them in the format

(###) ###-#### Ext. \#*.

To insert and delete characters1 In the Specify Display Format dialog box, click String.

Page 84: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 84/186

78 Formatting Data

2 Type a format into the Format String text box using the following

special characters:

# inserts a character from the original data

 _ suppresses a character in the original data

* inserts the remaining characters in the original data

\ inserts the next character(s) you type; use it to include one of the

special characters (for example, to insert the # character, type \# )

3 Click OK.

Substituting Values

 You can substitute values in a results column to highlight trends, focus

on general information rather than specific details, and flag exceptions.

For example, it may be useful to assign a single value (the word

Unsatisfactory) to a range of values (all sales below a certain amount) so

that you can easily identify areas that require further attention. You can

also apply a color for emphasis in any corresponding reports. (The color

is displayed only in standard reports, not reports created using

BI/Query Reports.)

To substitute values in results

1 In the Specify Display Format dialog box, click Computed String.

Page 85: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 85/186

Formatting Data 7

2 Select an operator from the list beside the Comparison Value text

box.

3 Type the value you want to replace into the Comparison Value text

box.

4 To change the value, type a new value into the correspondingReplacement Value text box.

5 To specify more than five sets of values, use the scroll bar to display

more blank rows.

6 To specify a color for the new value in the corresponding standard

report, click the color button and specify a color.

7 Click OK.

To insert a row,

place the cursor in

the row below

which you want

to insert the row, then click

Insert Row. To delete a row you’ve specified, choose the

first (blank) item from that

row’s operator list.

Page 86: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 86/186

Page 87: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 87/186

Data Values Files, Prompts, and Variable

Data Values Files 83

Naming and Storing Data Values Files 85Creating Data Values Results Files 86

In BI/Query 87

Using a Text Editor or Spreadsheet Program 89

Creating Data Values Query Files 90

Using Data Values Files to Alias Data 93

Prompts 96

Naming and Storing Prompts 97

Creating Single Prompts 97

Group Prompts 98

Creating the Prompts 99

Creating the Title 100

Testing the Prompt 100

Conditional Prompts 101

Creating the Group Prompt 102

Creating the Data Values Query File 103

Testing the Conditional Prompt 104

Importing Prompts 106

Variables 107

Creating Variables 108

Specifying Attributes and Operators

Naming the Attribute and Operator Using Placeholders

Including Functions

Including Variables

Including Prompts

Importing Variables from a File

Using Variables to Supply User Names

Page 88: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 88/186

Page 89: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 89/186

Data Values Files, Prompts, and Variables 8

Data Values Files,Prompts, and VariablesOne of the goals of building a query is that it will limit what it retrieves

from the database to the information that interests you. One way to

limit what it retrieves is by qualifying attributes with data values. (See

“Qualifying Queries” on page 32.) You can supply data values to

accomplish that goal in any of the following ways.

Before you submit the query, you can insert one or more data values

into a qualification, either by typing them or by choosing them from a

list. Lists of data values are provided by data values files.

 You can also build a query that you qualify using one or more prompts,

and then save the query for later use. Whenever you submit such a

query, you’re prompted to insert the data values to be used in the

qualification. Depending on what values you choose to insert when

prompted, the same query can be used to retrieve different subsets of

data. You can type data values in response to a prompt, but prompts

can also have data values lists associated with them. And you can

combine data values files and prompts so that you can insert values into

one prompt that are based on values you inserted into another.

 You can also build a query that you qualify using variables and then save

the query for later use. Whenever you submit such a query, the variable

runs automatically, performs pre-defined operations, and supplies the

resulting data value(s) for the qualification. You can include prompts in

variables and you can include one variable in another.

Data Values Files

Data values files are lists of data values from you can use to restrict

query results. Selecting data values from a list is a more accurate and

Page 90: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 90/186

84 Data Values Files, Prompts, and Variables

efficient way to insert values than typing them. (See “Data Values and

Data Values Lists” on page 35.)

There are two kinds of data values files. Data values query files query the

database and retrieve a subset of values to create the list; data valuesresults files display a stored set of values. Data values query files provide

the most accurate lists; the first time you use them in a session, they

query the database to supply the values. Data values results files are

produced by storing the results of a query or, sometimes, produced

manually. BI/Query doesn’t update the lists corresponding to them.

Results files reduce the load on the database server because they

eliminate the need to query the database.

A data values file contains a subset of all of the possible values in the

database. These values appear as a list when you click the Data Valuesicon (see “Data Values Icon” on page 34). If no data values file is

available for a particular attribute, when you click the Data Values icon

and choose Data Values, BI/Query runs the default query and retrieves

all of the values.

The administrator, however, can disable access to the default query.

The Data Values dialog box displays no values when the administrator has disabled the

default data values query.

Disabling it is recommended when loading all the values in the database

uses network resources inefficiently —  for example, when an attributehas a large number of values or when those values are simply numbers

and dates. (For more information, see the BI/Query Data Models Guide .

Page 91: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 91/186

Data Values Files, Prompts, and Variables 8

For information on qualifying an attribute with data values, see “Data

Values and Data Values Lists” on page 35.)

How data values files are named determines which file BI/Query uses

and whether it’s used in a qualification or a prompt.

Naming and Storing Data Values Files

Data values query and results files require special naming conventions.

When they supply values to be used in a prompt, they use the prompt

name. (See “Naming and Storing Prompts” on page 97) When they’re

used in both qualifications and prompts, they use the format data object

name.attribute name where data object name and attribute name are the names

used in the data model (not the names of the table and column in thedatabase). For instance, for a data object called Retailers with an

attribute called country, a data values file would be called

Retailers.country. Be sure to use the case used in the attribute or prompt

name.

Data values query and results files are stored in the DataVals folder. The

file names you give these files determine the order in which BI/Query

selects the files in the DataVals folder as well as whether the

corresponding data values are available in a qualification or in a prompt.

The following table shows the order in which BI/Query uses datavalues files, their names, and where they’re used.

Data Values File Descriptive Name Available In

Results file named after the

corresponding prompt

prompt name Prompt dialog

box

Query file named after the

corresponding prompt

prompt name Prompt dialog

box

Page 92: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 92/186

86 Data Values Files, Prompts, and Variables

If none of these data values files is found, BI/Query uses a default query to supply the

data values in the database (unless the administrator has disabled the default query).

When you click the data values icon in a prompt dialog box in order to

display a list of data values that can be used in the prompt, BI/Query

checks to see if there’s a data values file with the same name as theprompt. If there is, BI/Query uses it; otherwise, it checks to see if there

is a data values file named after the data object and attribute used in the

query. If there is, BI/Query uses it.

If BI/Query doesn’t find a data values file, and if data values for an

attribute haven’t been disabled, BI/Query runs a default query that

retrieves all the unique values in the database for the attribute and

displays the results in a list.

Creating Data Values Results Files

A data values results file stores a set of data values for an attribute. It

allows you to access a data values list without querying the database

each time you need it. A data values results file can be linked to a

prompt or an attribute so that its contents are available in a data values

list in a qualification tree or in a prompt dialog box. When you click

the data values icon, the values stored in the results file are displayed.

Results file named after the

data object and attribute

used in the query

data object

name.attribute

name

Qualification

tree, prompt

dialog box

Query file named after the

data object and attribute

used in the query

data object

name.attribute

name

Qualification

tree, prompt

dialog box

Data Values File Descriptive Name Available In

Page 93: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 93/186

Data Values Files, Prompts, and Variables 8

If data values haven’t been disabled for an attribute, you can access all

the data values in the database instead of just those in the data values

results file. Select more  from the data values list, then in the Data Valuesdialog box, click Load All.

 You can create a data values results file from results you’ve retrieved in

BI/Query as well as by using a text editor or spreadsheet program.

In BI/Query 

When you create a data values results file in BI/Query, be sure to

eliminate duplicate values from your results. You can select the

attribute to retrieve all of the values in the database for your results file,

or you can qualify the attribute to retrieve only specific values.

Qualification tree

Qualification prompt dialog box

Creating ata val-

ues results files is

useful when the

data changes

infrequently. If a file needs to

be updated often, create a data

values query file instead. (See

“Creating Data Values Query

Files” on page 90.)

Page 94: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 94/186

88 Data Values Files, Prompts, and Variables

This query returns a list of cities in the state of New York, sorted alphabetically.

To create a data values results file in BI/Query

1 In an attribute window, click an attribute. (You can select only one

attribute for a data values results file.)

2 To sort the results, click the Sort box, if you want to sort the results,

then apply any other restrictions you want.

3 Choose Query>Modifiers>Distinct to eliminate duplicate values.

4 Submit the query.5 In the results window, choose Results>Save As>Data Values.

6 In the Data Values dialog box, name the file. (See “Naming and

Storing Data Values Files” on page 85.)

Page 95: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 95/186

Data Values Files, Prompts, and Variables 8

7 Click Save.

Using a Text Editor or Spreadsheet Program 

 You can use any text editor or spreadsheet program to create a data

values results file that contains a set of customized data values. To do so,

create a data values results file first; it will serve as a template for the

customized data values. This is necessary because BI/Query stores data

values results files in two separate files: the .qrd  file, which stores results

in text format, and the .qrr  file, which stores additional information that

the application needs to read the text file. Without the .qrr  file,

BI/Query can’t open the .qrd  file. Once you create these files, you’ll

replace the data values in the .qrd  file with the customized data values.

When you type values into the text editor or spreadsheet program, type

them in the order and case you want them to appear in BI/Query,

pressing Enter after each value.

To create a data values results file using a text editor

1 In an attribute window, click an attribute. (You can select only one

attribute for a data values results file.)

2 To sort the results, click the Sort box, then apply any otherrestrictions you want.

3 Choose Query>Modifiers>Distinct to eliminate duplicate values.

4 Choose Query>Submit to submit the query.

Page 96: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 96/186

90 Data Values Files, Prompts, and Variables

5 In the results window, choose Results>Options.

6 Under Separators in the Results Options dialog box, specify <CR> 

in the Record text box and <None> in the End of File text box.

7 Click OK.8 In the results window, choose Results>Save As>Data Values.

9 In the Data Values dialog box, name the file. (See “Naming and

Storing Data Values Files” on page 85.)

10 Click OK.

11 In a text editor or spreadsheet program, open the .qrd file you

created, modify it, and save it under the same name.

Or, type a list of values in a new document file, pressing Enter after

each one, then save the file using the same path and file name as the 

.qrd  file.

12 To test the file in BI/Query, click the attribute used to create the

original results, click its Qualify box, then click the data values icon

in the qualification tree.

Creating Data Values Query Files

A data values query is a query that BI/Query submits when you click

the Data Values icon and select Data Values. The data values query

retrieves data values for an attribute from the database. Then it displays

them in the Data Values dialog box so that you can select those you

want to insert into a prompt or qualification.

Page 97: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 97/186

Data Values Files, Prompts, and Variables 9

A data values query file can be linked to a prompt or an attribute so that

the query results are available in a data values list in a qualification tree

or in a qualification prompt dialog box.

If data values haven’t been disabled for an attribute, you can access all

the data values in the database instead of just those returned by the data

values query by clicking Load All.

 Just as with data values results files, when you create a data values query

file, you’ll want to eliminate duplicate values from your results. Youcan select just the attribute, in order to retrieve all of the values in the

database for that attribute, or you can qualify the attribute to retrieve

only specific values.

Queries that

require BI/Query

to manipulate the

results can’t be

used as data values query files.

(See “Ordering QueryResults” on page 58, “Nar-

rowing the Range of Results” 

on page 128, and “Combin-

ing Queries” on page 129.)

Qualification tree

Qualification prompt

dialog box

Page 98: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 98/186

92 Data Values Files, Prompts, and Variables

This query returns a list of staff tit les, sorted alphabetically.

To create a data values query file

1 In an attribute window, click an attribute.

2 Click its Sort box to sort the results alphabetically, then apply any

other restrictions you want.

3 Choose Query>Modifiers>Distinct to eliminate duplicate values.

4 Choose Query>Save.5 In the Save Query dialog box, click Data Values Queries, then

specify a name for the file. (See “Naming and Storing Data Values

Files” on page 85.)

Page 99: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 99/186

Data Values Files, Prompts, and Variables 9

6 Click Save.

Using Data Values Files to Alias Data

Data aliasing  allows users to select from a list of common-language

names for data values while BI/Query inserts the corresponding actual

values into the query.

To set up data aliasing, you create a data values results file or data values

query file that contains two columns; in the first column are the actual

values, in the second are the aliases. Only the data in the second

column is displayed in the list of data values. Instead of selecting a value

for a qualification that may be difficult to understand or remember,

such as a staff person’s ID number, you’ll be able to select a more

meaningful value, such as the person’s last name. You select the name

from a list of data values and BI/Query inserts the ID number into the

qualification edit box for the query.

When you qualify the ID# attribute, click the data values icon in the

qualification tree, BI/Query displays staff last names as a list.

Page 100: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 100/186

94 Data Values Files, Prompts, and Variables

When you select a name from the list, BI/Query inserts thecorresponding ID number into the qualification tree.

To create a data values file that aliases data

1 In an attribute window, click an attribute that represents the values

 you want to alias.

2 Click a second attribute that represents the value you want to bedisplayed in the data values list, then, if you want to sort it, click its

Sort box.

ID for Peterson

Page 101: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 101/186

Data Values Files, Prompts, and Variables 9

3 Save the query as a data values query file. (See “Creating Data

Values Query Files” on page 90.)

OR

Submit the query and save the results as a data values results file.

(See “Naming and Storing Data Values Files” on page 85.)

4 Name the file after the first attribute (for example, Staff.ID # ).

Page 102: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 102/186

96 Data Values Files, Prompts, and Variables

Prompts

A prompt  is a request to insert a value into a qualification when you

submit a query. You can qualify a query with a prompt so that each

time you submit the query, you’re prompted to specify the

qualification value you want to use. (See “Qualifying Queries” on

page 32.) You can also include a prompt in a variable in order to

qualify a variable without inserting a value each time the variable is

used. (See “Including Prompts” on page 115.) And you can qualify a

data object or actual relationship with a prompt in order to restrict

users’ queries to specific information in a table. (See the BI/Query Data

Models Guide .)

For tables that contain a large number of rows, prompts improve query

performance and prevent users from submitting queries that retrieve

more data than they need. For example, regional sales managers may

need sales information only for countries in their region. When they

submit queries against the table containing countries, the queries

prompt them to specify the countries they want.

 You can submit queries using single prompts, group prompts, which

are made up of a number of individual prompts, and conditionalprompts, in which the data values returned for one prompt are based on

the value you specify for another.

Page 103: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 103/186

Data Values Files, Prompts, and Variables 9

Naming and Storing Prompts

Single prompts can have any name, although they’re usually named

after the attribute they qualify. (For example, if you create a prompt

that qualifies the City attribute, the prompt can be named City.) Groupand conditional prompts have special naming conventions. (See

“Group Prompts” on page 98 and “Conditional Prompts” on

page 101.) BI/Query stores prompts in a single Prompts file in the

Queries folder.

 You can type data values into a prompt or insert them from a data

values list. (See “Data Values and Data Values Lists” on page 35.)

Creating Single PromptsA single prompt  prompts you for one or more values for an attribute.

To create a single prompt

1 Choose Edit>Prompts.

2 In the Prompts dialog box, click New.

Page 104: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 104/186

98 Data Values Files, Prompts, and Variables

3 In the Edit Prompts dialog box, type a prompt name into the

Prompt ID text box.

4 Type into the Prompt String text box a phrase that describes the

data value or values wanted.

5 Click OK.

Group Prompts

A group prompt  is made up of two or more single prompts. All the

prompts can have the same group name and be displayed together in

one or more dialog boxes depending on the number of prompts in the

group. For example, a group prompt can be made up of prompts forthe Country and City attributes so that a query that qualifies those

attributes prompts you to select first a country, then one or more cities.

Page 105: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 105/186

Data Values Files, Prompts, and Variables 9

A group prompt can display up to five prompts in one dialog box. If it

contains more than five prompts, the first dialog box displays the first

five prompts, the second displays the next five, and so on. A query can

contain more than one group prompt.

When queries are qualified with more than one prompt, grouping

them in a dialog box allows users to see all the prompts at once and

reduces the number of steps in the query. It also relates one prompt to

another. (See “Conditional Prompts” on page 101.)

Creating the Prompts 

An exclamation mark is used to identify each prompt in a group

prompt. In order to keep related prompts together, it’s good practice to

provide a group name that precedes the exclamation mark. For

example, in the prompt Retailer!City, the group name is Retailer!  and

the prompt name is City. If you don’t specify an order for the prompts,

they’re executed in alphabetical order —  for example, Retailer!City is

run before Retailer!Country. If you want the prompts to appear in a

particular order, specify the order in their names. For example, to

ensure that the country prompt is run before the city prompt, use the

names Retailer!2City and Retailer!1Country.

To create the prompts for a group prompt1 Create at least two single prompts with a group name. (See

“Creating Single Prompts” on page 97.)

Page 106: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 106/186

100 Data Values Files, Prompts, and Variables

Creating the Title 

The dialog box that displays a group prompt displays the default title

Please Enter Qualification Values. You can create your own title for this

dialog box by creating a prompt that begins a the group name, two

exclamation marks, and Title  (for example, Retailer!!Title). You must

use the word Title with a capital T . The prompt string you type

becomes the title.

To create the title for a group prompt

1 Choose Edit>Prompts.

2 In the Prompts dialog box, click Edit.

3 In the Edit Prompt dialog box, type the name of a prompt into the

Prompt ID text box.

4 In the Prompt String text box, type a title for the prompt.

5 Click OK.

Testing the Prompt 

Before distributing a group prompt, it’s useful to test it to ensure that it

works properly. When you submit the query, the group prompt dialog

box displays the prompts in the order and with the title you specified.

To test a group prompt

1 In an attribute window, click the attributes you want.

2 For each attribute, click its Qualify box, choose Edit>Prompts,

then specify a prompt.

Page 107: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 107/186

Data Values Files, Prompts, and Variables 10

3 Submit the query.

4 In the group prompt dialog box, specify a value in the first text box.

(Type it or use the data values icon to select a value from a list.)

5 Specify a value in the second text box.

6 Click OK.

Conditional Prompts

Conditional prompts are group prompts in which the data values available

for one prompt are determined by the value specified for another. For

example, a prompt for cities provides only those cities located in the

country you specify for the country prompt. You create a conditional

Data values icon

Page 108: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 108/186

102 Data Values Files, Prompts, and Variables

prompt by creating a group prompt, then creating a data values query

file that retrieves data values based on the value specified for one of the

prompts.

When you select data values from a list instead of typing them into aprompt, conditional prompts eliminate inappropriate values from the

list and make it easier for you to find the appropriate values.

Conditional prompts are also useful in a data model that doesn’t allow

users to build their own queries, because they provide a means of

drilling down to obtain increasingly detailed information. (See the

BI/Query Data Models Guide .)

Creating the Group Prompt 

Make sure your group prompt prompts you in the order you want. For

example, to ensure that you’re prompted first for a country, then for a

city, name the first prompt Retailer!1Country and the second prompt

Retailer!2City.

To create the group prompt

1 Create a group prompt with a group name. (See “Group Prompts” 

on page 98 and “Creating Single Prompts” on page 97.)

Displays only cities in USA

Page 109: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 109/186

Data Values Files, Prompts, and Variables 10

Creating the Data Values Query File 

Now you create a data values query file that returns unique values for

the attribute that corresponds to the second prompt. Be sure to

eliminate duplicate values from your results.

To create the data values query file

1 In an attribute window, click an attribute that corresponds to the

second prompt.

2 If you want to sort the attribute, click its Sort box, then choose

Query> Modifiers>Distinct to eliminate duplicates.

3 Qualify the attribute that corresponds to the first prompt with the

first prompt.

4 Apply an operator. (See “Restricting Qualifications with

Operators” on page 42.)

This query retrieves a list of cities for the country specified for the Retailer!1Country

prompt.

5 Save the query as a data values query file using the name of the

second prompt in the group prompt. (See “Creating Data ValuesQuery Files” on page 90.)

Page 110: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 110/186

104 Data Values Files, Prompts, and Variables

Testing the Conditional Prompt 

Before distributing a conditional prompt, it’s good practice to test it to

ensure that it works properly.

To test a conditional prompt

1 In an attribute window, click the attributes you want.

2 Qualify the attribute that corresponds to the first prompt with the

first prompt.

3 Qualify the attribute that corresponds to the second prompt with

the second prompt.

4 Apply an operator. (See “Restricting Qualifications with

Operators” on page 42.)

The Country attribute is qualified by the Retailer!1Country prompt, and the City

attribute is qualified by the Retailer!2City prompt.

5 Submit the query.

6 In the group prompt dialog box, type a value into the first text box.

OR

If data values haven’t been disabled for the attribute, click the data

values icon and select a value from the list.

Page 111: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 111/186

Data Values Files, Prompts, and Variables 10

7 Click in the second text box.

8 Click the data values icon that appears, then click Data Values.

Clicking Data Values submits the data values query file (Retailer!2City) and displays

 the results in the Data Values dialog box.

9 In the Data Values dialog box, select the value(s) you want.(Depending on the operator you applied to the qualification, you

can select one or more values.)

10 Click Insert.

Page 112: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 112/186

106 Data Values Files, Prompts, and Variables

11 In the group prompt dialog box, click OK.

Importing Prompts

 You can distribute prompts by copying and renaming your Prompts file

(located in the Queries folder); other users can then import the prompts

contained in this file. You can also import prompts stored in someone

else’s Prompts file.

To import prompts

1 Choose Edit>Prompts.

2 In the Prompts dialog box, click Import.

3 In the Select Import File dialog box, select the file that contains the

prompts you want to import, then click Open.

4 In the Import Prompts dialog box, select the prompts you want

under Prompts to Import, then click Import.

Page 113: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 113/186

Data Values Files, Prompts, and Variables 10

5 Click Done.6 In the Prompts dialog box, click Done.

Variables

A variable  (or automatic  variable ) is a predefined operation that can be

used to qualify an attribute. (See “Variables” on page 38.) The

operation is performed when you submit the query and the results are

then used to qualify the query. Variables can also be used to qualify data

objects in a data model. (See the BI/Query Data Models Guide .)

Variables can carry out a variety of operations. In their simplest form,

they can retrieve values in the database so you don’t have to specify

them in queries. For example, when you need information about

retailers in a particular country, you can use a variable to determine the

states or provinces that are included in that country, rather than specify

each state or province yourself.

Variables can also perform calculations based on database functions to

work out date, time, and other values. For example, you can use a

variable to retrieve retailer sales that were placed today, before today,

and so on. The variable supplies what today’s date is, and BI/Query

returns the corresponding results.

Page 114: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 114/186

108 Data Values Files, Prompts, and Variables

Variables are especially useful for queries that are run on a regular basis

or are scheduled to run at specific intervals because they can

automatically supply data values for the time when they are run.

A variable can contain attributes, operators, values in the database,calculations, functions, subqueries, prompts, other variables, or stored

procedures (anything that’s valid in an SQL WHERE clause). Variables

take the work out of formulating potentially complex queries.

Variables are stored in the Prompts file in the Queries folder and

therefore must have names that are different from those given to

prompts. You can import variables stored in another user ’s Prompts

file. (See “Importing Variables from a File” on page 116.)

Creating Variables

When you submit a query qualified with a variable, the variable is

executed as a complete expression —  that is, the variable is substituted

for the entire qualification, including the attribute and operator. As a

result, a variable must contain information about what attribute to

qualify and what operator to use, as well as the operation to be

performed.

When the query is submitted, the variable Customers Exceeding Credit is substituted for

 the entire qualification shown above. Customers Exceeding Credit performs the

operation retailers.receivable >retailers.credit, substituting “retailers.receivable” for the

attribute Credit Limit and “>” for the operator “=”.

A stored procedure may already contain attribute and operator

information; in all other cases, you’ll need to provide it when you

create the variable.

 You can add to a variable any value, calculation, function, subquery, or

stored procedure that’s valid in an SQL WHERE clause and supported

by the DBMS. The syntax for variable expressions depends on the

DBMS; the examples provided in this chapter are based on ODBC.

 You can test that

an expression

returns the results

 you want by creat-

ing a calculated attribute that

uses the same expression. Use

the attribute in a query, then

verify the results. (For infor-

mation on creating calculated

attributes, see “CreatingAttributes That Perform Cal-

culations” on page 55.)

Page 115: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 115/186

Data Values Files, Prompts, and Variables 10

To create a variable

1 Choose Edit>Variables.

2 In the Variables dialog box, click New.

3 In the Edit Automatic Variable dialog box, type a name and

description into the Name and Description text boxes.

This variable determines today’s date. You can use it to qualify a query for sales at

 the end of a quarter rather than qualify the query with a specific date.

Attribute placeholder Specific operator Determines today’s date

Page 116: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 116/186

110 Data Values Files, Prompts, and Variables

4 Specify the expression you want the variable to perform. (See the

instructions below.)

5 Click OK.

Specifying Attributes and Operators

There are two ways to provide attribute and operator information in a

variable. You can create a variable that names an attribute and operator.

Or you can create a variable that uses placeholders for them.

Instructions for each are provided below.

To specify an attribute and operator

1 In the Edit Automatic Variable dialog box, select a data object from

the Table/Attributes list.2 To specify an attribute, select an attribute from the list under

Table/Attributes, then click Insert Selection. (See “Naming the

Attribute and Operator ” on page 110.)

OR

To specify a placeholder for an attribute, with the cursor in the

Expression text box, click ^Attribute^. (See “Using Placeholders” 

on page 111.)

3 To specify an operator, type it into the expression.

ORTo specify a placeholder for an operator, with the cursor in the

Expression text box, click ^Operator^.

4 Click OK.

Naming the Attribute and Operator 

A variable that names an attribute and operator will always qualify that

attribute using that operator, even if you insert it into the qualification

of a different attribute in the query. For example, suppose that in aRetailers data object, you create a query by selecting Name and Credit

Limit. You decide to qualify the query with the Customers Exceeding

Credit Limit variable. The variable performs the operation

Page 117: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 117/186

Data Values Files, Prompts, and Variables 11

retailers.receivable>retailers.credit. In other words, it qualifies the

Current Receivable (retailers.receivable) attribute by restricting it to

those retailers whose receivables are greater than their credit limits

(>retailers.credit). You can qualify Name, Credit Limit, or any

attribute you like with this variable, and the result will be the same

because the variable will always qualify the Current Receivable

attribute using the “>” operator.

Using Placeholders 

A variable that includes placeholders for the attribute and the operator

always qualifies the attribute into which it is inserted and uses the

operator you specify in the qualification tree. (When you submit a

retailers.receivable>retailers.credit

retailers.receivable>retailers.credit

retailers.receivable>retailers.credit

For any attribute you qualify

with the Customers Exceeding

Credit variable, the results

are the same, because it

substitutes the Current

Receivable (retailers.

receivable) attribute and

 the “>” operator.

Page 118: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 118/186

112 Data Values Files, Prompts, and Variables

query qualified by such a variable, the ^Attribute^ placeholder is

replaced with the current attribute and the ^Operator^ placeholder is

replaced with the current operator.)

For example, you could replace the Customers Exceeding Creditvariable (retailers.receivable>retailers.credit) in the example above with

a variable that substitutes placeholders for the attribute and operator

(^Attribute^ ^Operator^ retailers.credit). If you select the Name and

Credit Limit attributes, then qualify Current Receivable with the

placeholder version of the variable and choose the “>” operator, the

results are the same as those in the earlier example.

If you use the same placeholder variable to qualify a different attribute,

however, you’ll get different results. If, for instance, you qualify the

Invoice Amount attribute with the placeholder variable, the variable

finds the Name and Credit Limit of those retailers who are being

invoiced for amounts greater than their credit limits.

^Attribute^ ^Operator^ retailers.credit

Page 119: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 119/186

Data Values Files, Prompts, and Variables 11

 You can use placeholders to create variables that return different results

depending on the attribute qualified and the operator used.

 You include a placeholder in a variable you are creating or editing by

clicking ^Attribute^ or ^Operator^ in the Edit Automatic Variable

dialog box.

Using placeholders also allows you to create a variable that calculatestoday’s date; you can apply the variable to any date attribute in the data

model. The operator you specify in the qualification determines how

the attribute is compared to today’s date —  before (<), after (>), equal

to (=), and so on. No matter what attribute or operator you use in the

qualification tree, the query returns results based on today’s date. For

example, if you specify the Greater Than (>) operator, the query

returns results for all dates greater than today’s date.

Including Functions

Variables often include functions that perform some type of calculation.

Using the DBMS function for the current date, for example, a variable

^Attribute^ ^Operator^ retailers.credit

Page 120: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 120/186

114 Data Values Files, Prompts, and Variables

can determine the date for the beginning of the month to allow you to

find all retailer sales received since that date.

To include a function in a variable

1 In the Edit Automatic Variable dialog box, click Function.

2 In the Insert Function dialog box, select a function.

A list of built-in SQL functions appears under Functions. For certain DBMS types, a

list of scalar functions appears under Other Functions.

3 Click Insert.

4 To include the value to which you want the function to be applied,

edit the expression.

Including Variables

 You can use variables as building blocks for more complex variables.

The Today variable determines today’s date and allows you to create a variable that

determines yesterday’s date.

To include a variable in a variable

1 In the Edit Automatic Variable dialog box, with the cursor in the

Expression text box, click Variable.

^Attribute^ ^Operator^ {fn now()}

- {fn dayofmonth({fn now()})}

^Attribute^^Operator^ <<Today>> - 1

 You can use most

scalar functions

available in your

DBMS even if

they don’t appear in the

Other Functions list. Type the

function into the Expression

text box. (Check your DBMS

documentation for the correct

format.)

Page 121: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 121/186

Data Values Files, Prompts, and Variables 11

2 In the Variables dialog box, select a variable, then click Insert

Variable.

Including PromptsWhen you need to qualify a variable but you don’t want to restrict it to

a specific value, you can include a prompt so that you can insert a value

each time the variable is used. (For more information on prompts, see

“Prompts” on page 96.)

This variable includes the weekofyear! group prompt, which prompts you to specify first

 the week you want, then the year. The variable returns results based on the week and

year you specify.

To include a prompt in a variable

1 In the Edit Automatic Variable dialog box, with the cursor in the

Expression text box, click Prompt.

2 In the Prompts dialog box, select a prompt, then click Insert Prompt.

{fn week(^Attribute^)} ^Operator^

<<weekofyear!1week>>AND

{fn year(^Attribute^)} ^Operator^

<<weekofyear!2year>>

Page 122: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 122/186

116 Data Values Files, Prompts, and Variables

Importing Variables from a File

When you want to use variables created by another user, you can

import them from that user ’s Prompts file.

To import variables from a file

1 Choose Edit>Variables.

OR

If you’re qualifying a query, with the cursor in the qualification text

box, click the data values icon, then select Variables from the list.

2 In the Variables dialog box, click Import.

3 In the Select Import File dialog box, open the Prompts file

containing the variables you want.

4 In the Import Variables dialog box, select the variable(s) you want

under Variables to Import, then click Import>>.

When other users

want to use vari-

ables that you’ve

created, make a

copy of your Prompts file and

rename it to avoid overwrit-

ing other users’ files. Then

distribute your file using the

corporate server, e-mail, or

Intranet.

Page 123: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 123/186

Data Values Files, Prompts, and Variables 11

5 Click Done.

Using Variables to Supply User Names

Two predefined variables, DBUserID and BIUserID, are available in

BI/Query Admin. You can use these variables to customize results for

individual users without creating queries for each user.

The DBUserID variable supplies the database user name for the user

currently logged in to the database. Similarly, the BIUserID variable

supplies the BI/Broker user name for the user currently logged on to

BI/Broker. (See BI/Broker Users Guide .)

The creator of your data model can include a data object that associates

data with one of these user names. Then you can qualify queries with

the user name variable to ensure that only the data associated with that

user is returned to that user. (For information on how to associate data

in your database with a database user name or a BI/Broker user name,

see the BI/Query Creating Data Models guide.)

 You can use the DBUserID or BIUserID variable to qualify a query so

that it retrieves results customized for you. If you distribute that query

to other users, it retrieves results customized for each of them.

Users must be

logged on to

BI/Broker whensubmitting que-

ries that execute the BIUser-

ID variable. Otherwise, the

variable can’t supply the user

name. This is true even

though the user is submitting

a local copy of the query that

would not otherwise require

logging in to BI/Broker.

Page 124: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 124/186

118 Data Values Files, Prompts, and Variables

To qualify a query using a user name variable

1 In an attribute window, click the Qualify box for an attribute.

2 With the cursor in the qualification text box, click the data values

icon, then select Variables from the list.

3 In the Variables dialog box, select DBUserID or BIUserID .

4 Click Insert Variable.

5 Click Done.

Page 125: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 125/186

Building Advanced Queries

Qualifying One Attribute with Another 121

Qualifying an Attribute with a Subquery 122Modifying the SQL  125

Modifying a Query for Selected Results 126

Narrowing the Range of Results 128

Combining Queries 129

Appending One Results Set to Another 130

 Joining One Column to Another 132

Understanding Which Columns to Join 136

 Editing Combined Queries 136

Using the Super Query window 137

Editing a Component Query 138

Editing an Operation 139

Correcting Errors 140

Common Errors and Their Solutions 141

Creating Dynamic Relationships 142

Building Queries with a Circular Path 144

With a Correlation 145

Without a Correlation 149

Page 126: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 126/186

Page 127: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 127/186

Building Advanced Queries 12

Building AdvancedQueriesIf you are an experienced user with an in-depth understanding of the

database, of querying, and of your organization’s business rules,

BI/Query offers additional opportunities to build custom queries in a

variety of ways. You can qualify an attribute with another attribute or

with a subquery. If you know SQL (Structured Query Language), you

can modify a query by modifying the SQL on which it ’s based. You

can drill down on selected results to retrieve more detailed data and

narrow the range of results to focus on just the data you need. You can

combine queries by appending the rows or joining the columns of oneresults set to another. And you can edit the combined queries you’ve

created. You can create relationships on the fly to use two previously

unrelated data objects in a query. And you can build complex queries

with a circular path.

Qualifying One Attribute with Another

BI/Query allows you to build sophisticated queries in which one

attribute qualifies another attribute. For example, a Current Receivable

attribute can be qualified by a Credit Limit attribute to retrieve only

retailers whose current receivables exceed their credit limits. When you

qualify one attribute with another, you must specify the database name

for the second attribute.

To qualify one attribute with another

1 In an attribute window, click the Qualify box for an attribute.

2 With the cursor in the text box of the qualification tree, choose

Edit>Insert DB Name.

3 In the Insert DB Name dialog box, select a data object and

attribute.

Page 128: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 128/186

122 Building Advanced Queries

This query returns a list of retailers along with their current receivables and credit

limits. The Sort box indicates that the list will be sorted alphabetically by name. The

Current Receivable attribute is qualified by Credit Limit to retrieve only retailers

whose current receivables exceed their credit limits.

4 Click Insert Name.

5 Choose Query>Submit or save the query for later submission (see

“Saving Queries” on page 64).

Qualifying an Attribute with a Subquery

 You can access your data in more dynamic ways by qualifying a query

with a nested query statement, or subquery. A subquery returns values

for a single attribute.

Let’s say you want to retrieve information about retailers with the

highest credit limit. You’re aware that the highest credit limit allowed

for your retailers changes from time to time. You build and save a

Page 129: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 129/186

Building Advanced Queries 12

query that includes the Credit Limit attribute with the MAXIMUM

function applied to it. Then when you build other queries, you insert

that query as a subquery into a qualification, to obtain results based on

the maximum credit limit. When you submit such a query, BI/Query

submits the subquery first, then uses the results to qualify the query. By

qualifying with a subquery, you’re assured of always using the

maximum value in the database at the time you submit the query.

To qualify a query with a subquery, you need to create the subquery

first. A subquery can qualify any attribute, but it must qualify only one

attribute. It doesn’t have to qualify the attribute on which it’s based,

but it must have the same data type.

To qualify an attribute with a subquery

1 To create the subquery, in an attribute window, click an attribute.

2 Apply a function or qualification, then choose Query>Save.

3 To qualify a query with the subquery, in an attribute window, click

the Qualify box for an attribute.

4 With the cursor in the qualification text box, choose Edit>InsertSubquery.

5 In the Insert Subquery dialog box, select the subquery, then click

OK.

Page 130: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 130/186

124 Building Advanced Queries

6 In the qualification text box, select an operator from the operator

list. (If the subquery is returning a single value, select =. If it’sreturning a list of values, select IN  or NOT IN . The Begins with,

Contains, Ends with, Does not begin with, Does not contain, and Does

not end with operators are invalid for subqueries.)

7 If your query is complete, choose Query>Submit or save it for later

submission (see “Saving Queries” on page 64).

Page 131: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 131/186

Building Advanced Queries 12

Modifying the SQL

If you understand SQL and your database, you can modify the SQL

string generated by BI/Query when you formulate a query. However,

 you can’t directly modify the SQL for queries in which the results havebeen modified (see “Ordering Columns” on page 58 and “Sorting

Rows” on page 60) or combined with other results (see “Combining

Queries” on page 129).

 You must have the Edit Queries permission to modify the SQL.You

also need the Show SQL String preference to display the SQL in the

Query window. You can then modify anything after the SELECT

statement (subject to any restrictions placed on you by the DBMS).

BI/Query must recognize the format of data sent to the DBMS. If itdoesn’t, the results may have missing, misaligned, or otherwise

incorrect columns. This restricts the changes that you can make to the

SQL string. A good general rule is to not change anything before the

WHERE clause. That is, don’t change the attributes you’ve selected,

and don’t delete, add, or change the function you’ve applied to them.

Changes you make to the SQL string should be the last changes you

make to a query. If you modify the SQL string incorrectly, the DBMS

may return an error message.

To modify the SQL string

1 Make sure that you have the Edit Queries permission and the Show

SQL String preference. (Choose Tools>Permissions or

Tools>Preferences.)

2 Choose Query>Show.

If you click Show

Prompt Values in

the Query win-

dow, the SQL dis-

plays the values you insert

into prompts. If you don’t

insert values into prompts, the

Show Prompt Values option

displays the SQL without the

qualification or operator .

Page 132: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 132/186

126 Building Advanced Queries

3 Make the change(s) you want. (When you specify attributes in the

SQL string, use their database names, not the names in the attribute

window.)

4 If BI/Query displays a warning, click OK to overwrite the SQL

string.

OR

Click Cancel to undo your changes.

Modifying a Query for Selected Results

If you want to retrieve more detailed data about specific results you’ve

retrieved, you can do so in ad hoc drill-down mode . In this mode, you

select one or more results cells, then submit a query that returns results

only for those values.

When you select a single cell, {drilldown} appears in the qualification

tree instead of the contents of the cell. When you select more than onecell, the list icon appears; you can use it to view and modify the list of

cells you selected. (For information on using the list icon, see “List

Icon” on page 33.)

While the length

of the SQL state-

ment depends

only on available

memory, when you edit it in

the Query window, it acceptsup to 65,535 bytes. This

allows you to create queries

with thousands of values and

large numbers of calculated

attributes.

Page 133: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 133/186

Building Advanced Queries 12

To modify a query for selected results

1 In the results window, choose Results>Ad Hoc Drill Down.

2 Select the cell(s) on which to base your query.

The original query returns a list of retailer names, locations, and sales amounts.

Cells you select using Ad Hoc Drill Down are light grey.

3 To retrieve results that match these items, resubmit the current query.

OR

To retrieve different results for these items, modify the current

query, then submit it.

4 To work with the same subset of results later, save the new query.

To cancel ad hoc

drill-down mode,

choose Results>

Ad Hoc DrillDown or simply display

another window.

Provides a list of cells selected

in the results window

Page 134: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 134/186

128 Building Advanced Queries

The query retrieves only the records for retailers with the six largest sales amounts

and includes the dates on which the sales were placed.

Narrowing the Range of Results

To help you analyze your data, you can focus on a particular range of

results. Specifying a range for results includes only the rows within that

range. For example, you can specify retailer credit limits between

$200,000 and $600,000, sales received between June 30 and December

31, and salespeople’s names between the letters A and S . You can also

focus on results outside a range.

These results have no range applied. These results are for retailers with credit

limits between $200,000 and $600,000.

To narrow the range of results

1 Create or load a query.

2 Choose Query>Super Queries>Show Super Query.

 You can narrow

the results before

 you submit a

query by qualify-

ing an attribute with the

BETWEEN function (see

“Finding a Range of Values” 

on page 45).

Page 135: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 135/186

Building Advanced Queries 12

3 In the Super Query window, select a component query or

operation, then choose Query>Add Operation>Range.

4 In the Range Filter dialog box, click a column, then type a range

into the Minimum and/or Maximum text boxes. (For character

data, type the values using the correct case.)

5 To obtain results outside a range, click Not in Range.

6 Click OK.

Combining Queries

To focus on specific information and create more complex queries, you

can create a query that combines results. This super query gives you the

flexibility to perform join operations not specified in a design window

or supported by your DBMS. You can also combine results from

different databases and design windows, and place two or more related

results sets (for example, retailer sales for Europe and retailer sales for

North America) in one report. However, you can’t save a super query

as a data values query file (see “Creating Data Values Query Files” on

page 90) and you can’t save the SQL for the super query as a text file 

(see “Saving Results to a File” on page 157.)

 You combine queries by appending the rows of one results set to

another or by joining columns of results sets.

Page 136: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 136/186

130 Building Advanced Queries

Once you’ve combined queries, you can submit the resulting query to

retrieve the combined results. You can also link the combined query to a

button to perform these operations automatically. (For more information

on buttons, see the BI/Query Data Models Guide .)

This query appends the rows of one results set to another.

Appending One Results Set to Another

 You can append the rows of one query’s results to another —  even if

the data is derived from two different tables. For example, if one set of

results is for retailer sales during the first quarter and another is for

retailer sales during the second quarter, you can append one set to the

other to include sales for both quarters in the same report.

The data types of the columns in the first results set must match the

corresponding columns in the second results set. For example, if the

first results set contains two columns, and their data types are character  

and numeric , respectively, the first two columns of the second results set

must also be character  and numeric .

The two results sets can have a different number of columns as long as

the extra columns appear at the end of one set. Or you can exclude the

extra columns by hiding them. If the two results sets contain columns

with the same data type but in a different order, you can reorder them.

(For more information, see “Ordering Columns” on page 58.)

Page 137: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 137/186

Building Advanced Queries 13

Query Results 1

Name aSales

Abicon Inc. $12,000

Textal Ltd. $113,000

Unisystems $10,145

Ziptech $6,430

Query Results 2

Name aSales State

Bainstream Inc. $10,000 New York

Campus Corp. $2,000 California

MonoLitho $2,100 Ohio

Textronics $60,000 Illinois

Appended Results

Name aSales State

Abicon Inc. $12,000

Textal Ltd. $113,000

Unisystems $10,145

Ziptech $6,430

Bainstream Inc. $10,000 New York

Campus Corp. $2,000 California

MonoLitho $2,100 Ohio

Textronics $60,000 Illinois

Page 138: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 138/186

132 Building Advanced Queries

To append rows

1 Create or load a query.

2 Choose Query>Super Queries>Show Super Query.

3 In the data model, create or load a query you want to append. (Ifnecessary, reorder the columns in the query to match the order of

the first query.)

4 In the Super Query window, choose Query>Add Operation>

Append.

5 In the Append Rows dialog box, specify the results sets you want.

Appending rows from the second results set to the first. If the results sets have

different column names (for example, Retailer Name and Ret.Name), BI/Query uses

 the name of the first set.

6 Click OK.

Joining One Column to Another

BI/Query supports join operations that allow you to retrieve and

manipulate data from more than one table. Typically, these join

operations are specified when the data model is created. However, you

can also join columns of results by using a join operation to combine

queries. You may want to join columns of results when:

• the design window doesn’t provide joins for the attributes you need

to join

• the data model doesn’t include permission to create relationships

between tables

• the database doesn’t support outer joins

•  you want to combine results from more than one database

Page 139: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 139/186

Building Advanced Queries 13

• after looking at the data you’ve retrieved, you see that you want to

 join certain columns, but you don’t want to resubmit the

component queries (particularly if they took a long time to process

and you want to save time)

If the design window provides the joins you need and you want to reuse

a set of joined results, consider creating and saving a standard query that

retrieves the results rather than creating a query that combines the

results sets. Because the DBMS handles only one query, it may be able

to optimize the join operation more efficiently than BI/Query.

When you join results, you need to specify which columns should be

 joined and how. That’s because you’re creating a relationship between

the two tables. With the exception of columns containing float and

money data types, connecting columns must have the same data type.

By default, BI/Query joins the columns you specify and includes only

the rows that have an exact match. In SQL terminology, this is an

equijoin. (BI/Query actually performs a type of equijoin called a natural

 join, displaying the columns on which you join only once in the

combined results set instead of twice.) In the example below, data

about sales and payments have been retrieved from different tables. An

equijoin allows you to display only those sales for which payment has

been received.

 You can also join results and have BI/Query include all rows from a

results set even if they don’t match. In SQL terminology, this is an outer

 join. The example below shows that applying an outer join allows you

to display all sales, regardless of whether payment has been received.

 You can also apply a left or right outer join, as illustrated in the

diagrams on page 133.

Query Results 1

Sales # Sales Amount

101 $15,000

102 $52,303

An equijoin includes only rows

 that have an exact match in the

columns that are joined.

A left outer join includes all

rows from the left results set

and those that match from

 the right.

An outer join may even include

all rows from both results sets,

even if they don’ t match.

A right outer join includes all

rows from the right results

set and those that match

from the left.

BI/Query sup-

ports ANSI

SQL/92 syntax

for left and right

outer joins for certain data-

bases and connectivities. (For

more information, see the

online Help.)

Page 140: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 140/186

134 Building Advanced Queries

213 $995

331 $2,561

511 $8,000

514 $2,303

818 $612

Query Results 2

Sales # Amount Received

101 $15,000

102 $52,303

331 $2,561

818 $612

Equijoin on Sales #

Sales # Sales Amount Amount Received

101 $15,000 $15,000

102 $52,303 $52,303

331 $2,561 $2,561

818 $612 $612

Outer Join on Sales #

Sales # Sales Amount Amount Received

101 $15,000 $15,000

102 $52,303 $52,303

Query Results 1

Page 141: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 141/186

Building Advanced Queries 13

To join columns

1 Create one of the queries you want to join.

2 Choose Query>Super Queries>Show Super Query.

3 In the data model, create or load another query.

4 In the Super Query window, choose Query>Add Operation>Join.

5 In the Join Columns dialog box, make sure the current query is

selected in the Choose a Query for the Bottom Branch text box.

213 $995

331 $2,561 $2,561

511 $8,000

514 $2,303

818 $612 $612

Outer Join on Sales #

The columns you join must have

 the same data type

Page 142: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 142/186

136 Building Advanced Queries

6 Choose the columns you want to join from the lists of columns.

7 To include all rows from one or both results sets, click Include All

Left Rows, Include All Right Rows, or both. (For more information,

see “Understanding Which Columns to Join” on page 136.)

8 Click OK.

Understanding Which Columns to Join 

 You can join on up to four columns. This is especially useful when the

primary key consists of two or more fields. By default, BI/Query applies

an equijoin, including only the rows in both results sets that have an

exact match in the joined columns. The columns you join appear once

in the combined results set. You can specify a different join using the

Include All Left Rows and Include All Right Rows check boxes.

Editing Combined Queries

In a combined query, you can change each component query (each

query that makes up the larger query) and each operation performed on

the results. For example, you can add an attribute to a component

query, then change the sort order to include the new attribute. Editing

combined queries starts in the Super Query window.

To Include This Do This

Only rows that have an exact

match (equijoin).

Leave Include All Left Rows and

Include All Right Rows unchecked

All rows from the left results set

and those that match from the

right (left outer join).

Click Include All Left Rows.

All rows from the right resultsset and those that match from

the left (right outer join).

Click Include All Right Rows.

All rows from both results sets,

even if they don’t match.

Click Include All Left Rows and

Include All Right Rows.

 You can submit

and save queries

by right-clicking

the top pane of

the Super Query window,

then choosing the appropri-

ate option.

Page 143: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 143/186

Building Advanced Queries 13

Using the Super Query window

The Super Query window is divided into two panes separated by a

splitter bar, which you can use to resize the panes.

The top pane displays the structure of the query using a tree list. Eachcomponent query and each operation is included in the tree and is

represented by an icon. The operations performed on a component

query’s results appear above the component query in the tree. For

example, if the results of a component query are reordered, then sorted,

the tree list shows three branches —  first the component query, then

the reorder operation and the sort operation above it.

If a join or append operation is performed on two of the component

queries, it’s shown in the window above the queries and their

associated operations. Any operation that appears above a join orappend operation is applied to the results of the join or append.

Operation

Component queries

Message pane

Splitter bar

Toolbar

IconsQuery

Append

 Join

Range

Reorder 

Sort

Page 144: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 144/186

138 Building Advanced Queries

How the Retailer Accounts query works

1 Retrieves the results of the Invoice Amounts query. 2 Applies a range to the results.

3 Sorts by Retailer #. 4 Retrieves the results of the Retailer Receivables query.

5 Reorders the columns. 6 Sorts by Retailer #. 7 Joins the results from step 3 with theresults from step 6. 8 Reorders the columns to produce the final query.

The bottom pane of the Super Query window (called the message pane )

displays information about an item in the query. When you select a

component query, the message pane displays the query’s SQL string.

When you select an operation, the message pane shows information

about what the operation does to the query results. And if there’s an

error in the query, the message pane displays information about why

the error occurred and how to correct it.

Editing a Component Query

 You edit a component query by copying it from the Super Query

window into the data model. The component query then becomes the

current query, allowing you to open the appropriate attribute windows

and make your changes. When you’ve finished editing the query, you

paste it back into the Super Query window. (It’s not necessary to

submit the component query before you paste it.)

For example, suppose that a component query contains a date attribute

in a Sales data object and you want to add a qualification to the date

attribute. You copy the component query into the data model, then

open the Sales data object and apply the qualification. When you paste

16

4

37

8

5

2

When you re

working with

complex queries,

 you can see where

a join or append occurs by

collapsing the tree structure,

then expanding the branches

one by one.

Page 145: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 145/186

Building Advanced Queries 13

the component query back into the Super Query window, BI/Query

replaces the old component query with the new one.

If any errors occur as a result of making changes, you need to correct

them before you can save and submit the final query. (See “CorrectingErrors” on page 140.)

To edit a component query

1 If the super query isn’t loaded, choose Query>Load. In the Load

Query dialog box, select it, then click Load.

OR

Choose Query>Super Queries>Show Super Query.

2 In the Super Query window, click a component query, then

choose Query>Super Queries>Copy Query to Model.

3 Minimize the query window for the component query.

4 In the design window(s), make your changes to the component

query.

5 Display the Super Query window.

6 Click the component query you’ve edited, then choose

Query>Super Queries>Paste Query from Model.

7 Correct any errors. (See “Correcting Errors” on page 140.)

8 To save the query, choose Query>Save, specify a name for the

query, then click Save.9 To submit the query, choose Query>Submit Query.

Editing an Operation

 You can change how an operation manipulates query results by editing

the operation. You begin in the Super Query window. When you

double-click the operation you want to edit, BI/Query opens the

appropriate dialog box, where you can make your changes. When you

click OK, BI/Query replaces the old operation with the new one.

For example, if a range operation limits the results of a component

query to sales between $25,000 and $50,000, you can change the range

and the attribute the range is applied to. When you select the range

Editing GuidelinesWhen you edit queries in

the Super Query window,

follow these guidelines:

Start with the innermost

query and work up

through the tree. This

makes it easier to

correct any errors.

• Save your work

regularly.

• Don’t modify the SQL

string —  your changes

to the SQL won’t be

checked for errors.

If you can’t find

the Super Query

window, choose

Window>More

Windows, then use the Select

Window dialog box to open

the window.

Page 146: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 146/186

140 Building Advanced Queries

operation in the Super Query window, BI/Query opens the Range

Filter dialog box, where you can make your changes. When you click

OK, BI/Query replaces the old range operation with the new one.

If any errors occur as a result of your changes, you need to correct thembefore you can save or submit the query. (See “Correcting Errors” on

page 140.)

To edit an operation

1 To load a query, choose Query>Load. In the Load Query dialog

box, select a query, then click Load.

OR

Choose Query>Super Queries>Show Super Query.

2 In the Super Query window, click an operation, then chooseQuery>Super Queries>Edit Operation.

3 In the dialog box that appears, edit the operation.

4 Click OK.

Correcting Errors

Each time you edit a query in the Super Query window, BI/Query

checks for errors. You can’t save or submit a query that contains errors

 —  you need to correct the errors first. When you edit a query, youmay introduce an error because the parts of the query are

interdependent. For example, removing an attribute from a component

query when that attribute is used in a sort operation results in an error

in the sort.

Errors occur on operations, but you can correct them by editing either

the operation or its associated component query. For example, you can

correct the error described above by editing the component query to

include the missing attribute or editing the sort operation to sort on a

different attribute.

Most errors occur because an attribute used in an operation is missing

from the component query on which the operation is performed.

 You can’t edit anappend opera-

tion, but you can

delete it. Click the

append operation and choose

Query>Super Queries>

Delete Operation.

Page 147: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 147/186

Building Advanced Queries 14

When an error occurs, BI/Query displays an error icon beside the

corresponding operation. When you click the operation, the message

pane in the Super Query window provides information about why the

error occurred and how to correct it. After you ’ve corrected the error,

test the query by submitting it.

To correct an error

1 In the Super Query window, click the operation causing the error.

2 Read the information in the message pane.

3 Edit the component query or operation. (If you’re editing more

than one operation, start with the operation immediately above its

corresponding query and work up through the tree.)

4 To save the query, choose Query>Save, specify a name for the

query, then click Save.

5 To test the query, choose Query>Submit Query.

Common Errors and Their Solutions 

The table below lists some common errors and their solutions.

Error icon

Page 148: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 148/186

142 Building Advanced Queries

Creating Dynamic Relationships

The relationships between data objects in a data model allow you to

formulate queries using more than one object. Rather than using all

possible relationships between data objects, the data model typically

provides only the most important ones. When data objects don’t have arelationship, or when existing relationships don’t relate the attributes

the way you need them to be related, you can create dynamic

relationships. Dynamic relationships are typically created “on the fly” for

Type of Error Reason and Solution

Append: Column n doesn’t match The attributes in the results you’re

appending don’t match for one of

the following reasons:

•  you selected the attributes in thefirst query in a different orderthan the attributes in the second

• an attribute used in one query ismissing from another query

Edit the queries to reselect the

attributes in a consistent order.

Reorder Error: Missing Column

Range Error: Missing ColumnSort Error: Missing Column

An attribute in the operation is

missing for one of the followingreasons:

• the attribute is missing from thecomponent query

•  you hid the column with areorder operation

Do one of the following:

• edit the query to add the missingattribute

• edit the reorder operation to

restore the hidden attribute• edit the operation to use a

different attribute

Page 149: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 149/186

Building Advanced Queries 14

temporary use. To make use of dynamic relationships, you need to

understand the database and know how to draw related information

from more than one table.

Creating dynamic relationships requires the Dynamic Relationshipspermission and the Allow Dynamic Relationships preference. Saving

the relationships requires the Save Data Model permission.

In order to create a dynamic relationship between two tables, you need

to decide the condition under which the data in one table is related, or

“ joined,” to data in the second. That is, you need to specify a join

condition. For example, you can create a relationship between the

Retailer and Sales tables, where the Retailer Number attribute in one

table is made equal to the Retailer Number attribute in the other table.

A query that includes both data objects will then return data only forretailer numbers that appear in both tables. (For more information on

 join conditions, see “Creating Join Conditions” in the BI/Query Data

Models Guide .)

When you create a new relationship, it’s represented by a line joining

the two data objects in the data model. If you want, you can display a

relationship icon as well.

To create a dynamic relationship

1 Make sure that you have the Dynamic Relationships permission

and the Allow Dynamic Relationships preference and, if you’re

going to save the relationship, the Save Data Model permission.

2 Select the two data objects you want to join, then choose Query>

Relationship.

3 In the Choose Relationship dialog box, select <dynamic> from the

relationship list.

Page 150: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 150/186

144 Building Advanced Queries

4 Select an operator from the operator list. (The default operator is

“=”.)

5 Click an attribute in the left-hand list.

6 Click an attribute in the right-hand list, then click Add.

7 Click OK.

8 To save a relationship and name it, choose Query>New.

9 In the Save Query dialog box, click Save.10 In the Save Dynamic Relationship dialog box, specify a relationship

name. (For information on naming relationships, see the BI/Query

Data Models Guide .)

Building Queries with a Circular Path

When the data model you’re using contains two or more data objects

whose relationships form a circular path, you can build queries that use

all the data objects and all the relationships in that path. For example, ifthe data model contains the Employees and Departments data objects,

and they’re connected by the Work In and Managed By relationships,

 you can build queries that use both data objects and both relationships.

Data object lists

Operator listRelationship listChoosing an OperatorThe default = operator is

the most common type of

relationship; it specifies

that the value of anattribute from one table

equals the value of an

attribute from another.

 You may need to consult

 your administrator to

ensure that the relation-

ships you create use the

appropriate join conditions

and produce the results

 you want.

Page 151: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 151/186

Building Advanced Queries 14

Because each data object in a circular path has two relationships,

BI/Query prompts you to specify whether you want to create a

correlation (also called an alias). The choice you make determines how

 join conditions are applied in your query and the extent to which your

results are restricted. A query that uses a correlation allows you to ask

two questions of the same data object and is usually less restrictive than

a query that doesn’t use a correlation.

Queries with a circular path are typically built by advanced users who

understand how to use join conditions in order to retrieve the

information they need.

 With a Correlation

When you build a query with a correlation, BI/Query creates a

temporary copy of the data object. This allows you to ask two different

questions of the same object.

 You begin by selecting the relationships joining the data objects you

want to include in your query. The last relationship you select

determines how the circular query is formed. The data objects

connected to that relationship are the ones you’re presented with when

 you’re prompted to create a correlation. And that relationship is applied

to the data object you create a correlation for.

For example, if you select the Managed By relationship last and create a

correlation for Employees, BI/Query creates a second, temporary copy

of Employees called Empo__Manag. (To name the correlation,

BI/Query uses the first five characters of the data object’s name, two

underscores, then the first five letters of the relationship you selected

last.) The result is two copies of Employees: one connected to

Departments through the Work In relationship, the other, temporary

copy connected to Departments through Managed By.

When administra-

tors design a data

model, they can

create permanent

copies of a data object using

correlation names. In some

cases, this allows users to

avoid building circular que-

ries. (See the BI/Query Data

Models Guide .)

Page 152: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 152/186

146 Building Advanced Queries

This is what you see in the Behind the scenes, BI/Query creates

design window. temporary copy of Employees and connects it to

Departments using the Managed By relationship.

When you double-click the original data object in the design window,

 you’re prompted to specify which attribute window you want to use

 —  the one for the original data object or the one for its correlation.

 You can use one attribute window to ask one question, then the other

attribute window to ask the second question.

For example, suppose you want to use the data objects illustrated above

to find out which employees work for managers who make over

$60,000. You need a correlation because you’re asking for two kinds of

information from the Employees data object —  the names of the

employees and who is a manager making over $60,000. You’d use the

Employees data object to find out the names of the employees, and you’d use its correlation to find out who is a manager making over

$60,000. (You use the correlation for the second question because it’s

the one that uses the join condition in the Managed By relationship.)

When you submit the query, the DBMS processes it in two stages.

Behind the scenes, the DBMS first obtains a preliminary results set

(names of all employees and the departments they work in) by joining

each row in Employees with each row in Departments, then applying

the join conditions for Work In.

Departments X Employees

 Work In---------------------------------------------------------------- Results

1=

Page 153: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 153/186

Building Advanced Queries 14

The DBMS then applies the join condition for Managed By to the

preliminary results set and Emplo__Manag (the copy of Employees) to

retrieve the final results (employees who work for managers making

over $60,000).

This is the SQL that this query generates.

To build a query with a circular path that uses a correlation

1 Decide which data object you want to create a correlation for and

which relationship to use for that correlation.

2 Click the relationships joining the data objects you want to include.

(Make sure that the last relationship you click is the one you want

to use for the correlation.)

3 In the Circular Query Option dialog box, click the data object you

want to create a correlation for.

select

Employees.LastName,

from

Departments,

Employees,

Employees Emplo__Managwhere

(

(

Emplo__Manag.Salary > 60000.0000

)

)

and

Departments.DepartmentID = Employees.DepartmentID

and

Departments.Manager = Emplo__Manag.EmployeeID ;

Results1 X Emplo__Manag

Managed By----------------------------------------------------------------- ResultsFinal=

Because circular

queries are com-

plex, it’s good

practice to start by

building one that returns a

small subset of data. This

allows you to test the design

of the query before you sub-

mit it (and possibly retrieve a

large number of rows).

Page 154: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 154/186

148 Building Advanced Queries

4 Click OK.

5 In the design window, double-click the data object you created the

correlation for.

Double-click Employees to open the attribute windows for Employees and for its

correlation.

6 In the Open Attribute Windows dialog box, select the attribute

window(s) you want to open.

Choosing Employees  opens the attribute window for the original Employees data

object. Choosing Emplo__Manag  opens the attribute window for its correlation.

Page 155: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 155/186

Building Advanced Queries 14

7 Click OK.

8 In the attribute window(s), click the attributes you want to include

in the query, then close the window(s).

9 Click any other attributes you want to use from the other data

objects in the circular path.

10 To maintain all the join conditions in the query, choose Query>

Modifiers>Trim Relationships to deselect it.

11 Choose Query>Submit Query.

 Without a Correlation

When you build a query without a correlation, BI/Query doesn’t

create a temporary copy of a data object in the circular path. This

allows you to ask one question using all the data objects and all the joinconditions in the circular path. The results are usually more restricted

because the rows returned from the database must meet all the join

conditions in the circular path.

 

In a circular query without a correlation, the DBMS returns only the rows that meet the

join conditions in both the Work In and Managed By relationships.

Building a query without a correlation is similar to building a query

with a correlation except that the order in which you select the

relationships isn’t important. When BI/Query prompts you to specify

whether or not to create a correlation, you choose not to create one.

For example, suppose you want to use the data objects illustrated above

to find out which employees make over $60,000 and manage the

Page 156: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 156/186

150 Building Advanced Queries

department they work in. You need a circular query, but you don’t

need a correlation because you’re using each data object only once.

When you submit the query, the DBMS processes it in two stages.

Behind the scenes, the DBMS first obtains a preliminary results set(names of all employees who make over $60,000 and the departments

they work in) by applying the join condition for Work In to

Departments and Employees.

 

The DBMS then applies the join condition for Managed By to the

preliminary results set to obtain the final results (employees who make

over $60,000 and manage the department they work in).

This is the SQL that this query generates.

To build a query with a circular path that doesn’ t use a correlation

1 Click the data objects and relationships you want to include in the

query.

2 In the Circular Query Option dialog box, click No Correlation.

select

Employees.LastName,

from

Departments,

Employees

where(

(

Employees.Salary > 60000.0000

)

)

and

Departments.DepartmentID = Employees.DepartmentID

and

Departments.Manager = Employees.EmployeeID ;

Departments X Employees

 Work In---------------------------------------------------------------- Results

1=

Results1

Managed By-------------------------------- ResultsFinal=

Page 157: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 157/186

Building Advanced Queries 15

3 Click OK.

4 In the design window, double-click the data objects in the circular

path.

5 In the attribute window(s), click the attributes you want to include

in the query, then close the attribute windows.

6 Choose Query>Submit Query.

Page 158: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 158/186

Page 159: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 159/186

Exporting Information

 Exporting Queries 155

 Exporting Results 156Copying and Pasting Results 157

Saving Results to a File 157

Exporting Results to an Application 158

Preparing Results for Export 159

Specifying Results Options 159

Setting Export Options 161

 Exporting to Excel Using DDE 163

Common DDE Commands 163

Setting Export Options for Excel 164

Using Two Commands 164

Using the First Command only on Startup 165

Issuing Two Commands to Obtain the Effect

of Three 165

Combining Three Results Sets 166

Sending Current Results to Excel 167

Running a Macro That Calculates a 12-monthMoving Total 168

 Export Results Using Mail 169

Page 160: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 160/186

Page 161: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 161/186

Exporting Information 15

Exporting Information You can extend the usefulness of your BI/Query queries and results

sets by exporting them to other applications to produce powerfulworksheets and other documents. You can export the underlying SQL

for queries that have not been filtered or combined, and you can export

query results. You can save query SQL and results files for use in other

applications, and you can create buttons to export results automatically

using DDE or menu commands. You can also distribute by electronic

mail the query SQL files and results files that you’ve created.

Exporting QueriesIf you have the Save Queries permission, you can export the SQL for a

query to a text file, provided that the query does not manipulate the

results. (See “Ordering Query Results” on page 58, “Narrowing the

Range of Results” on page 128, and “Combining Queries” on

page 129.) The SQL can then be used in other applications. For

instance, you can use saved SQL in stored procedures in the database.

When you export a query from a results window, BI/Query saves the

query that generated that results set. When you export from any otherwindow, BI/Query saves the current query.

To export the SQL for a query

1 Make sure you have the Save Queries permission.

2 Load, build, or run the query you want to export.

3 Choose Query>Save.

4 In the Save Query dialog box, click Export SQL Only, then click

Export.

Page 162: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 162/186

156 Exporting Information

5 In the Save Query SQL dialog box, specify the name and location

for the file if you want these to differ from what is displayed, then

click Save.

Exporting Results

Query results are useful in BI/Query —  and they’re also valuable when

they’re exported to other applications. BI/Query exports results as text

files that can be used by any application. For example, you can augment

a report prepared in Microsoft Word by including actual data that

 you’ve retrieved from a query or you can transfer results to a worksheetin Microsoft Excel to perform advanced statistical analyses.

Page 163: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 163/186

Exporting Information 15

 You can export results using the following mechanisms:

• Copy results and paste them into another application. (See

“Copying and Pasting Results” on page 157.)

• Save results to a file and open the file in another application. (See“Saving Results to a File” on page 157.)

• Create a button that exports results to another application using

Microsoft’s Dynamic Data Exchange (DDE) facility or using menu

commands in that application. (See the table on page 158.)

Copying and Pasting Results

An easy way to export results is by copying them in BI/Query and

pasting them into the other application.

To copy and paste results

1 In a results window, select the results you want.

2 Choose Edit>Copy.

3 In the target application, paste the results you copied (in many

applications, Ctrl+V will paste copied material).

Saving Results to a File

 You can make results available to other applications by exporting the

results to a text file. Before exporting results, be sure that they’re

properly set up. (See “Preparing Results for Export” on page 159.)

 You can also create a button that automatically saves the results of a

query to a file. (See the BI/Query Data Models Guide .)

To save results to a file

1 Submit a query so that the results are saved directly to a file by

choosing Query>Submit Query>To File.

OR

In a results window, choose Results>Save As>Results.

2 In the Save Query Result to File dialog box, specify the name and

location of the file, then click OK.

Page 164: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 164/186

158 Exporting Information

3 Open the results file in the target application.

Exporting Results to an Application

A data model can include a button that exports results directly to

another application using one of two mechanisms —  menu commands

or Microsoft’s Dynamic Data Exchange (DDE). If you have the Edit

Data Model and Save Data Model permissions, you can create such a

button. (See the BI/Query Data Models Guide .)

When you export results to another application, BI/Query copies the

results, then checks whether the receiving application is already

running and, if not, starts it up. Depending on the export mechanism,

BI/Query then calls the appropriate menu commands in the receiving

application or sends the DDE commands to the receiving application.

Results must be set up properly in order to be exported directly to an

application. (See “Preparing Results for Export” on page 159.)

To use a button to export results to an application

1 Create a button. (See the BI/Query Data Models Guide .)

To Do This Use This

Export results by specifying the menu

commands to be executed in the receiving

application —  for example, to instruct

Microsoft Excel to execute Edit>Paste to paste

the contents of the Clipboard into a document.

Menu Commands

Include arguments in your commands thatinstruct the receiving application to carry out

more specific tasks than simply using menu

commands —  for example, to open a particular

worksheet and run a macro. (See also

“Exporting to Excel Using DDE” on

page 163.)

 DDE

Page 165: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 165/186

Exporting Information 15

2 In the Output section of the Create Button dialog box, click

Application, then click Export Options.

3 Specify export options, including an export mechanism (DDE or

Menu Item). See “Setting Export Options” on page 161.

4 In the text box, type the commands to be executed in the receivingapplication.

Preparing Results for Export

Before you export results, you need to ensure that they’re properly set

up. There are three things to consider:

• display format —  how numbers, characters, and dates are

represented (for example, Microsoft Excel doesn’t accept some dateformats allowed in BI/Query, like YY/MM/DD; see “Formatting

Data” on page 71)

• results options —  settings required by the receiving application

• export options —  the receiving application, the export mechanism,

and the commands to be executed

Specifying Results Options

When you save results to files and export them to other applications, be

sure to specify the results options required by the receiving application.

For example, a worksheet application may require double quotation

marks around textual data. (If you’re not sure what the receiving

application requires, check its documentation.)

 You can specify results options in the following ways:

• As data model preferences —  Specified in the Preferences dialog

box and applied thereafter to all new results sets and new buttons.

• For a particular results set —  Specified after retrieving results, with

the results window active; for this results set, overrides the options

specified as preferences.

• When you create a button —  Specified in the Create Button dialog

box; for this button, overrides the options specified as preferences.

Page 166: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 166/186

160 Exporting Information

To specify results options

1 To specify default  results options, choose Tools>Preferences. In the

Preferences dialog box, click Results Options.

OR

To specify results options for a particular results set, choose

Results>Options.

OR

To specify results options when you’re creating a button to

automate exporting or saving theme, in the Create Button dialog

box, click Results Options.

2 In the Results Options dialog box, specify the option(s) you want.

(These options are described in the table below.)

3 Under Separators, specify the separator(s) you want in the Field,Record, and End of File text boxes. (Select them from the lists or

type any valid ASCII characters, such as ^D for Control-D (ASCII

004), <LF> for a line feed, <CR> for a carriage return, and

<TAB> for a tab character. For more details, see the table below.)

4 Click OK.

Page 167: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 167/186

Exporting Information 16

Setting Export Options

When you export results to other applications, you need to specify the

application to which the results will be exported, the export mechanism

 you’re using, and the commands to be executed in the receiving

application. (To determine the requirements of the receiving application, see

its user documentation. You may also need the help of your administrator to

find out whether an application supports DDE and what service name to use.)

 You can specify export options as a preference or when you create a

This Option Does This

Save Query

Name

Includes the name of the query that generated the

results. This is useful when you’re exporting to

applications that use worksheet macros to performcertain operations depending on which query

generated the data.

Save Column

Headings

Includes results column headings in a block of

results that’s saved or copied.

Save Prompts Includes information about the prompts used in the

query —  for each, the number of prompts followed

by a record separator, the prompt ID followed by a

field separator, the number of values used in the

prompt followed by a field separator, and the actualprompt values separated by field separators.

Text in Quotes Inserts double quotation marks around textual data.

Transpose For results saved to a file, transposes rows and

columns so that the data is stored by columns rather

than rows (for example, the first row of results

becomes the first column of data); not available

when you create buttons.

Field

RecordEnd of File

A character or sequence of characters that separates

each value in a row (normally a tab character),separates each row of data (normally a carriage

return), and indicates the end of the file (normally

no character).

 A B C

D E F

A D

B

C

E

F

Original Transposed

Page 168: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 168/186

162 Exporting Information

button. Specifying export options in the Preferences dialog box applies

the options to buttons created thereafter. Export options specified from

the Create Button dialog box override the options specified as

preferences.

To set export options

1 To specify default  export options, choose Tools>Preferences. In the

Preferences dialog box, click Export Options.

OR

To specify export options when you’re creating a button, in the

Create Button dialog box, click Export Options.

2 In the Export Options dialog box, select the application to which

 you’re exporting from the Application list. (If it isn’t in the list,

select User Defined , then specify the file. The application name mustbe the same as the name that appears in the title bar of the

application. It can be up to 256 characters.)

3 If the executable for the application isn’t in your path, click the

button to the right of the Execute Command Line text box. In the

Select Application dialog, find and select the application, then click

Open.

4 If you’re exporting using DDE, and it isn’t supplied automatically,

supply the name that the application registers with the DDE server

into the Service Name text box.

5 Under Commands, click DDE or Menu Item.

When you create

a button to export

results using

DDE, the button’s

DDE command may contain

a macro that’s stored in a

shared network folder or in

different locations on users’ 

computers. If when you click

the button, BI/Query can’tfind the file, it captures the

path to Excel’s Macro Library

and inserts it into the button’s

DDE command.

Page 169: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 169/186

Exporting Information 16

6 Type the commands to be executed in the receiving application.

(The menu command mechanism requires the format “menu

command|command”.)

7 Click OK.

Exporting to Excel Using DDE

This section provides more information about exporting to Excel using

DDE as well as a number of examples. DDE (Dynamic Data Exchange) is

a form of inter-application communication in Windows and OS/2 that

allows applications to exchange information and commands.

Common DDE Commands

Here are some common command sequences used to send results to

Microsoft Excel using DDE. Some of them are used in the examples

that follow. For other commands, see your Excel user documentation.

To Do This Use This Command

Paste the results to a work-

sheet already open in Excel.

Or, if Excel is not alreadyrunning, run Excel, open a

new worksheet, and paste the

Clipboard contents to it

[paste()]

Paste the results to a new

worksheet in Excel

[new()]|[paste()]

Open the test.xls worksheet

(if Excel isn’t already

running) and paste the results

to it

[open(“c:\msoffice\excel\test.xls”)]

[paste()]

Open the test.xlm macro

sheet, then run a macro on

that sheet

[open(“c:\msoffice\excel\test.xlm”)]

[run(“test.xlm!macro1”)]

Page 170: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 170/186

164 Exporting Information

Setting Export Options for Excel

When you set export options for Excel, the default command —  

[Paste()]   —  appears automatically in the Commands text box. When

 you export your results, BI/Query starts up Excel if it isn’t already

running, then instructs it to paste the contents of the Clipboard (the

query results) into a worksheet.

Using Two CommandsInstead of using the default [Paste()] command in the Commands text

box, you can substitute up to two commands —  for example, to open a

specific worksheet and paste results. If you’re content with a generic

Open the test.xls worksheet,

open the test.xlm!macro1 

macro sheet, and run a macro

[open(“c:\msoffice\excel\test.xls”)]

[run(“test.xlm!macro1”)]

Open the test.xlm!  macro

sheet, then run the macro1 

macro on that sheet (where

the macro sheet is in the

BI/Query data model folder

or the macro is on the global

macro sheet)

[run(“test.xlm!macro1”)]

To Do This Use This Command

Page 171: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 171/186

Exporting Information 16

worksheet, you can open a macro sheet, run a macro on that sheet,

then save it using another name. Unless a macro is on the global macro

sheet, you must first open its macro sheet.

Using the First Command only on Startup

If the first of two commands is to be executed only once (such as

opening a specific worksheet on startup), use the | (pipe) symbol

between the two commands: [open(.........)]|[run(.............)]. Be sure

to also use the pipe symbol to prevent Excel from opening a worksheet

that is already open or pasting results into an open worksheet and

overwriting the contents. The first command is sent only if the

application isn’t already running and BI/Query must start it up; the

second command is always sent, even when the application is already

running. Specify all arguments for each command. The pipe symbol is

not  necessary if it’s logical for both commands to run each time you

export results. (The pipe symbol has a different purpose here than when

 you export results using menu commands.)

Issuing Two Commands to Obtain the Effect of Three

When you open a specific worksheet and run a macro, you’re doing

three things —  opening a specific worksheet, opening a specific macro

sheet, and running a macro. You can carry out these three commands

using two in order to use the DDE export mechanism. The two

commands would look like this:

To issue two commands to obtain the effect of three

1 Attach Excel’s auto_open function to your worksheet so that yourmacro sheet opens whenever the worksheet opens. Do this by

opening the worksheet, then choosing Formula>Define Name.

Specify a name such as Auto_open, then use the following syntax in

the Refers To text box: =test.xlm!open_macro.

[open(“c:\msoffice\excel\test.xls”)]|[run

(“test.xlm!macro1”)]

Page 172: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 172/186

166 Exporting Information

2 Place the macro on the global macro sheet (global.xlm). This sheet

is opened automatically with Excel and doesn’t require a command.

Using it cancels opening a default worksheet, but that function can

be included in the macro if needed. The disadvantage to this

approach is potentially developing a global macro sheet containing a

lot of specific macros that aren’t useful in a global sense.

3 Place the macro sheet in your path or in the subdirectory of the data

model you’re using. This is somewhat unorthodox, but the effect is

the same as placing the macros on the global macro sheet, and it has

the advantage of grouping the macros in a separate sheet.

Combining Three Results Sets

 You can easily combine the results of more than one query in an Excel

worksheet. This is useful when you’re using data from different tablesor when you’re using a combined query.

To combine three results sets

1 Create three buttons in BI/Query, then link each one to a query.

Link each button to a macro that positions the cursor in Excel, then

pastes the results to the appropriate spot on the default worksheet.

Click each button in turn. Don’t close Excel until all three buttons

have sent their results; otherwise, you’ll create three separate

worksheets. For example, set up the buttons with these macros:

If the macro sheet is in the BI/Query data model folder, or if the

macros are on the global macro sheet (see “Issuing Two Commandsto Obtain the Effect of Three” on page 165), you can accomplish

the same result using the following macros:

This Button Executes This Macro

Button A [open(“c:\msoffice\excel\test.xlm”)]

[run(“test.xlm!macro1”)]

Button B [run(“test.xlm!macro2”)]

Button C [run(“test.xlm!macro3”)]

Page 173: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 173/186

Exporting Information 16

2 Create a button that selects the current query, then exports the

results using the default paste to Excel. This method reduces the

number of buttons but requires you to load each query in

BI/Query before running it. You must also reposition the cursor in

Excel each time so that the next set of results does not overlap.

3 Paste to a specific worksheet. Open the macro sheet by following

one of the instructions in “Issuing Two Commands to Obtain the

Effect of Three” on page 165. Then use the following macros:

Sending Current Results to Excel

 You can create a button that exports the results of the current query to

Microsoft Excel using DDE. Using a button saves time when you

export data regularly to Excel. Clicking the button in this example

selects the results displayed in the results window, copies them to the

Clipboard, runs Excel, opens a new worksheet, and pastes the results.

If your Excel worksheet always uses the same format, set up a template

worksheet. Specify an export command that opens the template andpastes the results, such as [open( “ c:\msoffice\excel\template.xls” )][paste()] .

Once the results are copied, save the template with another name.

This Button Executes This Macro

Button A [run(“test.xlm!macro1”)]

Button B [run(“test.xlm!macro2”)]

Button C [run(“test.xlm!macro3”)]

This Button Executes This Macro

Button A [open(“c:\msoffice\excel\test.xls”)]

[run(“test.xlm!macro1”)]

Button B [run(“test.xlm!macro2”)]

Button C [run(“test.xlm!macro3”)]

Page 174: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 174/186

168 Exporting Information

To send current results to Excel

1 Create a button. (See the BI/Query Data Models Guide .)

2 Under Appearance, specify the name of the button, such as Send

Current Query to Excel.

3 Under Linkage, select Current Query.

4 Under Output, click Application.

5 Click Export Options and specify the application to which the

results should be exported (Microsoft Excel ) using DDE .

Running a Macro That Calculates a 12-month Moving Total

 You can create a button that exports the results of a query to Microsoft

Excel using DDE, opens a worksheet, and runs a macro that calculates a

12-month moving total.

To run a macro that calculates a 12-month moving total

1 In Excel, create the macro.

2 In BI/Query, in Design Mode, choose Layout>Create Button.

Page 175: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 175/186

Exporting Information 16

3 Under Appearance, specify the name of the button, such as Send

Current Query to Excel  or Create 12-month Moving Total.

4 Under Linkage, select Current Query.

5 Under Output, click Application.

6 Click the Export Options button and specify the application to

which the results should be exported (Microsoft Excel ) using DDE .

Export Results Using Mail

If you’re running an electronic-mail application on your computer, you

can export BI/Query files as attachments with your mail messages. Mail

provides an easy way to distribute new and revised queries and results

to others. If you use an electronic-mail application that supports

Microsoft’s Messaging API (MAPI), such as Microsoft Mail, you can

mail files directly from BI/Query.

When you send mail from BI/Query, the application starts up your

mail client. (For information on using your mail client, see the

corresponding documentation.) If you build a query before starting up

 You can retrieve

BI/Query files

using mail. Run

 your mail client

and retrieve the files into the

appropriate folders. (For

query files, this is the Queries

folder. For results, this is the

folder where BI/Query is

stored; be sure to retrieveboth .qrd  and .qrr  files.) To use

retrieved files, close the data

model if it’s open, reopen it,

then open the files.

Page 176: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 176/186

170 Exporting Information

mail, BI/Query automatically encloses the corresponding .qry file in

 your message —  regardless of which window you’re working in. If you

retrieve a results set, then start up mail, the corresponding .qrd  and .qry 

files are enclosed only if the results window is the active window. To

automatically enclose a results set, display the results window before

running mail. If you don’t want to include the current query or results

set in a mail message, remove the file from the enclosure.

To send mail from BI/Query

1 Choose File>Send.

2 Specify a recipient and subject and enclose any additional files.

3 Send the message.

Page 177: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 177/186

Index

A

actual relationships, qualifying, 96Ad Hoc Drill Down command, 127

ad hoc drill-down mode, 126 – 128

ad hoc queries, 29

Add Operation command, 129

adding

attributes, 51, 55 – 57

colors, 78 – 79

qualifications. S ee qualifying

rows of results, 130 – 132

See also creating

administr ator layer 

files, 23

finding, 24

reestablishing path to, 24

aggregate f unctions, 47 – 54, 56, 57

alarms, 78 – 79

aliasing data, 93 – 96

Allow Dynamic Relationships preference, 143

appending rows of results, 130 – 132

applications

BI/Analyze, 11

BI/Broker Admin, 10

BI/Broker, 10

BI/Query Admin, 11

BI/Query Reports, 11

BI/Query Update, 11

BI/Query User , 11

BI/Query, 10 – 11

BI/Suite, 9 – 11

BI/Web, 10

Business Intelligence, 8 – 12

Genio Suite, 8 – 9

Hummingbird, 8 – 12

Scheduler, 10

User and Group Manager, 10

attributes, 15, 16

adding, 51, 55 – 57

calculated, 51, 54, 55 – 57

calculations on, 47 – 57

creating, 51, 55 – 57

data formats, 71 – 75

data objects with, 15, 16

data values, displaying, 34 – 37

functions, appl ying, 47 – 57

grouping, 47 – 49, 51 – 55

in variables, 108

ordering, 58

sorting, 60 – 63

AVERAGE DISTINCT function, 50

AVERAGE function, 50

BBI/Analyze, 11

BI/Broker, 10

BI/Broker Admin, 10

BI/Broker Repository, 10, 21

See also repository

BI/Query Admin, 11

BI/Query Reports, 11

BI/Query Update, 11

BI/Query User , 11

BI/Query, 10 – 11

overview, 3, 15 – 18

starting, 21 – 23

BI/Suite, 9 – 11

BI/Web, 10

building queries. See queries

buttons, 18, 160

creating. See BI/Query Data Models Guide 

split data models with, 24

C

Cache Passwords per mission, 26calculated attributes, 51, 54, 55 – 57

calculations

in variables, 108

with attributes, 47 – 57

Index 1

Page 178: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 178/186

172 Index

calculations (continue d  )

with queries, 47 – 57

canceling ad hoc drill-down mode, 127

Case-sensitive Compar isons preference, 33

characters, special, 77 – 78

circular queries, 144 – 151

no correlations, 149 – 151

with correlations, 145 – 149

Clipboard, expor ting to, 157, 157

colors, using, 78 – 79

Column Order command, 59

columns

in results

hiding, 130

 joining, 132 – 136

ordering, 58, 130

Combine command, 42

combining

qualifications 35, 41 – 42

queries, 129 – 136

comparison operators, 43 – 44

computed strings, 78 – 79

condition box, 39 – 40, 42

conditional prompts, 97, 101 – 106

conditions, applying. Se e  qualifying

Connect command, 25 – 26

connecting to DBMS, 26

default connection files, 25 – 26

supplying connection information, 26

connection files, 26

omitting information, 26

Connections command, 25

contacting Hummingbird

Professional Services, 7 – 8

Sales, 12

Technical Suppor t, 6

Contents command, 5

Control Panel settings, 71, 71 – 73conventions in this guide, 3

converting two-digit years, 73 – 75

Copy command, 157

Copy Query to Model command, 139

copying, using Clipboard, 157

correlation names, 145

Count All command, 52

COUNT DISTINCT f unction, 51

COUNT function, 50, 54

creating

attributes, 51, 55 – 57

circular queries. See circular queries

data models. See BI/Query Data Models Guide 

data values

query files, 90 – 93, 103

results files, 88 – 90

nested queries, 123 – 124

prompts, 97, 99 – 100, 102

queries. See queries

relationships, 142 – 144

subqueries, 123 – 124

variables, 108 – 115

customer support, 5 – 6

D

data

aliasing, 93 – 96

entering, 71 – 73

formats, 71 – 75

colors, 78 – 79

dates, 71 – 72, 73, 77

default, 71

number s, 71 – 73, 76

strings, 77

groups, 49 – 55

substituting values, 78 – 79

data models

creating. See BI/Query Data Models Guide 

data objects, 15

editing, 24files, 23

opening, 23

split, 23

data objects, 15

Page 179: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 179/186

Index

attributes, 15

connecting, 142 – 144

qualifying, 96

relationships between, 142 – 144

data types, 55

Data Values command, 36

Data Values folder, 85

Data Values Results command, 88, 90

data values, 35 – 36, 83 – 96

access, 84

aliasing data, 93 – 96

disabling, 84

displa ying, 34 – 37

files, 83 – 96

icon, 34 – 37

in variables, 108

prompts, using with, 85 – 86, 103

qualifying attributes with, 34, 35 – 36, 83

query files, 83 – 86, 90 – 93

creating, 90 – 93, 103

naming, 85 – 86

prompts with, 85 – 86, 103

results files, 83 – 90

creating, 86 – 90

naming, 85 – 86

prompts with, 85 – 86

spreadsheet, using to create, 89 – 90

text editor, using to create, 89 – 90

database, connecting to, 26

Date Entry command, 74

dates

calculating in variables, 107, 109

entering, 33

fixed, 73 – 75

formats, 71 – 72, 73, 77

sliding, 73 – 75

DBMSs

connecting, 26default connection files, 25 – 26

Teradata, 55

DDE, 157, 158, 162 – 169

commands, 163 – 164

exporting to Excel, 163 – 169

default

connections, 25 – 26

data format, 71, 75

text styles, 71

deleting

calculated attributes, 55

characters in a string, 77

qualifications on attributes, 33, 35

displaying

data values, 34 – 37

data, 71, 75 – 79

Distinct command, 88, 89, 92, 103

documentation

conventions, 3

electronic, 4

related documents, 4 – 5

duplicate information, suppressing, 50

Dynamic Relationships per mission, 143

dynamic relationships, 142 – 144

E

edit mask, 78 – 79

Edit Operation command, 140

Edit Queries permission, 125

editing

buttons, 24

calculated attr ibutes, 55

data formats, 75 – 79

ornaments, 24

qualifications. See qualifying

queries, 125 – 126

SQL string, 125 – 126

electronic documents, 4

e-mail address, Hummingbird, 6, 8, 12

enhancements, suggesting, 6equal joins, 133 – 136

errors, editing, 140 – 142

Excel, exporting to, 162, 163 – 169

exception reporting, 78 – 79

Page 180: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 180/186

174 Index

exporting, 155 – 170

buttons, using, 157, 160

Clipboard, using, 157

DDE, using, 158, 162, 162 – 169

mailing f iles, 169 – 170

queries, 155 – 156, 169 – 170

reports, 170

results, 67 – 68, 156 – 163, 169 – 170

format, 159 – 161

to Excel, 162, 163 – 169

expressions. See variables

Ffax, Hummingbird, 6, 8, 12

files

data values

query, 83 – 86, 90 – 93, 103

results, 83 – 90

exporting to, 157, 159 – 161

mailing, 169 – 170

names, 85 – 86

Prompts, 106, 108

prompts, 97

queries, 68, 155 – 156

reports, 170

results, 67 – 68, 157

finding adminstr ator layer, 24

fixed dates, 73 – 75

Format command, 75

formats

data, 71 – 75

colors, 78 – 79

default, 71

substituting values, 78 – 79

dates, 33, 71 – 72, 77

number s, 71 – 73, 76results, 159, 159 – 161

strings, 78 – 79

four-digit year s, converting to, 73 – 75

functions, 47 – 55

aggregate, 47 – 57

AVERAGE DISTINCT, 50

AVERAGE, 50

COUNT DISTINCT, 51

COUNT, 50, 54

group order, 47 – 49, 51 – 52, 57

in variables, 108

MAXIMUM, 50

MINIMUM, 50

none, 50

qualifying attributes, 53 – 54

scalar, 57

SUM DISTINCT, 50

SUM, 47, 48, 50, 52

G

Genio Suite, 8 – 9

Group Qualification command, 53

group qualification, 53 – 54

grouping

attributes, 47 – 49, 51 – 55, 57

prompts, 97, 98 – 106

H

HAVING clause, 53 – 54

help

obtaining technical support, 5 – 6

online, 5

Help menu. See specific commands

hiding columns in results, 130

hierarchical prompts, 97, 98 – 106

How to use Help command, 5

Hummingbird

BI/Analyze, 11BI/Broker, 10

BI/Query Admin, 11

BI/Query Reports, 11

BI/Query Update, 11

Page 181: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 181/186

Index

BI/Query User , 11

BI/Query, 10 – 11

BI/Suite, 9 – 11

BI/Web, 10

e-mail address, 6, 8, 12

fax, 6, 8, 12

Genio Suite, 8 – 9

product documentation, 4 – 5

Professional Services, 7 – 8

Sales, 12

Technical Support, 5 – 6

World Wide Web address, 8, 12

I

importing

data values, 89

results, 89 – 90

prompts, 106 – 107

results from another application, 89 – 90

variables, 116 – 117

Insert DB Name command, 121

Insert Subquery command, 123

invalid data entry, 73

J

 Join command, 135

 join conditions, 143

 joining columns of results, 132 – 136

L

leaving prompts empty, 38

linkingdata objects, 142 – 144

data values to

attributes, 85 – 86

prompts, 85 – 86, 103

list icon, qualification tree, 33

Load Quer  y command, 139, 140

lock icon, 24

logging in to BI/Broker, 21 – 22

M

mailing files, 169 – 170

MAPI, 169 – 170

MAXIMUM function, 50

message pane, super query window, 138

MINIMUM function, 50

Modifiers command, 88, 89, 92

More Windows command, 139

multi-level prompts, 97, 98 – 106

multiple prompts, 97, 98 – 106

N

names of 

data values f iles, 85 – 86

prompts, 97, 99, 100

natural joins, 133 – 136

Negate Clause command, 40

negating qualifications, 40

nested queries, 122 – 124

New Query command, 144

none function, 50

null values, 46, 51

numbers

entering, 71 – 73

formats, 71 – 73, 76

O

objects. See data objects, buttons, ornaments, and

relationships

OLAP (Online Analytical Processing), 10, 11

Page 182: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 182/186

176 Index

online

documents, 4

Help, 5

technical support, 6

tool tips, 5

opening data models, 23

operations

append, 130 – 132

editing, 139 – 140

 join, 132 – 136

range, 128 – 129

super query window, using, 137

operator list, 34, 42 – 64

operators, 34, 42 – 64, 124

comparisons, making, 43 – 44

in variables, 108

matching

character strings, 44 – 45

items in list, 45

null values, 46

range of values, 45 – 46

user-defined, 46

options for exporting results, 160

order of 

attributes, 60 – 63

columns in results, 58, 130

prompts, 99

ordering columns, 58 – 59

ornaments, split data models with, 24

outer joins, 133 – 136

P

Paste Query from Model command, 139

permissions

Cache Passwords, 26

Dynamic Relationships, 143Edit Queries, 125

Save Queries, 65, 155

placeholders, in variables, 111 – 113

Preferences command, 16, 72, 160

preferences

Allow Dynamic Relationships, 143

Case-sensitive Comparisons, 33

Show Relationship Names, 16

Show Relationships, 16

Show SQL String, 125

problems, reporting, 6

procedures, in var iables, 108

product support, 5 – 6

Professional Services, Hummingbird, 7 – 8

Prompts command, 97, 100, 106

Prompts f ile, 108

prompts, 37 – 38, 96 – 107

conditional, 97, 101 – 106

creating, 97, 99 – 100, 102

data values, using with, 85 – 86, 103

drill-down, 97, 98 – 106

files, 97

group, 97, 98 – 106

hierarchical, 97, 98 – 106

importing, 106 – 107

leaving empt y, 38

multiple, 97, 98 – 106

names, 97, 99, 100

qualifying

actual relationships, 96

attributes, 54, 96, 136

data ob jects, 96

single, 97, 97 – 98

testing, 100, 104 – 106

titles, 100

publishing queries. See BI/Broker Publishing and Scheduling

Guide 

Q

qualification text box, 33qualification tree, 32 – 35, 53

condition box, 35, 39 – 40, 42

data values icon, 34 – 37

list icon, 33

Page 183: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 183/186

Index

operator list, 34, 42 – 64

qualification text box, 33

qualifying

actual relationships, 96

attributes, 30 – 47, 53 – 54

ad hoc drill-down mode, 126 – 128

combining qualifications, 35, 41 – 42

comparisons, making, 43 – 44

deleting, 35

editing qualif ications, 125 – 126

grouping, 47 – 57

matching character strings, 44 – 45

matching items in list, 45

negate clause, 35, 39

null values, 46

operators, 34, 42 – 64, 124

qualification tree, 32 – 35

range of values, 45 – 46

reversing qualifications, 35, 39

separating combined qualifications, 42

with an attribute, 54, 121 – 122

with data values, 34, 35 – 36, 83 – 96

with multiple qualifications, 40

with prompts, 37 – 38, 54, 85 – 86, 96 – 106

with subquer ies, 122 – 124

with values, 33

with variables, 38 – 39, 115

data objects, 96

results, 126 – 128

Queries folder, 65, 97

queries, 17 – 18, 29 – 38

building, 17

calculations with, 47 – 57

circular, 144 – 151

no correlations, 149 – 151

with cor relations, 145 – 149

combining, 136

append, 130 – 132 join, 132 – 136

complex, 129

creating, 17

combining, 136

editing, 125 – 126

correcting er rors, 140 – 142

expor ting, 155 – 156, 169 – 170

files, 68

filtering, range, 128 – 129

mailing, 169 – 170

nested queries, 122 – 124

ordering columns, 58 – 59

prompts. See prompts

publishing. See BI/Broker Publishing and Scheduling

Guide 

retrieving. See BI/Broker Publishing and Scheduling

G uide 

saving, 64 – 66, 155 – 156

scheduling. See BI/Broker Publishing and Scheduling

Guide 

securing. See B I/Broker Publishing and Scheduling G

sort order, 60 – 63

sorting rows, 60 – 63

SQL. See SQL

standard, 133, 155

submitting,

to applications, 156 – 169

to files, 68

subqueries, 122 – 124

super, 91

variables. See variables

R

Range command, 129

range, results in, 45 – 46, 128 – 129

Relationship command, 143

relationships, 16

creating, 142 – 144

dynamic, 142 – 144

saving, 143reporting problems, 6

reports

creating. See BI/Query Reports Guide  65

exporting, 170

Page 184: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 184/186

178 Index

reports (conti nued  )

mailing, 169 – 170

repository, 10

restricting

queries. See  qualifying attributes

results, 144 – 151

results

columns

hiding, 130

 joining, 132 – 136

order, 58, 130

ordering 58 – 59

combining, 136

data formats, 71 – 79

data values. Se e  data values

expor ting, 67 – 68, 156 – 170

files, 67 – 68

format, 159

grouping, 54

mailing, 169 – 170

qualifying, 126 – 128

range, specifying, 45 – 46, 128 – 129

restricting, 144 – 151

restricting. See qualifying

retrieving. See queries

rowsappending, 130 – 132

sorting, 60 – 63

saving, 67 – 68, 157

sending

to applications, 156 – 169

to files, 68

sorting 63

values, substituting, 78 – 79

Results Options command, 90, 160

retrieving information from the database. See queries

retrieving queries. See BI/Broker Publishing and Scheduling

Guide reversing qualifications, 35, 39

rows

sorting, 60 – 63

See also results

running BI/Query, 21

S

Sales, Hummingbird, 12

Save Queries permission, 65, 155

Save Query command, 65, 92, 123, 139, 141, 155

Save Results command, 68, 157

saving

queries, 64 – 66, 155 – 156

relationships, 143

results, 67 – 68, 157

SQL string, 155 – 156

scalar functions, 57

Scheduler, 10

scheduling queries. See BI/Broker Publishing and Scheduling

Guide 

Search for Help On command, 5

Send command, 170

sending

mail, using, 169 – 170

queries

to applications, 156 – 169

to files, 68

separatingcolumns in reports, 131

qualifications, 42

separators, for exporting results, 160

Show Query command, 38, 125

Show Super Query command, 128, 139, 140

single prompts, 97, 97 – 98

sliding dates, 73 – 75

Sort Order command, 63

sorting rows, 60 – 63

split data models, 23

administr ator layer, 24

buttons, 24ornaments, 24

reestablishing path between la yers, 24

splitter bar, super query window, 137

spreadsheets, data values results files, 89 – 90

Page 185: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 185/186

Index

SQL

HAVING clause, 53 – 54

operators. See operators

string

editing, 125 – 126

limit, 126

saving, 155 – 156

WHERE clause, 53

standard queries, 155

saving, 64 – 65

starting BI/Query, 21

strings, computed, 78 – 79

Submit Query —  To File command, 68, 157

Submit Query command, 139, 149, 151

submitting queries

to applications, 156 – 169

to files, 68

subqueries, 122 – 124

in variables, 108

substituting values, 78 – 79

SUM DISTINCT f unction, 50

SUM function, 47, 48, 50, 52

summary infor mation. See aggregate functions

super queries, 91, 129

See also filtering and combining queries

super query window, 137 – 138, 139, 140

suppressing duplicate information, 50

T

tables in database, r epresenting, 15

technical support, 5 – 6

contacting, 6

using the trace utility, 7

Teradata database, 55

testing prompts, 100, 104 – 106

text editor, for data values results files, 89 – 90time

calculating in variables, 107

including in r esults, 77

titles in prompts, 100

tool tips, 5

trace utility, 7

Tracing Enabled command, 7

tree list, super query window, 137

triggers, 78 – 79

Trim Relationships command, 149

troubleshooting problems, 7

two-digit years, converting, 73 – 75

U

Uncombine command, 42

User and Group Manager, 10

user-layer files, 23

user-defined

attributes, 55 – 57

calculations, 51

operators, 46

utilities, trace, 7

V

Variables command, 109, 116

variables, 38 – 39, 107 – 117

calculating

dates, 107

time, 107

containing

attributes, 110 – 113

functions, 113 – 114

operators, 110 – 113

placeholders, 110 – 113

prompts, 115

variables, 114 – 115

creating, 108 – 115

importing, 116 – 117qualifying attributes, 107 – 115

Page 186: SAP  Queries Guide

7/27/2019 SAP Queries Guide

http://slidepdf.com/reader/full/sap-queries-guide 186/186

 W

WHERE clause, 53displaying pr ompt values, 38

in variables, 38 – 39, 108

WinCLI connections, 55

windows, appear ance in this guide, 4

working offline, 21

World Wide Web

Hummingbird address, 8, 12

Y

 Year-2000 compliance, 73 – 75