cancel
Showing results for 
Search instead for 
Did you mean: 

How to create an Invoice in delivery screen?

Former Member
0 Kudos

Hi everybody.

I am trying to create an invoice in the delivery screen, but i am getting an error "-5002 Invalid total[OINV.DocTotal]". Can anyone tell me how to solve this ?

here is my code

Dim sNewObjCode As String

Dim i As Integer

' Get last added document number (the order that was added)

oCompany.GetNewObjectCode(sNewObjCode)

' this loop adds the different items to the invoice object

i = 0

Do

oInvoice.Lines.BaseEntry = sNewObjCode

oInvoice.Lines.BaseLine = i

oInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders

oInvoice.Lines.TaxCode = TableLines.Rows(i).Item(4)

i += 1

If i <> TableLines.Rows.Count Then

oInvoice.Lines.Add()

End If

Loop Until i = TableLines.Rows.Count

' Try to add the invoice object to the database

lRetCode = oInvoice.Add()

If lRetCode <> 0 Then ' If the addition failed

oCompany.GetLastError(lErrCode, sErrMsg)

MsgBox(lErrCode & " " & sErrMsg) ' Display error message

Else

cmdInvoice.Enabled = True

MsgBox("inv Added to DataBase", MsgBoxStyle.Information, "Order Added")

End If

Thanks

Mina

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Mina,

You have to fill the mandatory fields of the invoice

oInvoice.CardCode = oDelivery.CardCode

oInvoice.DocTotal = oDelivery.DocTotal

oInvoice.HandWritten = tNO

oInvoice.DocDate = oDelivery.DocDate

Regards,

Edwin van Kwikkelberghe

Answers (1)

Answers (1)

Former Member
0 Kudos

I suppose the Invoice amount total is 0 and then SBO doesn´t allow you to add it. The same happens when you create an Invoice using the GUI.

I think you must add the price to the lines.

Regards,

Ibai Peñ