Skip to Content
0
Former Member
Dec 05, 2005 at 09:14 PM

Adding SpecialPrices return DateRange Invalid

172 Views

Hi,

I am trying to programmatically add SpecialPrices and I got the error "Date Range Invalid" error. Below is my code:

SAPbobsCOM.SpecialPrices sp = (SAPbobsCOM.SpecialPrices) conn.InternalConnection.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oSpecialPrices);

sp.AutoUpdate = SAPbobsCOM.BoYesNoEnum.tYES;

sp.CardCode = "1903";

sp.ItemCode = "T123";

sp.Price = 58;

sp.PriceListNum = 1;

sp.SpecialPricesDataAreas.SetCurrentLine(0);

sp.SpecialPricesDataAreas.AutoUpdate = SAPbobsCOM.BoYesNoEnum.tYES;

sp.SpecialPricesDataAreas.Discount = 15;

sp.SpecialPricesDataAreas.PriceCurrency ="USD";

sp.SpecialPricesDataAreas.PriceListNo = 1;

sp.SpecialPricesDataAreas.SpecialPrice = 55;

sp.SpecialPricesDataAreas.DateFrom = new System.DateTime(2005,11,1,0,0,0,0);

sp.SpecialPricesDataAreas.Add();

sp.SpecialPricesDataAreas.SpecialPricesQuantityAreas.Discountin = 14;

sp.SpecialPricesDataAreas.SpecialPricesQuantityAreas.PriceCurrency ="USD";

sp.SpecialPricesDataAreas.SpecialPricesQuantityAreas.Quantity = 10;

sp.SpecialPricesDataAreas.SpecialPricesQuantityAreas.SpecialPrice = 54;

sp.SpecialPricesDataAreas.SpecialPricesQuantityAreas.Add();

int retval = sp.Add();

int errCode;

string errMsg;

if(0!=retval){

conn.InternalConnection.GetLastError(out errCode, out errMsg);

Console.WriteLine(errMsg);

}

else{

Console.WriteLine("Adding special price successfully");

}

Thank you in advance.

Sunny

Message was edited by: sansanee hanveerawong