dashboard example xml data
TRANSCRIPT
-
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 1
Step-by-Step Process for
Consuming XML Data in Xcelsius
Applies to:
Dashboard Design (Xcelsius Enterprise 5.3.2.0) (may also work with other versions). For more information, visit the Dashboard Design homepage.
Summary
This paper lists the steps for generating an XML file from an Excel worksheet and connecting it to an Xcelsius dashboard. This gives users suppleness to quickly work with source data and modify it per their business requirements without interacting with the dashboard file. Code for converting Excel data to XML data compatible with Xcelsius is also provided.
Author: Ashish Tewari
Company: Deloitte Consulting LLP
Created on: 21 October 2011
Author Bio
Ashish Tewari is currently working with Deloitte. He is a Business Intelligence Solution Consultant with 6 years of experience in SAP BW space.
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 2
Table of Contents
Introduction ......................................................................................................................................................... 3
Requirement ....................................................................................................................................................... 3
How XML Connection Works .............................................................................................................................. 3
Generating XML File ........................................................................................................................................... 4
Step-by-step Process ......................................................................................................................................... 6
Step 1: Create the Excel File .......................................................................................................................... 6
Step 2: Generate the XML File ....................................................................................................................... 6
Step 3: Validate the XML File ......................................................................................................................... 9
Step 4: Create the XML Connection in Xcelsius ........................................................................................... 10
Step 5: Map XML data to Components ......................................................................................................... 16
Step 6: Preview the Dashboard .................................................................................................................... 16
Consideration .................................................................................................................................................... 17
Appendix VB Code for Macro ........................................................................................................................ 17
Related Content ................................................................................................................................................ 20
Disclaimer and Liability Notice .......................................................................................................................... 21
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 3
Introduction
This paper lists the steps for generating an XML file from an Excel worksheet and connecting it to an Xcelsius dashboard. This gives users suppleness to quickly work with source data and modify it per their business requirements without interacting with the dashboard file. Code for converting Excel data to XML data compatible with Xcelsius is also provided.
Requirement
Dashboard is an intuitive tool for visualizing data in the form for eye catching flashy components. This is also complemented with the possibility of connecting it with live data. This may require dashboard to connect with any combination of diverse source system like SAP, RDBMS, Portal, Excel or XML. In this paper Ill discuss about the connectivity with XML data.
XML data can come from online forms or other databases. Here I will talk about converting an MS Excel file into XML file for data capture. Many times users want to have control to update dashboard data. In this case we can give them an MS Excel file and they can change data in it as per their business requirement and generate XML file, which will be connected to Xcelsius dashboard. This will reduce cycle time to update dashboard data.
Consider this requirement: users want to publish a dashboard page with manual feed of KPIs and a section of their BusinessObjects report hyperlink. To give them flexibility of changing underlying source file without changing dashboard XLF we can implement this solution. It will give users an Excel file, they can change or update data in that file on a specific section and generate XML file from there. This XML file will be linked in Xcelsius dashboard as source. This way XLF will be untouched and source data is also updated as per users direction.
How XML Connection Works
On Xcelsius there are various options for connecting it with source data. One of them is XML Data connection. There you can select Enable Send and/or Enable Load based on your requirement. For our scenario well do Enable Load. This functionality accepts data in a particular XML format and we need to generate XML file in that format only otherwise it will not be read. Once this data range is linked to Xcelsius, it works like any other connection. Data is populated in Xcelsius during runtime and components mapped with it will show visualization as configured. It is up to the designer to decide for the look and feel of dashboard with XML data.
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 4
Generating XML File
Important part of implementing this scenario is to understand how to generate XML file in specific format. It can be checked by clicking Preview XML button on Data Manager in Xcelsius. This will show how an XML should look like and then you can map it accordingly.
When you hit Preview XML button, it opens a temporary file in Internet Explorer that shows the structure of required XML file. Notice file name and declarations.
There has to be a VB program to generate this format from Excel file. See attached code in Appendix. All you need to do is to copy this code in Excel VB macro program and tweak it for XML file destination.
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 5
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 6
Step-by-step Process
Step 1: Create the Excel File
Create a layout for source Excel file and embed a button for Make XML. There will be Visual Basic (VB) code behind this button to read data from layout and put it in XML format compatible for Xcelsius. Go to the developer toolbar in Excel and insert a button from 'Form Controls'. Insert (copy and paste) the code in module for that Excel file by going to Visual Basic button on developer toolbar. Test and save Excel file as .XLTM format to save it with macro.
Step 2: Generate the XML File
When the user clicks the Make XML button, a popup message appears with procedure details. Once the user clicks Yes, it will ask about file name, group name, header row and data cell range.
File name should be same as Range name in Xcelsius connection details for XML.
Group name will be Row.
Titles destination of the table should be assigned in Header row.
Finally data set, which will be covered in XML should be specified in Data cell range prompt.
Note: Remember to change the destination for this XML file. Attached code saves it to the user desktop. Change this line accordingly "C:\Users\\Desktop\"..
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 7
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 8
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 9
Step 3: Validate the XML File
Once the XML file is saved, open it from its destination where it was saved (in this case from desktop) by VB program.
When you open the XML file, it will open in browser and will look like attached screenshot.
Check if this is the format expected and all declarations are opened and closed in proper order for Data, Variable, Row and Column.
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 10
When you collapse all rows, you can see that the structure of this XML file is same as what Xcelsius understands. Now this file is ready for connection with Xcelsius.
Step 4: Create the XML Connection in Xcelsius
Connect this XML file to Xcelsius using Data Manager.
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 11
Go to XML Data and specify the connection name (for example, XML Connection as below).
Provide XML file path in XML Data URL field.
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 12
Select text/xml for MIME type if the file is residing on the machine. In case of an online version of this file, choose the other MIME type.
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 13
Notice that there are of checkboxes for Enable Send and Enable Load.
Enable Send pushes data from Xcelsius to then external location Enable Load reads the data from the file or website.
In this document, select Enable Load check box.
Click the + icon and rename range with same name as XML files name.
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 14
Specify the range on the underlying Excel where this XML data will be populated during dashboard execution.
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 15
On the Usage tab, check the option of Refresh Before Components Are Loaded. This way, data will be populated in Xcelsius components on dashboard launch. A formula can also be placed here for a trigger.
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 16
Step 5: Map XML data to Components
Once XML data range is mapped in Xcelsius, perform the regular dashboard work. Map components with this XML data. Then define drilldowns and visibility of items.
Step 6: Preview the Dashboard
Based on above steps, dashboard components will be linked with XML data. Click Preview and validate the functioning.
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 17
Consideration
This concept of generating XML file from Excel and connecting it with Xcelsius can be used at many places. It is left to the imagination of developer who builds dashboards and creativity of users who pass on such requirements to us.
Appendix VB Code for Macro
' Sub Button1_Click()
' Attribute VB_Name = "XL_to_XML"
Sub MakeXML()
' create an XML file from an Excel table
Dim MyRow As Integer, MyCol As Integer, Temp As String, YesNo As Variant, DefFolder As
String
Dim XMLFileName As String, XMLRecSetName As String, MyLF As String, RTC1 As Integer
Dim RangeOne As String, RangeTwo As String, Tt As String, FldName(99) As String
MyLF = Chr(10) & Chr(13) ' a line feed command
DefFolder = "C:\Users\\Desktop\" 'change this to the location of saved XML
files
YesNo = MsgBox("This procedure requires the following data:" & MyLF _
& "1 A filename for the XML file" & MyLF _
& "2 A groupname for an XML record" & MyLF _
& "3 A cellrange containing fieldnames (col titles)" & MyLF _
& "4 A cellrange containing the data table" & MyLF _
& "Are you ready to proceed?", vbQuestion + vbYesNo, "MakeXML CiM")
If YesNo = vbNo Then
Debug.Print "User aborted with 'No'"
Exit Sub
End If
XMLFileName = FillSpaces(InputBox("1. Enter the name of the XML file:", "MakeXML CiM",
"xl_xml_data"))
If Right(XMLFileName, 4) ".xml" Then
XMLFileName = XMLFileName & ".xml"
End If
XMLRecSetName = FillSpaces(InputBox("2. Enter an identifying name of a record:", "MakeXML
CiM", "row"))
RangeOne = InputBox("3. Enter the range of cells containing the field names (or column
titles):", "MakeXML CiM", "A3:E3")
If MyRng(RangeOne, 1) MyRng(RangeOne, 2) Then
MsgBox "Error: names must be on a single row" & MyLF & "Procedure STOPPED", vbOKOnly +
vbCritical, "MakeXML CiM"
Exit Sub
End If
MyRow = MyRng(RangeOne, 1)
For MyCol = MyRng(RangeOne, 3) To MyRng(RangeOne, 4)
If Len(Cells(MyRow, MyCol).Value) = 0 Then
MsgBox "Error: names range contains blank cell" & MyLF & "Procedure STOPPED", vbOKOnly
+ vbCritical, "MakeXML CiM"
Exit Sub
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 18
End If
FldName(MyCol - MyRng(RangeOne, 3)) = FillSpaces(Cells(MyRow, MyCol).Value)
Next MyCol
RangeTwo = InputBox("4. Enter the range of cells containing the data table:", "MakeXML
CiM", "A4:E8")
If MyRng(RangeOne, 4) - MyRng(RangeOne, 3) MyRng(RangeTwo, 4) - MyRng(RangeTwo, 3)
Then
MsgBox "Error: number of field names data columns" & MyLF & "Procedure STOPPED",
vbOKOnly + vbCritical, "MakeXML CiM"
Exit Sub
End If
RTC1 = MyRng(RangeTwo, 3)
If InStr(1, XMLFileName, ":\") = 0 Then
XMLFileName = DefFolder & XMLFileName
End If
Open XMLFileName For Output As #1
'Print #1, ""
Print #1, ""
Print #1, ""
For MyRow = MyRng(RangeTwo, 1) To MyRng(RangeTwo, 2)
Print #1, ""
For MyCol = RTC1 To MyRng(RangeTwo, 4)
' the next line uses the FormChk function to format dates and numbers
Print #1, "" & RemoveAmpersands(FormChk(MyRow,
MyCol)) & ""
' the next line does not apply any formatting
' Print #1, "" & RemoveAmpersands(Cells(MyRow,
MyCol).Value) & ""
Next MyCol
Print #1, ""
Next MyRow
Print #1, ""
Print #1, ""
Close #1
MsgBox XMLFileName & " created." & MyLF & "Process finished", vbOKOnly + vbInformation,
"MakeXML CiM"
Debug.Print XMLFileName & " saved"
End Sub
Function MyRng(MyRangeAsText As String, MyItem As Integer) As Integer
' analyse a range, where MyItem represents 1=TR, 2=BR, 3=LHC, 4=RHC
Dim UserRange As Range
Set UserRange = Range(MyRangeAsText)
Select Case MyItem
Case 1
MyRng = UserRange.Row
Case 2
MyRng = UserRange.Row + UserRange.Rows.Count - 1
Case 3
MyRng = UserRange.Column
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 19
Case 4
MyRng = UserRange.Columns(UserRange.Columns.Count).Column
End Select
Exit Function
End Function
Function FillSpaces(AnyStr As String) As String
' remove any spaces and replace with underscore character
Dim MyPos As Integer
MyPos = InStr(1, AnyStr, " ")
Do While MyPos > 0
Mid(AnyStr, MyPos, 1) = "_"
MyPos = InStr(1, AnyStr, " ")
Loop
FillSpaces = LCase(AnyStr)
End Function
Function FormChk(RowNum As Integer, ColNum As Integer) As String
' formats numeric and date cell values to comma 000's and DD MMM YY
FormChk = Cells(RowNum, ColNum).Value
If IsNumeric(Cells(RowNum, ColNum).Value) Then
FormChk = Format(Cells(RowNum, ColNum).Value, "#,##0 ;(#,##0)")
End If
If IsDate(Cells(RowNum, ColNum).Value) Then
FormChk = Format(Cells(RowNum, ColNum).Value, "dd mmm yy")
End If
End Function
Function RemoveAmpersands(AnyStr As String) As String
Dim MyPos As Integer
' replace Ampersands (&) with plus symbols (+)
MyPos = InStr(1, AnyStr, "&")
Do While MyPos > 0
Mid(AnyStr, MyPos, 1) = "+"
MyPos = InStr(1, AnyStr, "&")
Loop
RemoveAmpersands = AnyStr
End Function
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 20
Related Content
Dashboard Design
Connecting Xcelsius Dashboards to External Data Sources using XML Data Button
Configure Xcelsius output XML schema for Xport Wizard
For more information, visit the Dashboard Design homepage.
-
Step-by-Step Process for Consuming XML Data in Xcelsius
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
2011 SAP AG 21
Disclaimer and Liability Notice
This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.