Adding new record in user table via DI API
Emanuele Croci
Dear all,
I created in SAP B1 two user tables (Master data and master data rows)
I need to add a new header record in my master data user table by DI code.
This is my source code...
...
Dim sboDestTable As SAPbobsCOM.UserTable = oCompany.UserTables.Item("MY_HEAD_TABLE")
sboDestTable.Code = newCode
sboDestTable.ArchiveDate = Now
sboDestTable.UserFields.Fields.Item("u_userfield1").Value = "new value 1"
Dim ErrCode As Integer = sboDestTable.Add()
...
...
but I have an exception error message on the Add() command: "SAP B1 Cannot add rows to a MasterData type UserTable"
Can someone help me, please?
How can I add a new record in a user master data table?
Best regards
Emanuele
Emanuele Croci
Dear all,
I solved in this way:
Dim oGeneralService As SAPbobsCOM.GeneralService
Dim oGeneralData As SAPbobsCOM.GeneralData
Dim oCompService As SAPbobsCOM.CompanyService = oCompany.GetCompanyService()
oGeneralService = oCompService.GetGeneralService("MY_UDO")
oGeneralData = oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)
oGeneralData.SetProperty("Code",new_code)
...
...
oGeneralService.Add(oGeneralData)
It also works on SAP B1 9.0 PL 08 with my UDO composed by a Master Data user table and a master data row user table.
Best regards
Emanuele
see also on
Please sign in to leave a comment.
Comments
0 comments