Skip to Content
0
Former Member
Jul 01, 2005 at 11:47 AM

updating user table (type document) via api

313 Views

hi!

i need to update an user table that is of type document.

that table is also used as the client table in an udo.

i have tried the following code, but that of course doesn't work as the table is not a plain table but is of document type:

  Dim objUserTable As SAPbobsCOM.UserTable
  Set objUserTable = objCom.UserTables.Item("MP_TABLE_LINE")
  If objUserTable.GetByKey(objMatrix.Columns.Item("U_MP_BEnt").Cells.Item(lngRow).Specific.Value) Then

      objUserTable.UserFields.Fields.Item("U_Qty").Value = _
      	objUserTable.UserFields.Fields.Item("U_Qty").Value - dblDiff

      If Not objUserTable.Update() <> 0 Then
          Call objApp.SetStatusBarMessage(objCom.GetLastErrorDescription())
          Call objApp.MessageBox(objCom.GetLastErrorDescription())
      Else
          objMatrix.Columns.Item("U_MP_BQty").Cells.Item(lngRow).Specific.String = _
          	objMatrix.Columns.Item("11").Cells.Item(lngRow).Specific.String
      End If
  End If
  Set objUserTable = Nothing

then i tried to use a dbdatasource which i would expect to work:

  Dim objDataSource As DBDataSource
  Set objDataSource = objForm.DataSources.DBDataSources.Item("@MP_TABLE_LINE")
  
  Dim objConditions As New SAPbouiCOM.Conditions
  Dim objCond As SAPbouiCOM.Condition
  
  <just setting up conditions here>
  
  Call objDataSource.Query(objConditions)
  Call objDataSource.SetValue("U_Qty", 0, objDataSource.GetValue("U_Qty", 0) - dblDiff)

but this only results in an error code "-7006", message:

"Item - The item is not a user defined item"

how can the update be done?

regards,

thomas