📚 SAP Business One SDK Help

SaveXML Method
See Also  Example
FileName

Specifies the path and file name of the XML data.

Specifies the path and file name of the XML data.

Description

Saves the object data to XML formatted data.

Syntax

Visual Basic
Public Sub SaveXML( _
   ByRef FileName As String _
) 

Parameters

FileName

Specifies the path and file name of the XML data.

Specifies the path and file name of the XML data.

Remarks

You can use this method to save a business object to an XML file. Then, call the GetBusinessObjectFromXML method to load this object into memory again, for example, to copy customers from one database to another. To enable this operation, set the XmlExportType property of the Company object to xet_ValidNodesOnly.

To use ReadXML method, set the XmlExportType to xet_ExportImportMode (3).

For more information, see Exchanging Data Using the DI API XML Capabilities.

Example

The following sample shows how to save data of an object to an XML file. Use this sample as a basis to all business objects (both document and master data types).
Invoice Document - SaveXML Method Sample (Visual Basic)Copy Code
Dim vInvoice As SAPbobsCOM.Documents
Set vInvoice = vCmp.GetBusinessObject(oInvoices)

'Retrieve an invoice document from the database
RetVal = vInvoice.GetByKey("1023")

If RetVal <> 0 Then
     vCmp.GetLastError ErrCode, ErrMsg
     MsgBox "Failed to Retrieve the record " & ErrCode & " " & ErrMsg
     Exit Sub
End If

'Save the object as an xml file
vInvoice.SaveXML ("C:\Program Files\SAP\XML\Invoice.xml")

'Retrieve the object back from the XML file
Set vInvoice = vCmp.GetBusinessObjectFromXML("C:\Program Files\SAP\XML\Invoice.xml", 0)

See Also