Skip to Content

Create Cancellation Document from Invoice through DI API on Excel

Jan 25, 2017 at 08:58 AM


avatar image

Hello you all!

I have an excel with a list of DocEntry from Invoices. This invoices must be cancelled and to do that I used the following code:

vDoc.GetByKey (inv_docentry)

retcode = vDoc.Cancel

This returned the following error: -5006-The requested action is not supported for this object

Then looking through the web I found a similar question in this forum:

And I changed my code to this:

vDoc.GetByKey (inv_docentry)


retcode = vDoc.Add

And now the system return this error: -5002-Ivalid value [OINV.Netproc]]

My Client is on 9.1 PL 8 and my Excel is 2013 version

Any thoughts?

Many Thanks


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

avatar image
Former Member Jan 09 at 04:08 PM

I have this same situation

Do you have any solution for this error ??

10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jan 11 at 10:02 AM


You should store the created cancellation document to another object first and it should be the one to be added.

Please see the code below.

Dim vDoc As SAPbobsCOM.Documents

Dim oCancelDoc As SAPbobsCOM.Documents

Set oCancelDoc = vCmp.GetBusinessObject(oInvoices)

Set vDoc = vCmp.GetBusinessObject(oInvoices)


inv_docentry = Sheet1.Range("A" & row_no1 & "").Value

If inv_docentry = "" Then Exit Sub

GoSub Cancel_Invoice

row_no1 = row_no1 + 1

GoTo Get_Invoice


vDoc.GetByKey (inv_docentry)

Set oCancelDoc = vDoc.CreateCancellationDocument

retcode = oCancelDoc.Add()

If retcode <> 0 Then

vCmp.GetLastError lErrCode, sErr

Msg MsgBox (retcode & " - " & sErrMsg)

End If

10 |10000 characters needed characters left characters exceeded