SAP offers reasonable guidance for creating and publishing the various reports (Webi, pdf, Excel, Crystal Reports) using custom web or windows applications that consume their SAP .Net Development SDK.
Using those tools one can create user friendly applications for managing reports in Infoview, but in some cases you may need an easily customizable process for automating some of those tasks. System administrators everywhere are finding Powershell to be a ideal tool administration and automation.
- SAP Business Objects 3.1 (BOXI 3.1)
- User account running Powershell has appropriate permissions to access the fileshare where the source pdf report is located
- Have account credentials with permissions to read/write files on the Bobj API server
- 32bit Powershell x86 engine
- Server or PC running the Powershell script has the SAP Business Objects .Net SDK installed
# Must use x86 powershell client for BOXI 3.1 dll's
#[CrystalDecisions.Enterprise.SessionMgr] | Get-member
$username = "<cmsUsername>"
$password = "<cmsPassword>"
$cmsname = "<cms-servername>:6400"
$cmsAuthType = "secEnterprise"
$BOServerName = "<Bobj-servername>"
[CrystalDecisions.Enterprise.SessionMgr]$boSessionMgr = New-Object CrystalDecisions.Enterprise.SessionMgr
[CrystalDecisions.Enterprise.EnterpriseSession]$boEnterpriseSession = $boSessionMgr.Logon($username, $password, $cmsname, $cmsAuthType)
[CrystalDecisions.Enterprise.EnterpriseService]$boEnterpriseService = $boEnterpriseSession.GetService("", "Infostore")
$boInfoStore = New-object CrystalDecisions.Enterprise.InfoStore($boEnterpriseService)
$myInfoObjects = $boInfoStore.NewInfoObjectCollection()
$myPluginManager = $boInfoStore.PluginManager
$myPluginInfo = $myPluginManager.GetPluginInfo("CrystalEnterprise.PDF")
$myInfoObject = $myInfoObject = $myInfoObjects.Add($myPluginInfo)
$myPDF = [CrystalDecisions.Enterprise.Desktop.Pdf]$myInfoObject
$myPDF.Title = "DeanPowershelling"
$myPDF.Description = "Dean is testing uploading to Infoview with Powershell"
# clean up
The example above is written for Pdf files, but the syntax for the other document types is very similar. Since this is Powershell, it would be a relatively simple task to convert the above to a Powershell Function that could be used by piping the results of some automation to the function to upload a collection of reports at a time, vs. the one-off approach above.
I initially assumed that because I had BusinessObjects installed on my development environment where I was testing, that I had the appropriate dll’s in the GAC to instantiate the BO objects in Powershell. That lead me down a rabbit hole of troubleshooting where I had difficulty determining if the issues I was having were related to the syntax I was trying to use in Powershell or the lack of the necessary BO assemblies.
I experimented with a combination of copying the dll’s from a working .Net web application to a local folder and using the Powershell Add-Type –path syntax to load the assemblies. I used Telerik JustDecompile to browse the SAP .Net SDK assemblies to make sure I wasn’t missing assemblies.
I downloaded and installed the SAP BusinessObjects .Net Development SDK’s. Some time during the troubleshooting I was successfully using the Powershell Add-Type –AssemblyName syntax, but I must have had the assemblies loaded from previous debugging attempts because after a restart of the development box, the script using Add-Type –AssemblyName to load the assemblies was failing to recognize the CrystalDecisions.Enterprise.SessionMgr which is actually a part of CrystalDecision.Enterprise.Framework which I was not loading in the PS1 script prior to the restart. The [reflection.assembly]:LoadWithPartialName was working with the above referenced assemblies even after a restart.
In order to step though and make sure my assemblies were referenced and loaded correctly, I used the above commented out syntax of BO object piped to the Get-Member commandlet to list the methods and properties on the BO objects:
[CrystalDecisions.Enterprise.SessionMgr] | Get-member
If the methods were listed without error, I knew I had the assembly references correct and the assemblies were loaded.
This is important enough to repeat, make sure if you are using the BOXI 3.1 SDK assemblies, you use an x86 32-bit Powershell engine.
Disclaimer: Make sure all interface with your SAP platform services is in compliance with your applicable SAP license agreements.