Description
Adds a record to the object table in SAP Business One company database.
Syntax
| Visual Basic |
|---|
Public Function Add() As Long |
Return Type
Returns a result value that indicates success or failure. If the method succeeds, it returns 0. Otherwise, it returns an error code.
You can retrieve the last error code and its description using the method GetLastError.
Remarks
Example
| Adding a sales forecast (C#) | Copy Code |
|---|
SAPbobsCOM.SalesForecast oSalesForecast = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oSalesForecast) As SAPbobsCOM.SalesForecast; string code = "Forecast" + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString(); oSalesForecast.ForecastCode = code; oSalesForecast.ForecastName = code; oSalesForecast.View = SAPbobsCOM.ForecastViewTypeEnum.fvtWeekly; oSalesForecast.ForecastStartDate = New DateTime(2007, 10, 1); oSalesForecast.ForecastEndDate = New DateTime(2007, 10, 28); SAPbobsCOM.SalesForecast_Lines oSalesForecastLine = oSalesForecast.Lines; oSalesForecastLine.ForecastedDay = New DateTime(2007, 10, 1); oSalesForecastLine.ItemNo = "item1"; oSalesForecastLine.Quantity = 5; oSalesForecastLine.Add(); oSalesForecastLine.ForecastedDay = New DateTime(2007, 10, 8); oSalesForecastLine.ItemNo = "item2"; oSalesForecastLine.Quantity = 20; oSalesForecastLine.Add(); oSalesForecastLine.ForecastedDay = New DateTime(2007, 10, 15); oSalesForecastLine.ItemNo = "item1"; oSalesForecastLine.Quantity = 100; globals_Renamed.lRetCode = oSalesForecast.Add(); if (globals_Renamed.lRetCode != 0) { globals_Renamed.oCompany.GetLastError(out lErrCode, out sErrMsg); Interaction.MsgBox(sErrMsg, (Microsoft.VisualBasic.MsgBoxStyle)(0), null); } else { Interaction.MsgBox(code + " has been added", (Microsoft.VisualBasic.MsgBoxStyle)(0), null); }
|
|
Example
See Also