on 01-04-2006 10:15 PM - last edited on 02-04-2024 2:44 AM by postmig_api_4
Hi,
I am trying to add Sales Forecast through the DI APIs but I got the error code: -5002 and the error message is "Date not within the forecast period [OFCT
.UserSign][line: 1]". I set myposting period to 2006 as current too so I am very perplexed with the error thrown. My C# Code is below:
SAPbobsCOM.SalesForecast vFCT = (SAPbobsCOM.SalesForecast) company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oSalesForecast);
vFCT.ForecastCode = "F01";
vFCT.ForecastName = "Forecast for First Quarter 2006";
vFCT.ForecastStartDate = new DateTime(2006,1,1,0,0,0,0);
vFCT.ForecastEndDate = new DateTime(2006, 3, 12,0,0,0,0);
vFCT.Lines.ItemNo = "A00001";
vFCT.Lines.Quantity = 200;
vFCT.Lines.Add();
vFCT.Lines.SetCurrentLine(1);
vFCT.Lines.ItemNo = "A00002";
vFCT.Lines.Quantity = 500;
int retVal = vFCT.Add();
int errCode;
string errMsg;
if (0 != retVal){
company.GetLastError(out errCode, out errMsg);
Console.WriteLine(string.Format("Error code: {0}; Error Message: ",errCode, errMsg));
}
else {
Console.WriteLine("Successfully add sales forecast");
}
I would appreciate if anyone can help point me out how i can solve this problem.
Sunny
Hi Sansanee,
Seeing as we are in 2006, make sure your financial period (under Administration-System Init-General Settings-Posting Periods) is set up for 2006.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sansanee
The reason it is not working is that for the lines you haven't specified the date....remember you need to set the quantities for certain months/days. Also the date format you are using for start and end.....not sure if sap likes that format.
here is a sample in vb.net, it works on my side
Dim SalesForecast As SAPbobsCOM.SalesForecast
SalesForecast = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oSalesForecast)
SalesForecast.ForecastCode = "SDK"
SalesForecast.ForecastName = "Testing"
SalesForecast.ForecastStartDate = "2006/01/01"
SalesForecast.ForecastEndDate = "2006/12/01"
SalesForecast.Lines.ItemNo = "138391"
SalesForecast.Lines.ForecastedDay = "2006/01/01"
SalesForecast.Lines.Quantity = 1
lRetCode = SalesForecast.Add()
If lRetCode <> 0 Then
oCompany.GetLastError(lRetCode, sErrMsg)
MsgBox(sErrMsg)
End If
hope this helps
User | Count |
---|---|
104 | |
12 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.