API Documents / Add
Add Method


Adds a record to the object table in SAP Business One company database.


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.


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.


The following sample shows how to add an invoice (with lines) document to the database. Use this sample as a basis for all business objects of document type (not master data type).
Invoice Document - Add Method Sample (Visual Basic)
Sub AddInvoice_Click() Dim RetVal As Long Dim ErrCode As Long Dim ErrMsg As String 'Create the Documents object Dim vInvoice As SAPbobsCOM.Documents Set vInvoice = vCmp.GetBusinessObject(oInvoices) 'Set values to the fields vInvoice.Series = 0 vInvoice.CardCode = "BP234" vInvoice.HandWritten = tNO vInvoice.PaymentGroupCode = "-1" vInvoice.DocDate = "21/8/2003" vInvoice.DocTotal = 264.6 'Invoice Lines - Set values to the first line vInvoice.Lines.ItemCode = "A00023" vInvoice.Lines.ItemDescription = "Banana" vInvoice.Lines.PriceAfterVAT = 2.36 vInvoice.Lines.Quantity = 50 vInvoice.Lines.Currency = "Eur" vInvoice.Lines.DiscountPercent = 10 'Invoice Lines - Set values to the second line vInvoice.Lines.Add vInvoice.Lines.ItemCode = " A00033" vInvoice.Lines.ItemDescription = "Orange" vInvoice.Lines.PriceAfterVAT = 118 vInvoice.Lines.Quantity = 1 vInvoice.Lines.Currency = "Eur" vInvoice.Lines.DiscountPercent = 10 'Add the Invoice RetVal = vInvoice.Add 'Check the result If RetVal <> 0 Then vCmp.GetLastError ErrCode, ErrMsg MsgBox ErrCode & " " & ErrMsg End If End Sub

See Also

Related information

Documents Documents Object· Table: OIGE OIGN
Documents is a business object that represents the header data of documents in the Marketing Documents and Receipts module and the Inventory and Production module of SAP Business One application. The source table for each document is according...

SAP® Business One is the trademark(s) or registered trademark(s) of SAP AG in Germany and in several other countries. Contact
This website is not affiliated with, maintained, authorized, endorsed or sponsored by SAP AG or any of its affiliates