Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

Creation of the bobj access module

Szilárd Huber edited this page Oct 1, 2015 · 4 revisions

Accessing SAP Business Objects

Publishing

In SAP Business Objects there is an option to publish the reports as Web Services. This enables us to query the data behind and make it accessible in a more convenient format than soap.

First let's se how to publish a Web Intelligence report as a web service. It is quite straightforward after one figures out that only the applet and the rich client are capable of doing it and where to right click. To get the Publish as a web service option you need to right click on the edge of the data in the report.

Publish Web Intelligence Report

After we published the report we can get the url of its WSDL and go on with actual coding.

Getting the data

First as we are about to access data through Soap we have to get a package for that. Fortunately there is a package for that as for almost everything in NPM.

We need to get the name of the method that we will call:

soap = require 'soap'

getMethodName = (description) ->
    for tableName, tables of description
        for serviceType, method of tables
            for methodName of method
                return methodName
    return ''

soap.createClient wsdlUrl, (err, client) ->
    methodName = getMethodName client.describe()

After that there is not much more than shooting the soap query and waiting for the results:

options = 
    login: 'username'
    password: 'password'
client[methodName] [options], dataCallback

In the results we can get the field information (names and types) from the headers section and the actual data from the table section:

dataCallback = (err, results) ->
    # Get the fields
    fields = []
    if not err? and results?.headers?.row?
        for row in results.headers.row
            for cell in row.cell
                fields.push {name: cell.$value, type: util.getType(cell.attributes['xsi:type'])}

    # Get the rows
    data = results.table.row
    ret = []
    if data?.length? > 0
        ret =
            data.map (row) ->
                item = null
                if row?.cell?.length > 0
                    item = {}
                    for field,index in row.cell
                        item[fields[index].name] = field.$value
                return item
            .filter (row) ->
                row isnt null

From there on we are good to go. To make life a little more complicated the format for Query As a Web Service reports differ to the one we just described but we don't go into details about it.

The resulting package is available on Github with an MIT license so please feel free to check and fork.

Clone this wiki locally