Using Visual Basic and the Business Objects SDK (version 6.5), I am attempting to automate the migration of universes and documents between repositories. I can successfully migrate core and derived universes, but I am having difficulties with the documents. Every document that is opened returns an empty string () for every DataProvider.UniverseName. Is there a reason I am unable to get the correct UniverseName of every data provider?
The following is a snippet of my code:
Dim BusinessObjApp As busobj.Application
Dim Document As busobj.Document
Dim DataProvider As busobj.DataProvider
Dim intDataProviderCount As Integer
Dim Universe As String
'Open Business Objects
Set BusinessObjApp = New busobj.Application
'Login to Business Objects
Call BusinessObjApp.LoginAs("MyGeneralUser", "MyGeneralPassword", False, "MyDomainName")
BusinessObjApp.Interactive = False
'Open the report file
Set Document = BusinessObjApp.Documents.Open("C:\Import\ReportFile.rep")
'Loop through each Data providers
For intDataProviderCount = 1 To Document.DataProviders.Count
Set DataProvider = Document.DataProviders.Item(intDataProviderCount)
'Find the DataProvider Universe if one exists
Universe = DataProvider.UniverseName
MsgBox Universe
'Document.Refresh
Next intDataProviderCount 'Loop for each Data Provider
I found that if I attempt to do a Document.Refresh, an error is thrown with the correct UniverseName that I need. But I am unable to access this name anywhere else. The error I receive is:
Any assistance you can give would be greatly appreciated. Thank you.
I also tried to retrieve the UniverseName by assigning the data providers universe to a Universe object and accessing the LongName property. Unfortunately, this method fails as well, with the following error:
The following is the code I used to try this:
Dim DataProvider As busobj.DataProvider
Dim Universe As busobj.Universe
Dim UniverseName As String
'Loop through each Data providers
For intDataProviderCount = 1 To Document.DataProviders.Count
Set DataProvider = Document.DataProviders.Item(intDataProviderCount)
Set Universe = DataProvider.Universe
'Gives an "Invalid Object" error on the line below
UniverseName = Universe.LongName
MsgBox UniverseName
Next intDataProviderCount 'Loop for each Data Provider
Is there another way I can use to find the Universe of a specific data provider in a document? Once again, any assistance would be great. Thank you.
The VBA variables that you are creating (Dim) are named the same as objects in the object model (like Universe, Document, DataProvider, etc.). Change those to Univ, Doc, DProv, etc. and see if that changes anything. Also for reference, you may want to look at the code in this utility. It’s a utility that documents all of the objects used in a series of .rep files, so it is doing similar logic.
Unfortunately, renaming these variables didn’t help.
You are correct; the logic in this code is similar. After running the report that was included in the post you mentioned, Business Objects popped up the “Select a Universe” dialog box, as shown here:
In light of this, I imagine Business Objects knows that the data provider is using the ‘FinOut’ universe, but is not sure which copy to use. If this is a correct assumption, I am back to my original question of “how did Business Objects know that this DataProvider used the FinOut universe and how can I access this information programmatically”?
If I cancel the “Select a Universe” dialog box, I receive the following error message:
which occurs on the following line:
This leads me to believe that since I canceled the “Select a Universe” dialog, Business Objects could not assign a universe to the DataProvider and thus the error when trying to access a property of an object that doesn’t exist.
So I guess I am still stuck on how to access the universe programmatically from a dataprovider in a report without any user intervention (like the “Select a Universe” dialog box). Any suggestions? Thanks in advance.
The dot (.) as the repository indicates a universe that hasn’t been exported. If you remove (or rename) that universe (in the base universe directory), does that solve the problem?
I removed the universe in the Base Universe Folder and this did solve the problem. I was able to retreive the Universe name from the DataProvider just fine. Thank you for your help!
However, what if there are multiple universe domains? For example, say the ‘FinOut’ universe exists in three different universe domains. Wouldn’t I run into the same issue? Is there a way to test for universe domain? Just curious.
If you look at the code sample you captured, you can see the .DomainName property. Unfortunately, it will still cause the same issue.
As far as same name in different domains, it does not appear to be a problem. I assume most installations (like ours) would have that configuration. It’s only the “non-exported” ones that appear to be an issue.
To use the same example, lets say I have a universe named ‘FinOut’ that exists in three different universe domains (UniverseDomainA, UniverseDomainB and UniverseDomainC). Additionally, I have a report that has a DataProvider which is referencing the ‘FinOut’ universe. When you say this will still cause the same issue, are you saying that Business Objects wouldn’t know which UniverseDomain the FinOut universe is referring to (so the Universe for the DataProvider would not be set and thus would throw errors when accessing any Universe properties)? Would it possibly pop up a “Select a universe” dialog or similar box where the user would have to choose the appropriate UniverseDomain for ‘FinOut’? Is there no programmatic solution to this issue (without user intervention of course)? Thanks.
Not quite. If you “touch” the .DomainName, it will give the same “ambiguous” prompt IF you have a duplicate non-exported universe (in the root universe directory). If the universes are exported (that is, residing in the appropriate domain specific subdirectory), then it will not be ambiguous, and your code should work just fine.