Skip to Content
author's profile photo Former Member
Former Member

Removing attachments from Purchase Order using DIAPI

Dear all,

I have added attachment to PO using DIAPI. I have given below the code.

Dim oAtt As SAPbobsCOM.Attachments2 = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oAttachments2)
Dim FileName As String = ""
Dim SourceFile As String = ""
Dim DestinationFile As String = ""

For i As Integer = 0 To PurchaseOrderInfo.Attachments.Length - 1


FileName = PurchaseOrderInfo.Attachments(i).FileName
SourceFile = PurchaseOrderInfo.Attachments(i).SourcePath & "\" & FileName
DestinationFile = PurchaseOrderInfo.Attachments(i).TargetPath & "\" & FileName


If i > 0 Then oAtt.Lines.Add()
oAtt.Lines.SetCurrentLine(i)
oAtt.Lines.FileName = System.IO.Path.GetFileNameWithoutExtension(FileName)
oAtt.Lines.FileExtension = Replace(System.IO.Path.GetExtension(FileName), ".", "")
oAtt.Lines.SourcePath = PurchaseOrderInfo.Attachments(i).SourcePath

If System.IO.File.Exists(DestinationFile) Then
System.IO.File.Delete(DestinationFile)
End If

If PurchaseOrderInfo.Attachments(i).Override = True Then
oAtt.Lines.Override = SAPbobsCOM.BoYesNoEnum.tYES
Else
oAtt.Lines.Override = SAPbobsCOM.BoYesNoEnum.tNO
End If


Next

Dim iAttEntry As Integer = -1
Dim lResult As Long
Dim lErrCode As Long, sErrMsg As String = ""


lResult = oAtt.Add()

It works fine. But, I am not able to remove an attachment via diapi.

Could you please help me how to solve this.

Thanks in advance.

Manikandan

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Jan 06, 2014 at 04:28 PM

    This space is specifically for BusinessObjects .NET SDK. So, I'm not sure where you need to post your question, but this is not the right place for it.

    -Dell

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 07, 2014 at 03:15 PM

    I am pretty sure you are looking for SAP Business One SDK Topic Space. To ensure you are posting in the correct SCN Space, always check the description for the Space under the Overview tab.

    - Ludek

    Senior Support Engineer AGS Product Support, Global Support Center Canada

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.