Skip to Content
0
Former Member
Mar 11, 2009 at 03:46 AM

Adding record on UDT with UDO

226 Views

Hi All,

I have this AddOn, which im using a UDT and registered it in UDO. My UDT's object type is MasterData.

On the saving part, i wasnt able to add a record and keep on getting this error: "Master Data Type UserTable can not add row" please tell me why..

'i have this code on the saving part:

Private Sub AddProdHierarchyToDatabase()

Dim ut As SAPbobsCOM.UserTable

Dim uts As SAPbobsCOM.UserTables

Dim rs As SAPbobsCOM.Recordset

Dim sql As String = String.Empty

Dim lastCode As Integer

Try

'get last code

rs = _company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

sql = "Select COUNT(Code) As LastCode From dbo.[@SMC_ProdHierarchy]"

rs.DoQuery(sql)

lastCode = rs.Fields.Item("LastCode").Value + 1

uts = _company.UserTables

ut = uts.Item("SMC_ProdHierarchy")

ut.Code = lastCode

ut.Name = "6"

ut.UserFields.Fields.Item("U_lookupCode").Value = Module1.HierarchyCode

ut.Add()

ut.Update()

Catch ex As Exception

End Try

End Sub

-Roger