Skip to Content
author's profile photo Former Member
Former Member

How to create an Invoice in delivery screen?

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 16, 2004 at 09:12 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 22, 2004 at 12:22 PM

    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ñ

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.