Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Creating invoices based on a deliveries based on order

I have to create an addon to create automatically invoices from open deliveries.

System: SBO 2004A, PL 43

Example:

I have an order with one line (itemcode=test, quantity=10,...).

Then I create manually two deliveries from this order.

delivery 1: itemcode=test, quantity=6

delivery 2: itemcode=test, quantity=4

Following is a part of the code for creating one invoice:

-


'more code...

For ax = 0 To boDelivery.Lines.Count - 1

'Add new line if neccessary

If ax > 0 Then

boInvoice.Lines.Add()

End If

' set current line of delivery

boDelivery.Lines.SetCurrentLine(ax)

Try

boInvoice.Lines.BaseEntry = boDelivery.DocEntry

boInvoice.Lines.BaseLine = boDeliveryLines.LineNum

boInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oDeliveryNotes

Catch ex As Exception

'error handling...

Return False

End Try

Next

'more code...

'add invoice

RetVal = boInvoice.Add()

If RetVal <> 0 Then

'error handling...

Return False

End If

-


For the first delivery it works well but the the second delivery return error -5000, when I add the invoice.

What is the reason?

Not what you were looking for? View more on this topic or Ask a question