cancel
Showing results for 
Search instead for 
Did you mean: 

Generate to XML file from a SBO system form ....

Former Member
0 Kudos

Hi gurus,

If I remember right, a standard form (ex:A/R invoice, A/P invoice ...) in the SBO system, we can ganerate to XML file. But I don't remember how to do it, anybody know about it, pls help me, tell me ... pls. Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Andy,

The answer of your question could be found in SAP samples, UI API sample 4.(default path C:\Program Files\SAP\SAP Business One SDK\Samples\COM UI\VB6\04.WorkingWithXML)

The code is below.

There are lots of samples delivered with SDK, and I think you would benefit a lot from them.

HTH,

Nick

Private Sub SaveAsXML(Form As SAPbouiCOM.Form)
'// Add a reference to "Microsoft XML, v3.0"

    Dim oXMLDoc As MSXML2.DOMDocument
    Dim sXMLString As String
    
    Set oXMLDoc = New MSXML2.DOMDocument
    
    '// get the form as an XML string
    sXMLString = Form.GetAsXML
    
    '// load the form's XML string to the
    '// XML document object
    oXMLDoc.loadXML (sXMLString)
    
    '// save the XML Document
    Dim sPath As String
    sPath = CurDir
    oXMLDoc.save (sPath & "MySimpleForm.xml")

End Sub

Answers (1)

Answers (1)

former_member184566
Active Contributor
0 Kudos

Hi Andy

Most Business Objects on the header have the property SAVEXML. So just do your object declaring, use getby key to get the exact document/record and the savexml to get it to xml. The below is all you need to make an xml file for an invoice with the doc number 3141.

Dim oInvoice As SAPbobsCOM.Documents

oInvoice = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)

If oInvoice.GetByKey("3141") Then oInvoice.SaveXML("c:\Test.xml")

Hope this helps

Former Member
0 Kudos

Hi Louis,

Thank you but I mean XML file to build a form as AR Invoice form or ..., not an invoice document.

Former Member
0 Kudos

Hi Andy,

Then you should use the Form object´s GetAsXML method, which returns the XML representation of the form as a string.

Regards,

Ibai Peñ

Former Member
0 Kudos

Just some points that I have noticed on using the SaveXML by use of business objects... If you go through a business objects SaveXML / SaveToFile methods it will only save the FIRST returned dataset... So for example if you use the Production Order business object you will only get back the first (or first Queried) row of data from the OWOR table and the related data in the WOR1 table... If you want all the data from both tables you will need to use a Recordset object and query all the required data from the tables that you want then save the recordset to a XML file...