BusinessObjects Board

Changing Universe

I’ve hit a bit of a wall here… :hb:

We have a certain number of linked universes (they all have the same structures, and the same objects, the difference being how they get populated…)

Anyway, we have a set of reports which could be run for either of those universes, so we would like to be able to decide from a VB form which universe to choose and from there the Dataprovider would be refreshed.

I have built the VB form listing all the Universes available.
I can then edit the Dp for the given report, but it seems that the Universe name is Read only and I cannot update it.

has anyone got any ideas???


Olivier Masse :fr: (BOB member since 2002-08-29)

Sorry , just found it.

It is the ChangeUniverse Method.


Olivier Masse :fr: (BOB member since 2002-08-29)

Well I found it but it still returns an error.
This is the code:


Private Sub UserForm_initialize()
    
    Set boDocs = Application.Documents
    Set boDoc = ActiveDocument
    Set boUnivs = Application.Universes
    
'Populates the DropDown Menu with the names of the available Universes
    For Each boUniv In boUnivs
        cmbUniverse.AddItem (boUniv.LongName)
     Next
     
End Sub

'30 April 2003 (Olivier Masse)
Private Sub cmdChange_Click()
    
    Dim i As Integer

    Set boDocs = Application.Documents
    Set boDoc = ActiveDocument
    Set boDps = boDoc.DataProviders
    
    iDps = boDps.Count
    
    For i = 1 To iDps
        Set boDp = boDps.Item (i)
        boDp.ChangeUniverse (cmbUniverse.Value)
    Next i
    
End Sub

When I run this code I get a message saying Object Required???

HELP!!! :confused: :shock: :frowning: :wah:


Olivier Masse :fr: (BOB member since 2002-08-29)

Hi,

Shouldn’t the parameter to ChangeUniverse method be an Universe object. You seems to be passing a text string from the ComboBox. Try changing that to an Universe Object and check whether it works.

Sri


Sridharan :india: (BOB member since 2002-11-08)

Sri,

i have tried to change the string returned from the drop down menu but I still get an error message.


For i = 1 To iDps
        For Each boUniv In boUnivs
            If boUniv.LongName = cmbUniverse.Value Then
                Set boUniv1 = boUniv
            End If
        Next
        boDps.Item(i).ChangeUniverse (boUniv1)
    Next i

According to the definition the function should be used as follow

I am getting lost there


Olivier Masse :fr: (BOB member since 2002-08-29)

Hi,

I did check up at my end and it says “Type Mismatch Error”. Note sure why :confused: :confused: :confused:

Sri


Sridharan :india: (BOB member since 2002-11-08)

Sri, it is because the repository wasn’t defined…
This code now works.


Dim i As Integer
    Dim sDp As String
    Dim newunivname As Universe
    
    Set boDocs = Application.Documents
    Set boDoc = ActiveDocument
    Set boDps = boDoc.DataProviders
    
    iDps = boDps.Count
    
    For i = 1 To iDps
        Set newunivname = Application.Universes(cmbUniverse.Value, "Repository Name")
        boDps.Item(i).ChangeUniverse newunivname
    Next i

Olivier Masse :fr: (BOB member since 2002-08-29)

Hi Olivier,

It works even without a repository name . Really strange :reallymad: Yesterday I didn’t work but today it worked without any problem.

Sri


Sridharan :india: (BOB member since 2002-11-08)

Strange…


Olivier Masse :fr: (BOB member since 2002-08-29)

Even more strange is the fact that it is the same code that I did yesterday. I thought of changing it after seeing message but instead ran it for once and worked great.

Sri


Sridharan :india: (BOB member since 2002-11-08)

I have another error when using similar code as you describe.

Run-time error ‘115’, error changing universe

-> on the similar line below/above “boDps.Item(i).ChangeUniverse newunivname”

Someone an idea?
Thanks!


BlackStrike (BOB member since 2004-09-14)

Hey Blackstrike,

I had the code working in version 5.1.6 we moved to 5.1.9 and now I get the same error on that line:

Run-time error ‘115’, error changing universe

-> on the similar line below/above “boDps.Item(i).ChangeUniverse newunivname”

Please let me know if and how you solved it.

Oscar


ohuibers :netherlands: (BOB member since 2004-03-05)

Hi All,

I am getting Type mismatch error when I try to change to universe of data provider from VB code. I am using BO 5.1.8 and the code is as follows:-

Public Function Refreshreport(reportname As String)
Dim ObjRep As New busobj.Application
Dim ObjDes As New Designer.Application
Dim ObjUniverse As Designer.Universe
Dim dp As busobj.DataProvider
Dim ObjReport As busobj.Document

Call ObjRep.LoginAs(“Parag”, , True)
Set ObjReport = ObjRep.Documents.Open(reportname)

Call ObjDes.LoginAs(“Parag”, , True)
Set ObjUniverse = ObjDes.Universes.Open(“D:\VB code POC\Test.unv”)
Set dp = ObjReport.DataProviders(1) Call dp.ChangeUniverse(ObjUniverse) :reallymad:
dp.refresh

End

I tried dp.ChangeUniverse ObjUniverse also.
I am relly frustated now bacuse of this error. :frowning: Can any one suggest me the soluntion.

Thanks
Parag


p_sahasrabudhe (BOB member since 2005-04-22)

It is not necessary to involve the Designer SDK at all. There is essentially a subset of the Designer SDK contained within the Reporter SDK. In other words, there is a busobj.Universe object as well.

Change the Dim statement for ObjUniverse to busobj.Universe. Remove all of the Designer related code, and change the Set ObjUniverse line of code to something like this:

Set ObjUniverse = ObjRep.Universes("universe long name", "repository name (optional)")

{additional note … all of your other duplicate posts have been deleted}


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Hi Dwayne,

Thanks a ton for your valuable suggestions. Just one more query… Set

ObjUniverse = ObjRep.Universes(“universe long name”, “repository name (optional)”) here instead of “Universe long name” is it possible to give universe path. I have temp universe stored on Local PC and I want to try with it.

And what exactly is universe long name ?

Very eagerly awaiting for your reply.
Thanks,
Parag


p_sahasrabudhe (BOB member since 2005-04-22)

It is not possible to reference by the pathname. You may want to use a universe that has not yet been downloaded.

The universe long name is the Name from the Definition tab of the Parameters dialog box. Whenever possible, should try to keep this name unique.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Hi Dwayne,

One more question. :frowning:
Now it is giving me error “Multiple universes specify repository”.
Bascially where does it look for the universe when we give such “Long universe name?”
Is this the folder which we set from BO reporter by doing Tools->options->File Locations tab-> Universes??

If yes from VB, is it possible to change this path?
I have bit complex requirements so bugging you so much, :frowning:

Thanks.
Parag


p_sahasrabudhe (BOB member since 2005-04-22)

I guess it was a bit subtle, but the answers are in my previous posts. First, if you will keep the long name unique, you will not have that problem. If the long name is not unique, you can specify the repository as the second parameter. If the universe has not been exported, the repository is probably “.” …


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Hi Dwayne,

I checked and what ever I said in my earlier post was correct. When ever you give long name of the universe it searches that universe in the directory which is mapped as universe directory i.e. Tools-> options-> documents tab-> universe.
We can change this directory from VB by using objRep.setBOdirectory

Thanks for all your inputs. Will bug you again if I get any more doubts. :slight_smile:

Parag


p_sahasrabudhe (BOB member since 2005-04-22)