cancel
Showing results for 
Search instead for 
Did you mean: 

Usert Tabla type document

Former Member
0 Kudos

i create a tableuser document type in the SBO,with the fields "code","name" for example

what i want is add values,then read it and finally

delete all the values

someone know how to do this thnxs

Dim vUserTables As SAPbobsCOM.UserTablesMD

Set vUserTables = vCompany.UserTables.item("TEMP")

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Miguel,

The UserTablesMD object is used for creating and maintaining the table structure. It is not used for maintaining data within the table. For this purpose the UserTable object is used. Herewith example code of how to insert, read and delete from a UserTable

        'insert
        Dim vUserTable As SAPbobsCOM.UserTable
        vUserTable = oCompany.UserTables.Item("TEMP")
        vUserTable.Code = "1"
        vUserTable.Name = "Item 1"
        vUserTable.UserFields.Fields.Item("U_Field1").Value = "Value 1"
        vUserTable.UserFields.Fields.Item("U_Field2").Value = "Value 2"
        If vUserTable.Add <> 0 Then
            MessageBox.Show("Error: " & oCompany.GetLastErrorDescription)
        End If

        'read
        vUserTable = oCompany.UserTables.Item("TEMP")
        vUserTable.GetByKey("1")
        MessageBox.Show(vUserTable.Name)

        'delete
        vUserTable = oCompany.UserTables.Item("TEMP")
        vUserTable.GetByKey("1")
        If vUserTable.Remove <> 0 Then
            MessageBox.Show("Error: " & oCompany.GetLastErrorDescription)
        End If

Hope it helps,

Adele