cancel
Showing results for 
Search instead for 
Did you mean: 

Cancelling Documents using DI API

Former Member
0 Kudos

Good day,

I am developing a code where I have to cancel a documents using DI API SDK.

I see some documents using the method Cancel and ther others using the method

CreateCancellationDocument.

For Example:

The Sales Orders use the Method: ObjectOrder.Cancel()

The Invoices use the method: ObjectTarget = ObjectInvoice.CreateCancellationDocument()

The Question is, How do i know which documents use the method Cancel or

CreateCancellationDocument?

Thanks and Regard.

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member233854
Active Contributor

It is the same idea when you are using SAP as an user. You don`t need to create a document to cancel an Order, but in order to cancel an invoice, you need to create another document.

Former Member
0 Kudos

Thank you for your answer,

Is there any property that tells me which documents can only be done with the cancel method?

edy_simon
Active Contributor

Hi david,

You will know when you should use each when you get more familiar with SAP
But as a rule of Thumb, most documents that has a journal entry posting will need to use the CreateCancellationDocument.
All of this documents will have a TransId Value in the table.

Regards
Edy

marour
Participant
0 Kudos

Did you find a solution for your Problem? i am facing the same Problem

0 Kudos

Try this,

     SAPbobsCOM.Documents oInvoice;
                            SAPbobsCOM.Documents oCancelI;
                            oInvoice = (SAPbobsCOM.Documents)_oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
                            oCancelI = (SAPbobsCOM.Documents)_oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
                            if (oInvoice.GetByKey(PK) == true)
                            {
                                oCancelI = oInvoice.CreateCancellationDocument();
                                res = oCancelI.Add();
                                if (res != 0)
                                {
                                    _oCompany.GetLastError(out error, out errorDes);
                                }                               
                            }
rajkumar_gupta84
Explorer
0 Kudos

//Create a new Documents object

Documents doc = comp.GetBusinessObject(BoObjectTypes.oDeliveryNotes);

//Get a the document by key which will be cancelled
doc.GetByKey(19);

//Create an object which represent to a new cancellation document based on doc
Documents cancelDoc = doc.CreateCancellationDocument();

//We can modify some values in the cancellation document
cancelDoc.DocDate = new DateTime(2012, 4, 8);

//Then we can add this cancellation document, and at the same time the status of the base document will be changed into ‘canceled’
cancelDoc.Add();

jhou
Explorer
0 Kudos

Not working for Invoice though.

On this code >> Documents cancelDoc = doc.CreateCancellationDocument(), cancelDoc result is NULL.

Really need a working solution on this, can't find any at this point.