cancel
Showing results for 
Search instead for 
Did you mean: 

Insert Data to user defined table

Former Member
0 Kudos

I have created a User defined table called TC_Log with 3 columns Code,Name,U_Message

I need to insert using SDK in C# data to  TC_Log.Code

                                 TC_Log.Name

                                 TC_Log.U_Message

what is the object for this TC_log and how do i fill this table in C# .

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I found this helpful

                

static Integration.Integrator init = new Integration.Integrator();

               oUserTable = init.company.UserTables.Item("TC_Log");

                oUserTable.Code = "Value Code";

                oUserTable.Name = "Value Name";

                oUserTable.UserFields.Fields.Item("U_Message").Value = Message;

                oUserTable.UserFields.Fields.Item("isError").Value = "N";

                oUserTable.UserFields.Fields.Item("Date").Value = DateTime.Now;

                oUserTable.Add();

Answers (2)

Answers (2)

former_member183373
Active Participant
0 Kudos

Hello Assaf,

If your user defined table has a UDO you can use below method.


SAPbobsCOM.Company oCompany;

SAPbobsCOM.CompanyService sCompany;

sCompany = oCompany.GetCompanyService();

oGeneralservice = sCompany.GetGeneralService("UDO_NAME");

oGeneralData = oGeneralservice.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);

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

oGeneralData.SetProperty("Name", "1");

oGeneralData.SetProperty("U_Message", "Test"); 

oGeneralservice.Add(oGeneralData);

Thanks,

Atilla

Former Member
0 Kudos

i think you have missed to define oGeneralservice


what is oGeneralservice?

former_member183373
Active Participant
0 Kudos

Hello Assaf,

You are right I forgot to define General Service object.

Here is the updated version;


SAPbobsCOM.Company oCompany; // Connect this object in another method.


SAPbobsCOM.GeneralService oGeneralService; // Object that provides access to UDO

SAPbobsCOM.CompanyService sCompany;

sCompany = oCompany.GetCompanyService();

oGeneralservice = sCompany.GetGeneralService("UDO_NAME");

oGeneralData = oGeneralservice.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);

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

oGeneralData.SetProperty("Name", "1");

oGeneralData.SetProperty("U_Message", "Test"); 

oGeneralservice.Add(oGeneralData); // Returns the key of the new row

Thanks,

Atilla

Former Member
0 Kudos

I have added your code to main {}

but i am getting Error  :  The name 'oGeneralservice' does not exist in the current context    C

Former Member
0 Kudos

Hi Assaf,

The code SDK to insert data into user defined table :


SAPbobsCOM.UserTable oUserTable;

oUserTable = oCompany.UserTables.Item("TC_Log");

oUserTable.Code = "Value";

oUserTable.Name = "Value";

oUserTable.Add() ;

Hope it helps

Regards,

Mohamed BEGAA.

Former Member
0 Kudos

do you have c# version ? I couldn t locate in sdk help file