Showing results for 
Search instead for 
Did you mean: 

About Invoice

Former Member
0 Kudos

Hello to all, I have the following problem, when I try to add an invoice, the following error shows up: -5002 Update quantity to Purchase Order?

some suggestion for correcting the problem?  

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I am a developer and I do not know too much about the business logic underneath SAP Business One.

This sounds as if the invoice you tried to create was linked to an order document. When you tried to add the invoice, the quantity of the item did not match the quantity given in the related order?

Just guessing.

HTH Lutz Morrien

0 Kudos

The error occurs because the last line added to the invoice was an empty line.

When you create a new Documents object, it already has a line on it.  Do not call Document_Lines.Add until you are ready to add the second line. Do not call Document_Lines.Add after the last line has been added to the invoice.


  Set oInvoice = vCmp.GetBusinessObject(oInvoices)

  Set oInvLines = oInvoice.Lines

  oInvoice.CardCode = txtCustCode

  oInvoice.DocDate = Date

  oInvoice.DocDueDate = Date

  'set properties on the first line of the invoice

  oInvLines.ItemCode = "A00001"

  oInvLines.Quantity = 5

  'add an empty line to the invoice, then set properties on it


  oInvLines.ItemCode = "A00002"

  oInvLines.Quantity = 3

  'comment: if you add another line just before you add the invoice, it will cause the error

  retval = oInvoice.Add