cancel
Showing results for 
Search instead for 
Did you mean: 

Creating invoices based on a deliveries based on order

Former Member
0 Kudos

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?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

I am a newbie, so please forgive me if my idea is way off, but I have done a little work with creating invoices this way.

What I do not see in your code is where you set the quantity to 4 or 6 or whatever on the invoice line item. If you don't do this wouldn't the quantity on the invoice have the whole amount (10 in your example)?

If that is the case, then maybe you just can't pull the same delivery line onto another invoice when the quantities are "all used up"?

Again, sorry if I am "out in left field" on this.

Former Member
0 Kudos

The quantity will be set automatically with the connection to the base document.

Former Member
0 Kudos

I found the problem. There was a logic error in the code. At a special situation I add a new line at the beginning of an invoice.

Now it works fine. Thanks to all.

Former Member
0 Kudos

Hi Johann,

What is the description of error code -5000? You can get it with oCompany.GetLastErrorDescription.

Adele

Former Member
0 Kudos

There is no error message...

I tried it with additional quantity and so I got following error message:

code: -5000

msg: "Überlappender E/A-Vorgang wird verarbeitet"

translation: "overlapping i/o-transaction will be processed"

Here is the new code:

'...

Try

boInvoice.Lines.BaseEntry = boDelivery.DocEntry

boInvoice.Lines.BaseLine = boDeliveryLines.LineNum

boInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oDeliveryNotes

'new line

boInvoice.Lines.Quantity = boDeliveryNoteLines.Quantity

Catch ex As Exception

'...

Former Member
0 Kudos

Hi Johann,

Looks the important question is the one Ad ask before:

Do you initialize the invoice object for every new invoice?

Both of your snippets didn´t show it.

Regards,

Ibai Peñ

AdKerremans
Active Contributor
0 Kudos

Hi Johann,

Besides the initialization of your object can you also put sour SBO to english, to have te exact english error message.

Regards

Ad

Former Member
0 Kudos

Yes, I initialize the invoice object every time with following code:

boInvoice = oDataIterface.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)

Former Member
0 Kudos

no solutions?

AdKerremans
Active Contributor
0 Kudos

Hi Johann,

what is the exact error message.

You can retrieve the error message with the GetLastError() method of the company object

If RetVal <> 0 Then

dim errormsg as string

company.GetLastError(retval, errormsg)

msgbox(errormsg)

'error handling...

Return False

End If

Do you initialize the invoice object for every new invoice?

Regards

Ad