Adding new record in user table via Dynamic Code

David Bordones

Hi there, 

 

I created in SAP B1 two user tables (Master data and master data rows). I'd like to add a new header record in my master data user table via Dinamic Code (SDK).


 This is my source code: 

C#:

SAPbobsCOM.Company oCompany;
SAPbobsCOM.UserTable oUserTable;
oUserTable = (SAPbobsCOM.UserTable)company.UserTables.Item("My_Table");

oUserTable.Code = "1";
oUserTable.Name = "test";
oUserTable.Add() ;

but I have an exception error message: "SAP B1 Cannot add rows to a MasterData type UserTable"

 

I tryied another script using VB.Net

Dim oGeneralService As SAPbobsCOM.GeneralService

Dim oGeneralData As SAPbobsCOM.GeneralData

Dim CompService As SAPbobsCOM.CompanyService = Company.GetCompanyService()

 

oGeneralService = CompService.GetGeneralService("My_Table")

oGeneralData = oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)  

oGeneralData.SetProperty("Code","1")

oGeneralService.Add(oGeneralData)

 

However, I got another error message: Exception has been thrown by the target of an invocation. - Service Not Found

 

Do you know if its possible to add lines in UDT? 

 

Kind Regards,

David

 

Comments

2 comments

Please sign in to leave a comment.