Hi,
I am having problem creating a business partner with both mail to and bill to address. I want to create two instances (lines) in BPAddresses; one with mial to address and another with bioll to address. But I still get the error code -5002 with the message "Address is empty [OCRD: CardCode} line:1"
Below is my code in C#:
SAPbobsCOM.BusinessPartners bp = (SAPbobsCOM.BusinessPartners) conn.InternalConnection.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);
bp.CardName = "Test Tester";
bp.CardType = SAPbobsCOM.BoCardTypes.cCustomer;
bp.CardCode = "TEST29";
bp.Address = "1305 Blue Raven Blvd";
bp.City = "Citrus Height";
bp.Country = "US";
bp.BillToState = "CA";
bp.ContactPerson = "Peter Snicker";
bp.Currency = "USD";
bp.ZipCode ="94521";
string errMsg;
int errCode;
int returnval = bp.Add();
if(0 != returnval){
conn.InternalConnection.GetLastError(out errCode, out errMsg);
Console.WriteLine(errMsg);
return;
}
string cardCode;
conn.InternalConnection.GetNewObjectCode(out cardCode);
//Console.WriteLine("Added BP successfully",cardCode);
bp.GetByKey(cardCode);
bp.Addresses.Add();
bp.Addresses.SetCurrentLine(1);
bp.Addresses.AddressType = SAPbobsCOM.BoAddressType.bo_ShipTo;
returnval = bp.Update();
if(0 != returnval){
conn.InternalConnection.GetLastError(out errCode, out errMsg);
Console.WriteLine(errMsg);
return;
}
I would appreciate if anyone can help me with this problem.
Thank you in advance,
Sunny