📚 SAP Business One SDK Help

Add Method
See Also  Example

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

You must values for the mandatory properties, and then call the Add method. The auto-complete feature completes all the default values of the other properties. In the DI API, the auto-complete feature operates the same way as in the SAP Business One application.

Example

Adding a draft stock transfer (Visual Basic)Copy Code
' Add a draft of stock transfer
Dim draft As SAPbobsCOM.IStockTransfer
draft = oCompany.GetBusinessObject(BoObjectTypes.oStockTransferDraft)

' Draft details
draft.CardCode = "Code1"
draft.Add()
Converting draft stock transfer to stock transfer (Visual Basic)Copy Code
Dim draft As SAPbobsCOM.IStockTransfer

'Convert a draft of stock transfer to a stock transfer
draft = oCompany.GetBusinessObject(BoObjectTypes.oStockTransferDraft)
draft.GetByKey(1)
draft.SaveToFile("C:\Draft.xml")

'********** Manual Action Required: Modify the ObjectCode from 1179 to 65 in "C:\Draft.xml"

Dim oStockTransfer As SAPbobsCOM.StockTransfer
oStockTransfer = oCompany.GetBusinessObject(BoObjectTypes.oStockTransfer)
oStockTransfer.Browser.ReadXml("C:\Draft.xml", 0)
oStockTransfer.Add()

Example

See Also