Sie sind auf Seite 1von 7

How to…

Get BW data into Excel


without having an SAP
frontend installed
BUSINESS INFORMATION WAREHOUSE

ASAP “How to…” Paper

Applicable Releases: BW 2.0B, 2.1C


May 2001

SAP (SAP America, Inc. and SAP AG) assumes no responsibility for errors or omissions in these materials.
These materials are provided “as is” without a warranty of any kind, either express or implied, including but not limited to, the
implied warranties of merchantability, fitness for a particular purpose, or non-infringement.
SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages
that may result from the use of these materials.
SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within
these materials. SAP has no control over the information that you may access through the use of hot links contained in these
materials and does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party
web pages.
HOW TO GET BW DATA INTO EXCEL WITHOUT HAVING AN SAP FRONTEND INSTALLED

1 Scenario
This paper describes how to deliver BW WebReporting results into Excel spreadsheets by the help of
Excel’s Web Query feature. This method admittedly gives you much less functionality than the usual
way of retrieving BW data into Excel using the BEx Analyzer add-in – most prominently, interactive
reporting is not possible at all with this approach.
You no longer need RFC connectivity, or any other part of the SAP frontend installed on your PC. All
that is needed here is HTTP connectivity to your BW Server
(In Release 2.0B/2.1C of BW, this means you’ll have to have an SAP ITS server sitting on your web
server, which can pass incoming HTTP requests on to a BW application server).
This document describes how Web Queries can be used in Excel2000. The forthcoming next version
of Excel will further improve on the user interface and functionality for maintaining Web Queries. In
Excel97, Web Queries have already been available, although with limited functionality. However, their
maintenance was much more difficult. If you are interested in using Web Queries with Excel97, we
recommend that you download the so-called “Web Connectivity Kit for Excel“ from:
http://officeupdate.microsoft.com/downloadDetails/webcnkit.htm

2 The Result
The query’s result will automatically be presented in the worksheet.

Ó2001 SAP AMERICA, INC. AND SAP AG 1


HOW TO GET BW DATA INTO EXCEL WITHOUT HAVING AN SAP FRONTEND INSTALLED

3 The Step By Step Solution

The idea is to embed so-called Web Queries into Excel, which retrieve HTML via an HTTP request
into Excel. Web Queries render the information they receive directly into a range of cells in the
Excel worksheet.

1. To embed a Web Query into the


workbook, you choose the function
”New Web Query...“ from Excel’s
Data menu.

2. To define your Web Query, you


have to specify:
a. The URL for the Web Query:
Here you enter the URL to a BW
WebReport that the BW Web
Publisher generated for you.
b. The part of the result that you
want to see in your spreadsheet
Normally the default “Only the
tables“ will be the best choice
here. For exceptions from this
rule, see section 5.1 below.
c. How much of the HTML page’s
formatting Excel should try to
reproduce in the sheet
As Excel will often have trouble
to come close to the formatting
on the original page, less may be
more in this case – i.e. the option
“Rich text formatting only“ may

Ó2001 SAP AMERICA, INC. AND SAP AG 2


HOW TO GET BW DATA INTO EXCEL WITHOUT HAVING AN SAP FRONTEND INSTALLED

actually look better in the end


than the more ambitious “Full
HTML formatting“

3. The query’s result will automatically


be presented in the worksheet. This
may take a little time. So that you
can continue to work in other parts
of the sheet – data retrieval via the
Web is always asynchronous.

4. To change the query later on, you


can right-click on the Web Query’s
result range and choose ”Edit
Query...“ from the context menu.
Also from the context menu, you can
call up the “Data Range Properties“
dialog. Here you can specify
properties similar to the “Query
Properties“ in the BEx Analyzer, e.g.
whether you want the column width
in the result range to automatically
adapt to each new result, or whether
you want to refresh the query
automatically each time you open
the workbook. You also specify how
Excel should proceed whenever a
query result gets so big that it would
cover non-empty cells in other
ranges; and many more.

Ó2001 SAP AMERICA, INC. AND SAP AG 3


HOW TO GET BW DATA INTO EXCEL WITHOUT HAVING AN SAP FRONTEND INSTALLED

4 What are the limitations?

4.1 Avoid the variable dialog


With Web Queries, you have to avoid by all means that any preliminary HTML dialog precedes the
HTML page with the actual results. Among others, this means that user-entry variables are not
allowed here.
However, it makes a lot of sense to introduce user-exit (!) variables in the queries that you publish and
embed into Web Queries. With user-exit variables, you implement a small piece of coding that
supplies a user-specific value for a certain variable when a query is run. In general, user-exit variables
can still be user-entry variables, in which the user-specific value is only a suggested value that the
user can still change. With Web Queries, however, your user-exit variables should be non-user-entry
variables, so that the user-specific value will actually be the value that is used in the query. In this way
you can ensure that each user gets the data filtered in a way appropriate for him – i.e. to each his own
region, cost center, personnel number, etc.
Another interesting thing to note is that as of BW release 2.0, it is possible to have variables which
restrict the query’s initial result set, but whose values can still be overridden by filters applied during
interactive navigation - i.e., it would still be possible to set a filter outside the range which has been
prescribed by a user-exit variable. Therefore, user-exit variables and dynamic filtering (see section
5.4) can be combined.

4.2 Avoid the logon dialog


Another preliminary dialog that has to be avoided is the logon dialog. In rare cases, when BW
WebReporting is used to distribute non-confidential data, the HTTP server infrastructure will be
configured to not require a specific logon, so that no logon dialog will be sent out. Normally, however,
the server will require some logon information from the user – name and password, at least, and
optionally also client, language, etc. - and will automatically prompt the user, if these are not provided.
Therefore, the Web Query needs to provide logon information – and the only way this can be done is
with the Web Query’s URL. SAP’s Web Reporting infrastructure allows for URLs to be extended with
logon information like this:

https://myHostName/scripts/wgate/webrfc/!?_function=WEBQUERY&CMD=LDOC&WBID=F4
HF1H8OEXRB6FO0SF6XMDJ4F&PAGEID=myPageName&~login=JOHNDOE&~client=012&~
password=MYSECRET&~language=EN
To avoid having to hard code the password directly into the workbook query definition, you may want
to provide a dialog in Excel that prompts the user for the password and adds it to the URL (see
section 5.4).

4.3 Avoid interactivity and graphical items


Excel will only be able to render textual information into the worksheet. Therefore, it is quite clear that
graphical items in the HTML page, such as charts and maps, will be useless for our purposes here. Of
course it is possible to use Excel’s built-in features to fill maps and charts with the data that comes
back from the Web Query. For the often occuring problem of making maps and charts adapt
automatically to changes in the size of a Web Query’s result set, see paragraph 5.3 below.

Ó2001 SAP AMERICA, INC. AND SAP AG 4


HOW TO GET BW DATA INTO EXCEL WITHOUT HAVING AN SAP FRONTEND INSTALLED

BW WebReporting items which work particularly well with Excel Web Queries are the Table item, the
Filter item, and the Text Elements item. However, even with these you’ll have to exclude everything
that could add interactivity – because interactivity in BW WebReporting normally relies on Browser
scripting and/or stateful URLs, which are both unusable in Excel and could lead to all kinds of erratic
behavior. In particular, interactivity that would be rendered in the form of icons should be avoided. In
Excel, those icons would appear as shortcuts which a) are unattractive and b) would not work anyway,
see above.
From this it follows that, when publishing your Table, Filter, and Text Elements items, you should
switch off the flags for “Display header“ and “Add interactivity links“, and also set the value for “Fixed
page size“ to 0.
It’s also a good idea to add the parameter “...&STATELESS=TRUE“ to your Web Query URL to let the
BW Server know that you’re not going to use any interactive features. This allows for some
optimization, and you will receive your results a little faster.

5 Tips & Tricks

5.1 Partitioning the result


If you want to control the layout of data in your worksheet, there are two possible approaches:
è You can either modify the HTML template underneath your BW WebReport, i.e. insert blank lines
etc.
è You can embed several Web Queries for the same BW WebReport; each time picking a different
piece of the data that comes back.
For the second approach, you use option “One or more specific tables on the page“ in the query
definition dialog (see chapter 2 above). For example, the result shown in the third picture in chapter 3
consists of three tables: One that comes from a Text Elements item, one (with only one line) that
holds filter information, and one that displays the actual result set. If you would like to see the results
to the right of the text elements and filters, you could use two Web Queries: One that picks tables
”1,2“ and another one that only picks table ”3“.

5.2 Adapting the color palette in Excel


For efficiency reasons, Excel2000 is not able to display an arbitrary number of different colors in a
workbook. Instead, colors in a workbook always come from a fixed color palette, which is specific for
the workbook. Each workbook’s color palette holds 56 colors, and these are the only colors that can
be used for any cell coloring, including borders, backgrounds, or fonts.
Often enough, the colors on your Excel palette may not match very well with the style sheets that
looked so cool in the Internet browser. In this case, you can try to get better formatting by adapting the
color palettes for the workbooks that hold your Web Queries. To do this, choose ”Options...“ from the
”Tools“ menu in Excel, and switch to the ”Color“ tab.

5.3 Building refresh handlers


Often, you would want a certain script to run whenever new data arrives for your Web Query. For
example, you may have a chart attached to the Web Query’s result and need to re-attach the chart
whenever the size of the result changes.
In these cases, you can employ the “automatic recalculation“ feature in Excel. First of all, you would
have to implement your script, preferably in a VBA module in your workbook:

Ó2001 SAP AMERICA, INC. AND SAP AG 5


HOW TO GET BW DATA INTO EXCEL WITHOUT HAVING AN SAP FRONTEND INSTALLED

Function myRefreshHandler(myInput As String) As String

... your coding goes here ...

End Function
Then you choose an arbitrary cell outside (!) the Web Query’s result area, and enter into it the formula
“=myRefreshHandler(X1)“, where X1 is an arbitrary cell inside (!) the Web Query’s result area. As long
as you have “Calculation“ set to “Automatic“ in Excel (see the “Calculation“ tab in Excel’s “Options...“
dialog), a refresh of your Web Query will now automatically invoke your script.

5.4 Changing the Web Query URL dynamically


Please note that although you have to supply a URL to the Web Query when you create it, you can still
dynamically change that URL later on, e.g. by a VBA program. This enables you to use a wide range
of BW WebReporting features, because most of what you can do in BW WebReporting is also
available via URL parameters. For details about this, please refer to the usual BW WebReporting
documentation. Here we only give a short example to illustrate the technique. It shows a VBA routine,
which sets a dynamic filter for a certain country in a Web Query:

Const myUrlStaticPart As String = “http://...“

Sub applyCountryFilter(myCountry As String)

Dim myQueryTable As QueryTable

Set myQueryTable = ThisWorkbook.Worksheets(“mySheet“).QueryTables(1)

myQueryTable.Connection = “URL;“ & myUrlStaticPart & _

“&FILTER_IOBJNM=ODB_CNTRY“ & _

“&FILTER_VALUE=“ & myCountry

myQueryTable.Refresh

End Sub

Ó2001 SAP AMERICA, INC. AND SAP AG 6

Das könnte Ihnen auch gefallen