on 2005 Dec 05 9:14 PM
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
Hi Sansanee,
Special Prices functions for a date range. You need a from date and a to date.
In your code you've got a "from date":
sp.SpecialPricesDataAreas.DateFrom = StartDate
But you need a "to date":
sp.SpecialPricesDataAreas.Dateto = EndDate
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Barend,
Thank you for your reply but even if I added this line to add Dateto, it still didn't work.
sp.SpecialPricesDataAreas.Dateto = new System.DateTime(2005,12, 31,0,0,0,0);
It still returned the same error: "Invalid Date Range". Do you happen to know if there is any setting in SBO that specify how many days interval the special prices should be in effect or there is some sort of business rule some where? I am stumped with this problem and would greatly appreciate any help.
Thank you in advance,
Sunny
User | Count |
---|---|
112 | |
8 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.