cancel
Showing results for 
Search instead for 
Did you mean: 

Update User Defined Table

Former Member
0 Kudos

Hi Dear;

how can I Delete or update Data in a user defined table using the SDK.

regards;

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hi

Look these code.

Note: donn't use @ before user defined table name.

1) Delete record.


try
  oForm.Freeze(True)

  Dim oUserTable As SAPbobsCOM.UserTable
  oUserTable = SBO_Company.UserTables.Item("YOUR_USER_TABLE_NAME_HERE")

  Dim oEdit As SAPbouiCOM.EditText
  oEdit = oForm.Items.Item("uCode").Specific
  Dim sValue As String = oEdit.Value

  If oUserTable.GetByKey(sValue.Trim) Then
    ' DELETE RECORD FROM USER DEF. TABLE
    oUserTable.Remove()
    oUserTable = Nothing
  End If
catch ex As Exception
  ' log exception
finaly
  oForm.Freeze(False)
end try

2) Add / Update


Dim oUserTable As SAPbobsCOM.UserTable
oUserTable = SBO_Company.UserTables.Item("YOUR_USER_TABLE_NAME_HERE")
Dim iRet As Integer = 0
Try
  ' Transaction Begin
  SBO_Company.StartTransaction()
  If oUserTable.GetByKey(sCode) Then
      ' UPDATE RECORD
      oUserTable.Name = sName
      oUserTable.UserFields.Fields.Item("U_Field").Value = sFieldValue
      ' other fields
      iRet = oUserTable.Update()
  Else
      ' ADD RECORD
      oUserTable.Code = sCode
      oUserTable.Name = sName
      oUserTable.UserFields.Fields.Item("U_Field").Value = sFieldValue
      ' other fields
      iRet = oUserTable.Add()
  End If
Catch ex As Exception
  ' Transaction Rollback
  If SBO_Company.InTransaction Then SBO_Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)
  ' log exception
Finally
  ' Transaction End
  If SBO_Company.InTransaction Then SBO_Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit)
  oUserTable = Nothing
End Try

Hope its help you.

BR

Sierdnas

Edited by: Sierdna S on Jul 17, 2008 12:16 PM

Former Member
0 Kudos

Sierdna,

I'm trying to update a Document Row. What should I use as the record code?

Regards,

Vítor Vieira

Answers (1)

Answers (1)

Former Member
0 Kudos

that depends on which type of table you are using? is it No Object, Document or Master?

regards,

Binita