Skip to Content
0
Former Member
May 15, 2008 at 03:51 PM

Copy data to company

35 Views

Hello experts,

I am trying to copy data from an object in one company connection to a new object in another company connection. Here is some sample code below. The problem is with the line orBP = ovBP. This copies over the company connection as well, so that I am adding to the original company - not what I want to do. Is there a way to copy all of the BP's info without use of the = operator? Is there some sort of copy function for objects?

I hope this makes sense, let me know if you need more clarification. Thanks in advance for all your help!

Best Regards,

Sarah

//Set the connection context information to the DI API.

//Note: oCompany is the original company that we are connected to

rCompany.Server = "(local)";

rCompany.language = SAPbobsCOM.BoSuppLangs.ln_English;

rCompany.CompanyDB = "XXXXX";

rCompany.UserName = "manager";

rCompany.Password = "manager";

rCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005;

rCompany.UseTrusted = false;

rCompany.DbUserName = "sa";

rCompany.DbPassword = "XXXXX";

//Establish the connection to the company database.

ret = rCompany.Connect();

if (ret != 0)

{

// Display error message

}

else

{

SAPbobsCOM.BusinessPartners ovBP;

SAPbobsCOM.BusinessPartners orBP;

ovBP = (SAPbobsCOM.BusinessPartners)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);// oBusinessPartners);

orBP = (SAPbobsCOM.BusinessPartners)rCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);// oBusinessPartners);

ovBP.GetByKey("1SABTEST-001-L");

orBP = ovBP;

ret = orBP.Add();

}