Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9008

Re: Instructions on how to add attachment to a document through DI API 9.0

$
0
0

Hi Yuval,

I just ran a test on my SBO 9 PL8 using below codes

 

        Private Sub AddTestAttc()            Dim oAtt As SAPbobsCOM.Attachments2 = oCompany.GetBusinessObject(BoObjectTypes.oAttachments2)            Dim FileName As String = "C:\Test.xml"            oAtt.Lines.Add()            oAtt.Lines.FileName = System.IO.Path.GetFileNameWithoutExtension(FileName)            oAtt.Lines.FileExtension = System.IO.Path.GetExtension(FileName).Substring(1)            oAtt.Lines.SourcePath = System.IO.Path.GetDirectoryName(FileName)            oAtt.Lines.Override = SAPbobsCOM.BoYesNoEnum.tYES            FileName = "C:\Test1.xml"            oAtt.Lines.Add()            oAtt.Lines.FileName = System.IO.Path.GetFileNameWithoutExtension(FileName)            oAtt.Lines.FileExtension = System.IO.Path.GetExtension(FileName).Substring(1)            oAtt.Lines.SourcePath = System.IO.Path.GetDirectoryName(FileName)            oAtt.Lines.Override = SAPbobsCOM.BoYesNoEnum.tYES            Dim iAttEntry As Integer = -1            If oAtt.Add() = 0 Then                iAttEntry = oCompany.GetNewObjectKey()            Else                SBO_Application.MessageBox(oCompany.GetLastErrorDescription)            End If        End Sub        Private Sub UpdateTestAttc()            Dim oAtt As SAPbobsCOM.Attachments2 = oCompany.GetBusinessObject(BoObjectTypes.oAttachments2)            oAtt.GetByKey(2)            Dim FileName As String = "C:\Test2.xml"            oAtt.Lines.Add()            oAtt.Lines.FileName = System.IO.Path.GetFileNameWithoutExtension(FileName)            oAtt.Lines.FileExtension = System.IO.Path.GetExtension(FileName).Substring(1)            oAtt.Lines.SourcePath = System.IO.Path.GetDirectoryName(FileName)            oAtt.Lines.Override = SAPbobsCOM.BoYesNoEnum.tYES            FileName = "C:\Test3.xml"            oAtt.Lines.Add()            oAtt.Lines.FileName = System.IO.Path.GetFileNameWithoutExtension(FileName)            oAtt.Lines.FileExtension = System.IO.Path.GetExtension(FileName).Substring(1)            oAtt.Lines.SourcePath = System.IO.Path.GetDirectoryName(FileName)            oAtt.Lines.Override = SAPbobsCOM.BoYesNoEnum.tYES            Dim iAttEntry As Integer = -1            If oAtt.Update = 0 Then                iAttEntry = oCompany.GetNewObjectKey()            End If        End Sub

 

The first method is to add a new attachment with 2 files.

The second method is to update the added attachment with another 2 files.

All working fine.

 

Regards

Edy


Viewing all articles
Browse latest Browse all 9008

Trending Articles



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