cancel
Showing results for 
Search instead for 
Did you mean: 

How to close any documents by di api

Former Member
0 Kudos

Hello guys, ¿How to close a Purchase Request by di api? Thanks for your understanding and support. Regards, DR

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Douglas,

this is the code that I use a document throught the DI API :

    Dim RetVal As Long

    Dim ErrCode As Long

    Dim ErrMsg As String

    Dim vOrder As SAPbobsCOM.Documents

    Set vOrder = vCmp.GetBusinessObject(oOrders)

    'Retrieve the document record to close from the database

    RetVal = vOrder.GetByKey(DocEntry)

    If RetVal <> 0 Then

        vCmp.GetLastError ErrCode, ErrMsg

        MsgBox "Failed to Retrieve the record " & ErrCode & " " & ErrMsg

            Exit Sub

    End If

    'Close the record

    RetVal = vOrder.Close

    If RetVal <> 0 Then

        vCmp.GetLastError ErrCode, ErrMsg

        MsgBox "Failed to Close the document" & ErrCode & " " & ErrMsg

    End If

End Sub

Former Member
0 Kudos

Hi, thank you, for your answer, but i have a question , and is, where I specify the number of document, that I want to close.

former_member185682
Active Contributor
0 Kudos

Hi Douglas,

As pointed in your sample, the document that you load in the vOrder.GetByKey(DocEntry) will be the document that you needs close. DocEntry is the key of your document.

Regards,

Diego

Former Member
0 Kudos

Hi Douglas,


You can not mentioned number of documents  you need  to close, but by the help of DocEntry you can close any document that you open recently.


regards

Mahak

Former Member
0 Kudos

Ok , I'm clear with that, but as I open a document using di api ? I do not understand that part, because I need to close a specific document . Thank you for your help,

former_member185682
Active Contributor
0 Kudos

Hi Douglas,

What are you mean with "as I open a document using di api"?

If you need change a document status to open, I think it is not possible.

If you need load a document with status open, you need know the docEntry for this document and load this with GetByKey method in Document Object.

Regards,

Diego

Former Member
0 Kudos

Ok , I know the docentry the document, I want to close , the problem is that is of type int, and Boolean type is GetByKey . And send an error I'm working on c #

former_member185682
Active Contributor
0 Kudos

I think I understood your doubt, I will try explain better

When you call Document.GetByKey(DocEntry) you need pass an integer as parameter, if your document was found, the method GetByKey returns a true and the data of your document will be loaded in Document object.

A sample (Suppose that you need get an order that has DocEntry equals 68):

Document doc = oCompany.GetBusinessObject(oOrders)

if(doc.GetByKey(68))

{

     //The document was found, then the doc object has all properties of your document that you need closes

     //Now, you can put your logic here

}

else

{

     //The document not found

}

Hope it helps,

Regards,

Diego

Former Member
0 Kudos

Thanks , sorry , I was just ignoring the .close () command; the document already closed . thank you

Answers (0)