on 07-17-2008 9:30 AM
Hi Dear;
how can I Delete or update Data in a user defined table using the SDK.
regards;
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
that depends on which type of table you are using? is it No Object, Document or Master?
regards,
Binita
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
100 | |
12 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.