on 04-26-2006 1:30 PM
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?
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Johann,
What is the description of error code -5000? You can get it with oCompany.GetLastErrorDescription.
Adele
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
'...
no solutions?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
87 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.