Showing results for 
Search instead for 
Did you mean: 

Update query

Former Member
0 Kudos

Hi All,

When i write update query for system table for UDO table i get mesage as

"Another user modified the table" when i ciick on update button.

Update is not recommended for system and UDO table when i went through the SDK coding standards.

Is there any another option other than wrting the Update query to update the system and UDO table.

Like we have for insert through DI API .

Plz suggets

Quick reply will be helpful

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos


You should never use an insert/update/delete SQL Query for system/UDO tables.

Here is an example taken from DI API help file (c:\Program Files\SAP\SAP Business One SDK\Help\refdi.chm):

The following sample shows how to update a BusinessPartners object in the database. Use this sample as a basis to all business objects of master data type (not document type).

Dim nErr As Long
Dim errMsg As String
Dim vBP As SAPbobsCOM.BusinessPartners
Set vBP = vCompany.GetBusinessObject(oBusinessPartners)

'Get the required record of the current object
If (vBP.GetByKey("HU1001") = True) Then
   'Update the required properties
    vBP.FreeText = "Here's free text"
    Call vBP.Update
End If

'check for errors
Call vCompany.GetLastError(nErr, errMsg)
If (0 <> nErr) Then
    MsgBox ("Found error:" + Str(nErr) + "," + errMsg)
End If



Former Member
0 Kudos

What if i have to do something like this in B1 without using update query

str = "update [@PACK] set U_ALCSTA='" & csta & "',U_ALEDATE='" & Date.Now & "',U_ALETIME='" & Date.Today.TimeOfDay.TotalHours & "' where U_PId='" & pid & "' and U_vid='" & vid & "' and DocNum='" & doc & "'"

Plz suggest

0 Kudos

Then you should do coding similar to this:

Private Sub Add_Data_Click()
    Dim oUserTable As SAPbobsCOM.UserTable
    Set oUserTable = oCompany.UserTables.Item(1)

    dim code as string = here find your existing record code by sql SELECT
    oUserTable.GetByKey (code)

    'Set user field
    oUserTable.UserFields.Fields.Item("U_AlbUDF").Value = "1"

    dim ret as integer = oUserTable.Update

    If ret = 0 Then
        MsgBox "Value to field: '" & oUserTable.UserFields.Fields.Item("U_AlbUDF").Name & _
            "' was updated successfuly to " &     oUserTable.TableName & " Table"
        oCompany.GetLastError ret, Str
        MsgBox Str
    End If
End Sub

Answers (0)