cancel
Showing results for 
Search instead for 
Did you mean: 

Create a UDT via DI API

Former Member
0 Kudos

Hi,

I just finished a small add on for a client and I need to create an installation program rto create the required UDF and UDT.

When, I use that code to create a UDT, it does not work. BTW, I'm using VB6

' Declaration of the variable

Dim oTable As SAPbobsCOM.UserTables

'Initialisation of the Meta object

oTable = oCompany.GetBusinessObject(oUserTables)

' Settings for the table 333

oTable.TableName = "TEST"

oTable.TableDescription = "Unit of Measure"

' Creation of the table

lRetCode = oTable.Add

If lRetCode <> 0 Then

Else

MsgBox ("Table TEST was added correctly")

End If

I don't understand why it does not work. I also tried to replace the second line by

oTable = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables) but without success.

Any idea?

Vincent

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Try using the UserTablesMD class instead of the UserTables one. This is the one used to manage user defined tables.

Be carefull, becouse DI allows only one instance of a these kind of object.

Regards,

Ibai Peñ

Former Member
0 Kudos

Hi,

My new VB 6 code is the following but it still does not work. The error is at the second line. 'Object variable not set'

Any idea now?

Vincent

Dim oUserTableMD As SAPbobsCOM.UserTablesMD

'Initialisation of the Meta object

oUserTableMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)

' Settings for the table 333

oUserTableMD.TableName = "TEST"

oUserTableMD.TableDescription = "Unit of Measure"

' Creation of the table

lRetCode = oUserTableMD.Add

If lRetCode <> 0 Then

Else

MsgBox ("Table TEST was added correctly")

End If

Message was edited by: Vincent MOTTE

Former Member
0 Kudos

hi vincent just a suggestion...

but it is actually a lot easier to save your UDT and UDF to xml files and load them directly when Application Start.

Loading UDT from xml :

dim vFATABLE As SAPbobsCOM.UserTablesMD

vFATABLE = vFACMP.GetBusinessObjectFromXML("XML File Path", 0)

Former Member
0 Kudos

Hi Vincent,

Have you set your oCompany variable to a certain SBO Connection? I suspect this to be a connection reference problem. Are you using UI/DI at the same time or just DI?

cheers,

Oki

Former Member
0 Kudos

I found the problem at line 2, instead of

oUserTableMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)

I had to put

Set oUserTableMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)

Thanks for your help

Vincent