BusinessObjects Board

Add Table using Universe Designer SDK

How does one add tables to an existing universe using COM designer SDK. I have tried:

objUniverse.Tables.Add (strTable_Name)

but get “Cannot create Table” error.


Keith Crump (BOB member since 2002-08-15)

Hello Keith, good to hear from you again!

On the surface, your code looks fine. A couple of thoughts, the first of which I suspect you are already taking care of. Because that .Add method creates an object, you’ll need one of the following syntaxes:

Dim Tbl as busobj.Table
Set Tbl = objUniverse.Tables.Add(strTable_Name)

or

Call objUniverse.Tables.Add(strTable_Name)

Assuming that’s not the issue, I suspect it’s how your strTable_Name is formatted. When you add a table manually in Designer, is the owner required? If so, you’ll need to include owner in the strTable_Name. Depending on which RDBMS, somethings quote marks are needed. Something on those lines.


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

Another thing to note about this topic is that in some instances, the case of your table name may need to match the case of the original table in the database. I learned this to be the “case” the hard way.


Sytrus (BOB member since 2007-10-04)

That problem will also happen if the table you’re trying to create has the same name as a table you’ve already created. If so, you can just add a number to the end. If that isn’t the problem, try adding Double quotes around it. In VB.NET I use:

Private Function CreateTable(ByVal Universe As Designer.Universe, ByVal TableName As String, ByRef X As Integer, ByRef Y As Integer, ByVal Derived As Boolean, Optional ByVal TableDesc As String = "") As Designer.Table
            Dim NewTable As Designer.Table
            Try
                NewTable = Universe.Tables.Add(TableName.ToUpper))
                TableDesc = """" & TableDesc.Trim("""") & """")
                NewTable = Universe.Tables.Item(NewTable.Name).CreateAlias(TableDesc))
            Catch ex As Exception
                Dim Temp As Integer
                Temp = 2
                While True
                    Try
                        NewTable = Universe.Tables.Item(TableName).CreateAlias("""" & TableDesc & "_" & Temp & """"))
                        Exit While
                    Catch ex2 As Exception
                        Temp += 1
                    End Try
                End While
            End Try
            Return NewTable
        End Using
    End Function

That would try to create the table and an alias for it, and if unsuccessful, would try to create just an alias with a number after it. Hopefully this helps you a little.


Sivvy (BOB member since 2009-02-19)

Hi all,
Thanks for your help.
I’m using VB.NET too.

When i try to add a new table in an empty universe
Universe.Tables.Add(table_name)
I actually do have the new table created in the universe but the table is blank: no column in it.
Why do i get an empty table? Is this Tables.add supposed to brings up all the columns with it or am i supposed to add each column?

Is there a way to add a table (by its name) from the database (that would brings up all its columns and everything) ?
Just like when you insert a table in the Designer basically.

If anyone has a code sample to show an exemple, that would help a lot :wink:


ceka (BOB member since 2009-02-23)

I had the same problem… All I did was loop all my tables in with the correct names, and then used

ObjUniverse.RefreshStructure()

AFTER they were all in there. I emphasize AFTER because the refresh is SLOW. Don’t put the Refresh in the loop.

If you want to automate the actual universe pane afterwards, just use

ObjUniverse.Tables.Item("Table'sExactName").CreateClass("Class'sNewName")

Sivvy (BOB member since 2009-02-19)

Thanks Sivvy

The ObjUniverse.RefreshStructure() worked fine!!
Thx :wink:


ceka (BOB member since 2009-02-23)

Can you please let me how to add Joins between tables & Class Object in Univers using Designer SDK.


2732829 (BOB member since 2009-03-06)

Check that topic

Good luck


ceka (BOB member since 2009-02-23)

Thanks, but I already go through this link and there is no code to ADD Object in Universe using Desinger Universe SDK.

Please help me if you have idea about this.


2732829 (BOB member since 2009-03-06)

Basically that would go like

Dim Cls As Designer.Class
Dim Obj As Designer.Object

Set Cls = Univ.Classes.Add("Classe Name")
'or Set Cls = Univ.Classes.FindClass("Classe Name") if class already exists
Cls.Description = "blabla"
etc ...

Set Obj = Cls.Objects.Add("ObjectName")
Obj.Type = dsNumericVariable
Obj.Description = "desc"
Obj.Select = "TABLE.COL"

ceka (BOB member since 2009-02-23)

Something similar that actually extracts the objects from the table columns:

Dim Cls As Designer.Class
Dim myTableName As String = "ExampleTable"

Univ.Tables.Add(myTableName)
Univ.RefreshStructure()

Set Cls = Univ.Tables.Item(myTableName).Classes.Add("Class Name")

If “myTableName” actually exists in the database, this would add the table, populate the columns, then create a class with all the columns in it as objects.


Sivvy (BOB member since 2009-02-19)

Hi,

Can you please let me how can I create “Filter” in Universe through Designer SDK.


2732829 (BOB member since 2009-03-06)

I want to insert Tables Joins Using Desinger Universe SDK. And If I have Alias table the how can we do using Desinger Universe SDK?


2732829 (BOB member since 2009-03-06)

Call Univ.Joins.Add("syntax of join") 'including alias if you like

Also, I removed your duplicate post from the BOB’s Downloads topic.


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

Hi Dwayne,

Thanks for your reply. I already used “Univ.Joins.Add(Join Condition)” text for this is not working for Alias tables And second this statement show correct join Expression but its selected all field for second table.

Please let me if you have solution for this issue.


2732829 (BOB member since 2009-03-06)

I don’t know what to say, it works for me … including fields from aliased tables.

Here is something to try. Create the join manually. Copy the join syntax into Notepad or something, and close the universe without saving it. Now use that EXACT same join syntax in your VBA code. It HAS to work.


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

Have you made sure to include double quotes on re-named tables? One of the first problems I ran into was the double quotes.


Sivvy (BOB member since 2009-02-19)

Hi,

How can I create new universe with new connection through Designer Universe SDK.


2732829 (BOB member since 2009-03-06)

Take a look at the Designer SDK documentation, because both the .Universes and .Connections collections have a .Add method. The bigger question is why you would want to do this? Creating universes and connections are a one-time activity, so I’m not sure what value automation has … at least from a best practice approach.


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