Skip to Content

Create Cancellation Document from Invoice through DI API on Excel

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:

https://archive.sap.com/discussions/thread/3852956

And I changed my code to this:

vDoc.GetByKey (inv_docentry)

vDoc.CreateCancellationDocument

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

K.R

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

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 ??

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 11 at 10:02 AM

    Hello,

    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)

    Get_Invoice:

    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

    Cancel_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

    Add comment
    10|10000 characters needed characters exceeded