Skip to Content
0
Former Member
Nov 03, 2004 at 12:22 PM

DI: Add userfield to usertable

318 Views

I tried to add an userfield to an usertable.

This is my Code:

Public ocompany As SAPbobsCOM.Company

Public errorCode As Long

Public ErrorMsg As String

Public lretcode As Long

Public bp As SAPbobsCOM.BusinessPartners

Public usertable1 As SAPbobsCOM.UserTablesMD

Public userfield As SAPbobsCOM.UserFieldsMD

Private Sub addtablesbtn_Click()

Set usertable1 = ocompany.GetBusinessObject(oUserTables)

Set userfield = ocompany.GetBusinessObject(oUserFields)

'add usertable

usertable1.TableName = "tt1"

usertable1.TableDescription = "test1"

usertable1.Add

'add userfield

userfield.TableName = "tt1"

userfield.Name = "Tf1"

userfield.Description = "Testfield1"

userfield.Type = db_alpha

userfield.Size = 8

lretcode = userfield.Add

If lretcode <> 0 Then

ocompany.GetLastError errorCode, ErrorMsg

MsgBox "Failed to add UserField " & errorCode & " " & ErrorMsg

End If

When trying to add the userfield i get the error:

"Failed to add UserField -1120 The Mete Data for this object cannot be updated, since it's ref count is bigger then 0"

Do Anybody knows whats wrong?