|
Return to Newsletter Contents...
The Re-introduction of the Business Objects .Net SDK
By Joe Roberts, Vice President/Principal Consultant
What Can I do with the SDK?
In a nutshell… Anything that can be done with any and all of the user
interfaces provided by SAP Business Objects and more. So let’s think about that for a minute. What are the user
interfaces provided by SAP Business Objects?
1.)
InfoView: All user interaction with reports and other documents. Folder navigation, viewing,
scheduling and modification of reports and documents, Inboxes, Favorites, Preferences, parameter prompting, history,
etc.
2.)
The Central Management Console: Add users and groups, managing documents and reports, importing documents and reports,
setting properties, setting security, managing servers, displaying performance metrics, integration with Active
Directory and LDAP, managing universes and connections, creating and managing profiles and publications, etc.
3.)
The Publishing Wizard: Import Crystal Reports and agnostic documents, setting properties, creating schedules,
setting database logon information, creating folders and categories.
These are the main interfaces but all other interfaces that are built within
InfoView using the SDK completely or interfacing with the SDK to perform Business Objects Enterprise functions.
With this tool set you can do anything from a simple viewing of a report from a
custom application to writing your own InfoView-like interface to Business Objects Enterprise and anything in between.
Extending the SDK
So what could we really do with all this functionality? Let’s face it,
rebuilding the InfoView interface to your own liking is probably a bad idea unless there are mission critical business
rules that are not addressed in the standard InfoView interface. Time and cost alone should be enough to discourage
this. So what does make sense? How about augmenting current functions with your own business logic. A few things come to
mind from requests that I have received over the years.
1.)
How about creating a web based report publishing interface that allows
you to select multiple reports and publish them to different folders.
The Central Management Console only allows administrators to publish one report at a time and Publishing Wizard allows
you to publish multiple reports to different folders, but is a Windows application that requires installation on the
local workstation.
Using the SDK we could use our .Net knowledge to create a web page that allows
the user to select multiple reports using a “File Upload” component. Using the SDK we could display a list of folders
for each report allowing the users to select the folder in which to publish each report then commit those reports, in
batch, to Business Objects Enterprise.
2.)
Or how about setting individual user preference to a predetermined
“Global” setting.
Administrators would often like a “Global Default” setting for user preference
but InfoView only allows them to change an individual user’s preferences. Using the SDK we could build an interface that
would allow an Administrator to define the global preference settings they desire and then “push” those settings out to
a specific list of users, specific groups of users or all users within the system.
3.)
Here’s a really popular read world scenario: You have a custom
application, web site or intranet application and you want to display a list of reports (from Enterprise) and allow the
user to click on the report and view it without being prompted for an Enterprise logon.
Again using the SDK we can either associate a logon to Enterprise with the
logon to the application itself or use a common Enterprise logon for viewing the report (provided we have the proper
licensing in place). I’ll give you an example of the code necessary to do this later in this article.
These are just three very simple scenarios but as you can probably see we are
really only limited by our own imagination.
Installation
The SDK is available as part of the installation anytime you install any of the
Server or Client tools from the Business Objects Enterprise CD’s or DVD’s. Optionally you can choose a “custom”
installation and select only the .Net SDK.
On a developer workstation I would recommend the following:
1.)
First install either Visual Studio 2005 or 2008 on the workstation.
2.)
Run the installation of the Client Tools CD’s from SAP Business Objects
a.
If you just want the SDK, do a custom install and select the .Net
SDK under developer tools.
b.
If you will need to use any of the client tools (Designer,
Publish Wizard, Import Wizard, etc.) run the full installation of the Client Tools.
Make sure you are using the correct version of the Client Tools CD based on the
version of Business Objects Enterprise you are running in your environment.
Best Practices
Business Objects Enterprise is a platform; as such it is maintained and
controlled by the BO Administrator. This is an important piece of knowledge to keep in mind. No matter how much you may
want to control functionality from your application, ultimately the Enterprise Administrator will control everything. To
make your life easier I would recommend that you “evaluate” and “react” to information retrieved from the system instead
of trying to control it. For instance:
1.)
When you need a list of reports to display, make sure the list is
available to the user you will logon as and then simple ask the system for a list of reports. Use the information
returned to dynamically build your list of reports. That way when the Administrator removes a report or adds a new
report your list will react appropriately.
2.)
If you need to create your own prompting page, read the prompts from the
report and display them accordingly. Then augment them with your own business logic. This will prevent issues with
prompt order, naming and such that often create gaps or errors in your application.
3.)
Evaluate on actions before creating your listings. Check to see if the
user can “View On-Demand” before you create a link to view the report. No matter what you do you cannot obviate
security. If the users isn’t allowed to perform the action your link will fail with an error message. Evaluate and react
will save you a lot of heartache and perceived bugs.
Where can I get documentation on the SDK?
The appropriate documentation and downloadable help files can be found at
https://www.sdn.sap.com/irj/boc/sdklibrary
Both the Java and .Net SDK’s are available on this site so make sure you select the appropriate files to download.
Examples
As I promised before I want to take a few minutes to give you some real code for real world scenarios.
Everything starts with a first step and these examples are exactly that… a first step. While they certainly don’t
substitute for learning and knowing the SDK they should give you a good starting point.
Logging on and querying the application
The first step in writing any SDK based application will be to logon as a user
on Enterprise and get a list of objects (folder and/or reports). This example will logon a user named “bob.smith” and
retrieve a list of top level folders. Once we have the top level folders we can use that information to build a folder
tree and retrieve reports based on a selected folder.
In this example we will:
1.
Create a Session Manager object (SessionMgr). This is always the
first step when logging a user on. The Session Manager object allows us to create a session in Enterprise for this user.
The Session Manager will facilitate our logon and create something called the Enterprise Session object which represents
this user’s security context.
2.
Log the user on using the “Logon” method of the Session Manager.
This method requires us to provide the username, password, CMS machine name and type of authentication this user’s name
is associated with (in this example it is a Business Objects user account).
3.
We will then create something called the InfoStore. This object
provides our conduit to “query” the Enterprise environment and ask questions of Business Objects Enterprise. I like to
think of this like a .Net database connection object. We can use this object to retrieve Enterprise objects such as
Folders, Documents, Users, Groups, Universes, etc. It has a “query” method and we can write an Enterprise application
query that will look similar to a database query.
4.
We will then create a collection of InfoObjects. In this case
they will be a collection of top level folder objects but they could be Reports, Users, etc based on the syntax of our
query.
Ok… let’s go!
‘*** First we use and create a Session Manger using our “Using”
clause (no pun intended).
Using
mySessionManager As New SessionMgr
‘*** Log the users on using the Logon method of the session
manager, this will create an
‘*** Enterprise Session if successful
Dim MyEnterpriseSession As EnterpriseSession =
mySessionManager.Logon(“bob.smith”,”pw”,”myCMSName”,”secEnterprise”)
‘*** Here we will create something called a token. This token
represents the users credentials
‘*** and can be used later instead of persisting the logon information above. In this example I am
‘*** going to persist the token in session variable but you can do that anyway that makes sense to
‘*** you. We will use this token in the next example to view a report without prompting the user for
‘*** an Enterprise logon using the URL report viewing functionality. Below we are creating a token
‘*** that will be good for 1440 minutes and 1000 logons before the system will expire it.
Dim Token
As String = MyEnetperiseSession.LogonTokenMgr.CreateLogonTokenEx(“”,1440,1000).toString
‘*** Next we will create our InfoStore service so that we can
query the CMS
Dim myService
As EnterpriseService = MyEnterpriseSession.GetService(“InfoStore”)
Dim myInfoStore As InfoStore = New
InfoStore(myService)
‘*** We can now use our InfoStore object to query Enterprise;
the result of this query will be a
‘*** InfoObjects collection (in this example top level folders).
Dim FolderQuery
As String = “Select * from ci_infoobjects where si_parentid = 0”
Dim myFolderCollection As InfoObjects =
myInfoStore.Query(FolderQuery)
‘*** We can now loop though our collection and do whatever we
need
For
Each myFolder As InfoObject In
myFolderCollection
‘*** Put your own logic here
Next
End Using
That’s pretty simple - only 7 lines of code!
URL report viewing with a token
This example uses the Open Document call to view reports on the URL. All we
need to do is have either the ID or Name of the report we want to view and a logon token. This example is a function
that gets passed a report id and uses hardcoded credentials to log a user on to Enterprise. There are many ways to write
this function but the key components are:
1.
A report id or name
2.
An Enterprise logon token
3.
The correct path to the openDocument.aspx page in Enterprise.
Public Shared Function ViewAReport(ByVal myReportID As
String)
‘*** First we will create a variable to hold the path to the
openDocument.aspx. In this example
‘*** the name of server where Enterprise is installed is BOBJ1.
‘*** Next log the user on and create a token (See above).
Dim
MyEnterpriseSession As EnterpriseSession =
mySessionManager.Logon(“bob.smith”,”pw”,”myCMSName”,”secEnterprise”)
Dim Token As String =
MyEnetperiseSession.LogonTokenMgr.CreateLogonTokenEx(“”,1440,1000).toString
‘*** Next we will append query string variables to our viewer
URL to pass information to that page.
‘*** The first one is the report id the required variable name
for that is iDocID.
myViewerURL += “?iDocID=” & myReportID
‘*** Next add the token to a query string variable. The
required variable name here is token.
myViewerURL += “&token=” & Token
‘*** Lastly we simply direct the browser to the page described
in our viewer variable
Response.Redirect(myViewerURL)
End Function
That’s really all there is to it - 6 lines of code.
These examples are admittedly similar processes within the SDK but they are two
great starting points for writing complex, dynamic Business Objects Enterprise SDK application. I hope you’ve learned
something valuable here and happy coding!
|