-
Notifications
You must be signed in to change notification settings - Fork 3
SAP Business Object Web Data Connector
We already showed some pretty cool Web Data Connectors for Tableau such as Github commits and MongoDB.
Today let's move to the area of enterprise software and connect to SAP Business Objects.
Fortunately there is an npm package that takes the pain of dealing with SAP BO Web Services down from our shoulders. We could use this package right from our WDC javascript but there are some problems with that approach.
- The package connects to an other server for data and it can cause CORS to block the data from there.
- This package uses some other packages and their browserified, combined size can be huge.
To cut short these issues we added two endpoints to our web server that just do the proxying of the data:
sendJSON = (res, data) ->
jsonData = JSON.stringify data
res.setHeader('Content-Type', 'application/json')
res.send(jsonData)
app.get '/sap/tabledefinitions', (req, res) ->
sap.getTables req.query.wsdl, req.query.credentials, (err, tables) ->
unless err?
sendJSON res, tables
else
res.status(500).send()
app.get '/sap/tablerows', (req, res) ->
sap.getTableData req.query.wsdl, req.query.credentials, (err, rows) ->
unless err?
sendJSON res, rows
else
res.status(500).send()
In the WDC code we only need to set up only two callbacks, the rows and the columns of the Starschema WDC Base object:
doAjax = (path, connection_data, success) ->
config = JSON.parse(tableau.password)
config.wsdl = connection_data.wsdl
xhr_params =
url: window.location.protocol + '//' + window.location.host + '/sap/tabledefinitions'
dataType: 'json'
data: config
success: success
$.ajax xhr_params
columns: (connection_data) ->
doAjax '/sap/tabledefinitions', connection_data, (data, textStatus, request) ->
if data?.length > 0 and data[0]?.Fields?.length > 0
tableau.headersCallback fieldNames(data[0].Fields), fieldTypes(data[0].Fields)
rows: (connection_data) ->
doAjax '/sap/tablerows', connection_data, (data, textStatus, request) ->
tableau.dataCallback data, "", false
We also set up the state machine and the Jade template for getting WSDL url and credentials as user input. They can be checked in the Starschema Tableau Web Table Connector repository.
And finally let's see it in action: