cancel
Showing results for 
Search instead for 
Did you mean: 

Creating A/R Invoice (Error -5002)

Former Member
0 Kudos

Hi all,

Does anyone know why this code would throw the "- 5002 Invalid total [OINV.Address]" error? Any ideas?

Here is my code, and datas:

[code]Dim ReturnValue As Long

Dim ErrCode As Long

Dim ErrMsg$ = ""

Dim vInvoice As SAPbobsCOM.Documents

Dim iLine As Long

vInvoice = vCompany.GetBusinessObject(MyObjectType)

'MyObjectType = 13

vInvoice.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items

vInvoice.CardCode = MyCardCode$

'MyCardCode = Is an existing BP's code

vInvoice.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO

vInvoice.DocDueDate = MyDocDueDate

'MyDocDueDate = #5/9/2006#

vInvoice.DocDate = MyDocDate

'MyDocDate = #5/9/2006#

vInvoice.TaxDate = MyDocDate

'MyDocDate = #5/9/2006#

vInvoice.VatDate = MyDocDate

'MyDocDate = #5/9/2006#

For iLine = 1 To MyLineNr

If iLine > 1 Then

vInvoice.Lines.Add()

End If

vInvoice.Lines.ItemCode = MyItemCode$(iLine - 1)

'MyItemCode = Is an existing item code

vInvoice.Lines.Quantity = MyQuatity(iLine - 1)

'MyQuantity 1 = 1

'MyQuantity 2 = 1

vInvoice.Lines.Price = MyPrice(iLine - 1)

'MyPrice 1 = -100

'MyPrice 2 = 300

vInvoice.Lines.VatGroup = MyVatGroup$(iLine - 1)

'MyVatGroup = Is an existing VAT group

Next iLine

ReturnValue = vInvoice.Add

[/code]

Thanks the help.

Accepted Solutions (0)

Answers (2)

Answers (2)

jaccomoolenaar
Participant
0 Kudos

Hi,

I have had some problems in the past with casesensitivity of the cardcode. Could it be that the cardcode differs by case?

Regards,

Jacco

Former Member
0 Kudos

Hi,

thanks the answers. The problem is that if you record sales invoice which has a minus price line, but the total of invoice is positiv. I try to record it manually, and it's worked, but the SDK (DI API) did not like it.

jaccomoolenaar
Participant
0 Kudos

Hi,

What's the value of MyLineNr?

Regards,

Jacco

Former Member
0 Kudos

MyLineNr value is 2 (2 is a number of invoice lines)

former_member687054
Participant
0 Kudos

Hi,

The error message is strange

"- 5002 Invalid total "

invalid total with address ref. Anyway. I had I problem with the creation of invoice and I solve my problem when I tried with a different Business Partner (the source of error was a setting of my BP), may be you can try that.

HTH

Jodércik