Quantcast
Channel: SCN : Unanswered Discussions - BI Platform
Viewing all articles
Browse latest Browse all 5661

Removing attachments from Purchase Order using DIAPI

$
0
0

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


Viewing all articles
Browse latest Browse all 5661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>