Description
The following sample shows how to add an invoice (with lines) document to the database. Use this sample as a basis to all business objects of document type (not master data type).
Sub AddInvoice_Click()
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim vInvoice As SAPbobsCOM.Documents
Set vInvoice = vCmp.GetBusinessObject(oInvoices)
vInvoice.Series = 0
vInvoice.CardCode = "BP234"
vInvoice.HandWritten = tNO
vInvoice.PaymentGroupCode = "-1"
vInvoice.DocDate = "21/8/2003"
vInvoice.DocTotal = 264.6
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
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
RetVal = vInvoice.Add
If RetVal <> 0 Then
vCmp.GetLastError ErrCode, ErrMsg
MsgBox ErrCode & " " & ErrMsg
End If
End Sub |