Adding Special Prices: Date Range Invalid
SeKo
Hi all,in a B1 2007 environment I need to load some special prices which are only valid from a minimum amount. They should become valid immediately and should remain valid until the end of times (or someone changes them manually). If the BP orders less then the minimum amount, he should get the normal prices on his pricelist.
This is the stripped code I use:
sp = (SAPbobsCOM.SpecialPrices) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oSpecialPrices);
sp.AutoUpdate = SAPbobsCOM.BoYesNoEnum.tNO;
sp.CardCode = cardcode;
//sp.Currency = "EUR";
sp.ItemCode = itemcode;
//sp.Price = prijs;
sp.SpecialPricesDataAreas.SetCurrentLine(0);
sp.SpecialPricesDataAreas.DateFrom = new System.DateTime(2001, 1, 1, 0, 0, 0, 0);
//sp.SpecialPricesDataAreas.Dateto = new System.DateTime(2099, 12, 31, 0, 0, 0, 0);
sp.SpecialPricesDataAreas.AutoUpdate = SAPbobsCOM.BoYesNoEnum.tNO;
sp.SpecialPricesDataAreas.SpecialPricesQuantityAreas.PriceCurrency = "EUR";
sp.SpecialPricesDataAreas.SpecialPricesQuantityAreas.SpecialPrice = prijs;
sp.SpecialPricesDataAreas.SpecialPricesQuantityAreas.Quantity = quantity;
sp.SpecialPricesDataAreas.Add();
lretcode = sp.Add();
if (lretcode != 0)
throw new Exception("Error while updating prices: " + oCompany.GetLastErrorDescription());
But I keep getting 'Invalid Date Range', even if I put the dates from 01/08/2011 to 10/08/2011. I checked the www and this forum, but couldn't find an answer..
Anyone here able to help me?
Paolo Manfrin
Hi, if you do the same through the UI do you get the same error?SeKo
Hi Paolo,No, through the UI I can add the special price with these data...
Paolo Manfrin
Hi SeKo,there was another user with the same entry in the SAP Forum.
Here how he solved the issue:
https://forums.sdn.sap.com/thread.jspa?threadID=1726676&tstart=478
hth,
paolo
SeKo
Hi Paolo,thanks for the quick reply!
I've now noticed that the prices are added, even though I get the error message... the return code is -10.
I could just ignore the error, but that would not be very nice
SeKo
I've found the error! I was not resetting the sp object in the right place.Now I reset it like this in the correct place (every time I use a new price):
System.Runtime.InteropServices.Marshal.ReleaseComObject(sp);
sp = null;
sp = (SAPbobsCOM.SpecialPrices) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oSpecialPrices);
0
Please sign in to leave a comment.
Comments
0 comments