Two new XML Web items are available in the SAP BW 3.5 Web Application Designer that ease XML programming. Learn how they affect your query options.
Key Concept
Two XML Web items in SAP BW 3.5 provide programmatic access to query metadata and result sets in an XML output format. This paves the way to making programmatic interaction with and manipulation of Web Application Designer templates easier with XML.
SAP BW 3.5 includes two Web items that are easily overlooked because their names do not immediately make their function evident. While not necessarily directly applicable to the mainstream user of either Web Application Designer (Web AD) or Web templates in general, these Web items provide important features for making analytically based XML programming efforts easier over the Web. These Web items are unique in that they allow programmatic access to the result data returned by SAP BW 3.5.
By providing XML representation of both structural information and the actual data of a particular query or view, these Web items allow quick access to SAP NetWeaver BI data for browser-based application development. You can use JavaScript to access the data delivered by these Web items. This is particularly handy when the application accessing the SAP NetWeaver BI system requires detailed metadata information (in addition to the data itself).
Note
This article focuses on retrieving XML-based data from SAP NetWeaver BI. The corresponding XML-based import of data into SAP NetWeaver BI is covered in Ned Falk’s article, “
What’s All the Excitement Over XML in BW?.”
No extra functionality is needed in addition to SAP BW 3.5 to use these Web items and generate the XML output. The XML-enabled Web application of your choice consumes the XML output.
Shown in
Figure 1 and
Table 1, the two Web items I’ll focus on are:
- Web AD Object Catalog
- Web AD Data Provider Information
Figure 1
Web template layout with XML items (left). XML does not display at runtime (right).
Open Hub |
SQL or flat file |
Open Hub flattens data from SAP NetWeaver BI data structures. This is the interface for exporting mass volume data from SAP NetWeaver BI. |
Asynchronous (scheduled), mass data, and high volume export of data from SAP NetWeaver BI |
XMLA |
MDX via HTTP/SOAP request |
This method provides support for robust, industry-standard multidimensional expression (MDX) queries against SAP BI via HTTP/SOAP calls |
Synchronous, full-featured (standards-based) OLAP request with multidimensional results returned. Allows ad hoc querying of any InfoProvider. |
Web AD Object Catalog |
Simple HTTP request |
This Web item provides structural information about the query or view in XML format embedded in the source text of the resulting Web page |
Output is not visible via normal execution of the HTML Web template. This Web item can be placed on the same template with visible Web items (tables, charts, navigation). Allows programmer to access all details of metadata for the template and items embedded within the template. The scope of output is limited to content of Web template where this Web item is embedded. |
Web AD Data Provider Information |
Simple HTTP request |
This Web item provides the query metadata for the navigational state and result set values in an XML format. The level of detail reported for the query result set is set to a user-defined level of granularity in the Web item. |
Output is not visible via normal execution of the HTML Web template. This Web item can be placed on the same template with visible Web items (tables, charts, navigation). Allows programmer to access specific, stateful details for the template as the user interacts with visible Web items. The statefulness of a template is a setting that can be made via API calls. By default, the template is stateful. |
Web service-based access |
HTTP request for Web Service Definition Language (WSDL) and subsequent requests for details |
Web service-based data acquisition supported for SAP NetWeaver BI structures (via transaction WSCONFIG) |
Web service-enabled SAP NetWeaver BI data access. Often used when a query or view already exists for reporting and programmatic access to that report (e.g., result set) is needed. Avoids the requirement of recoding in MDX (if accessed via the XMLA interface, for example). |
|
Table 1 |
Comparison of data-access options for SAP NetWeaver BI |
Table 1 compares and contrasts standard and new ways of obtaining data from SAP NetWeaver BI, including the two Web items. Like all things SAP, there are purposely many ways to acquire data because companies may take very different technical approaches to reach the same ends.
These XML Web items give the programmer ultimate access to all aspects of the metadata and results of a particular query or view. They contrast to other SAP NetWeaver BI access methods in that they provide XML integration points for Web AD templates, including the current navigation state of that template. This means that the programmer can interact with the Web template at the same time that the end user is navigating through it.
You can also use the new Web items to display results in XML. For instance, an application that needs access to current sales figures for product X in time period Y for region Z for customer 123 could programmatically obtain that information from SAP NetWeaver BI and render the results in XML.
Object Catalog
The first of these two Web items, the Object Catalog, is simpler in output and usage than the other. It is simply an XML representation of the current Web template properties, data providers, and Web items used in the Web template. The XML output of these Web items is not directly visible in the Web template; it is generated in the source text for the Web application.
The output options for the Object Catalog are fairly self-explanatory (
Figure 2). One of the nice features of the last option, the
Output List of Web Items, is that its output list specifies the settings of each of the Web items in the template (
Figure 3). This can be particularly useful for trouble-shooting during template development and is more of a developer’s tool than something that would be propagated to production systems or directly used by end users.
Figure 2
Web item-specific properties of the Object Catalog
Figure 3
Item properties listed for a table Web item
Data Provider Information
This Web item reports on a specific data provider. Therefore, as you do for other Web items, you must specify one specific data provider. This Web item ultimately provides XML representation of the query or view details down to the individual cell values if you wish.
Two basic properties of this Web item control the output detail and content:
- Output navigation status
- Output result data
As shown in
Figure 4, selecting both options results in detailed XML output of several different categories.
To see the results in the format shown in
Figure 4 use the
EXPORT option supported by the SAP BEx Web API. For instance, you could place the command in
Figure 5 in your Web template.
Figure 4
Web item settings and related XML output
FORMAT=’XML’> |
Figure 5 |
Command to use the EXPORT option |
As you can see in
Figure 4, four basic categories of data are listed as output from the data provider Web item:
AXIS_INFO, TXT_SYMBOLS, CELL_DATA, and
AXIS_DATA. I’ll describe each of these briefly in the following sections.
Note
For SAP BEx Web API documentation, go to
help.sap.com and search for the document “Web Application Design: BEx Web Application Designer.” You can also follow this link from
https://service.sap.com/bi: Documentation>SAP BW 3.5 Documentation Enhancements>3.5 Web API Reference.
For a link that gives a detailed explanation of each individual XML tag (those shown in the list in Figures 6, 7, 8, and 9), go to
https://help.sap.com and search for “AXIS_INFO.” Click on the document labeled “Datasets — highlight.”
AXIS_INFO: This section breaks down into three classes of general metadata for the query or view: free characteristics, current columns, and current rows (Figure 6).
Figure 6
AXIS_INFO data classes
I’ll outline the details of the other tags displayed by this Web item. Because you produce the other tags displayed in the output by selecting the
OUTPUT NAVIGATION STATUS property, the Web item also tracks the current state of the data on the page. If I slice in another characteristic on the rows, I would then see the
NCHARS tag set to “2” and a later section listing that characteristic and its details.
TXT_SYMBOLS: The other half of the navigation status information is held under this tag (Figure 7). Text symbols come in three general classes (under the
SYM_TYPE tag):
- V means a variable value follows
- F means a filter value follows
- C means a general text element follows (note that the item in Figure 6 has a SYM_TYPE of C)
Figure 7
TXT_SYMBOLS details
This section also displays other details, such as the name of the report author and metadata for the entire query and query view (Creation Date, Last Modified Data, InfoProvider(s), Last Refreshed Date and Time, Filters, Conditions).
AXIS_DATA: As the name implies, this section provides information about all the query data outside the cell intersections (
Figure 8). This is where details of the characteristic values can be found on a column-by-column and row-by-row basis, including all levels of sliced in characteristics and key figures. Contrast this with the
AXIS_INFO section, which only shows the summary list of the contents of the axes.
Figure 8
Details of characters and key figures sliced on axes
CELL_DATA: Finally, this section describes individual values found at the intersections of the report (Figure 9). One item worth noting is that both the internal representation of a cell value and the formatted value are provided.
Figure 9
CELL_DATA details
Interacting with Customized Code
How do you access all this information via code? If you want to find individual cell values using JavaScript, the immediate challenge is how to navigate through the generated XML to locate the appropriate data. First, recognize where this data begins in the template. The command in
Figure 10 leverages the Document Object Model (DOM) to set a variable at the start of the XML output of the data provider information Web item.
startnode = document.getElementById(‘XMLQUERYVIEWDATA_1’); |
Figure 10 |
Command to set a variable at the start of XML output |
Note that
XMLQUERYVIEWDATA_1 is the default name given to this Web item. You can look in the HMTL code of your Web template to see the appropriate name in your case if you changed it from the default or want to target one of multiple Web items.
Then, it’s a matter of walking the XML tag hierarchy by reference, as shown in
Figure 11. From the data in Figure 1, the code in Figure 11 yields the value
4,320.000.
item_node =
startnode.firstChild.firstChild.nextSibling.nextSibl ing.nextSibl
ing.firstChild.firstChild.firstChild.firstChild.nextSibling.fi
rstChild.nodeValue;
alert(item_node); |
Figure 11 |
Code to walk the XML tag hierarchy by reference |
Walking the hierarchy is quite detailed because this example starts at a high level within it. Since a number of the intermediary XML tags are considered “children” and “siblings” of the startnode, you have to navigate down through this hierarchy to get the correct results. By “intermediary” I mean those tags (as seen in the source text of the Web template) that fall between the element ID and the target cell value.
Details of the order of operations for the child and sibling statements can be found in the help.sap.com documentation by searching for “XML Web Item: Data Provider Information.” The discussion there also provides an example that is a bit more complex than the one shown here.
Glen Leslie
Glen Leslie is a product manager for SAP’s Business Intelligence solution. Originally a data warehousing consultant, Glen has been working with SAP BW since the 1.2B release in a variety of environments.
If you have comments about this article or publication, or would like to submit an article idea, please contact the
editor.