cancel
Showing results for 
Search instead for 
Did you mean: 

DI - Export/Import JournalEntries to XML

Former Member
0 Kudos

Hi,

I want to export all JournalEntries, with their JournalEntries_Lines, using SaveXML, and them import, loading the XML file, using the Company GetBusinessObjectFromXML function.

To export just one, I use

Dim oJE As SAPbobsCOM.JournalEntries

oJE = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries)

If oJE.GetByKey(23) Then

oCA.SaveXML("c:MyJE23.xml")

End If

but, how to export all? I tried with a recordset but it saves a XML file that after doesn´t work with the GetBusinessObjectFromXML function.

What is the XML format to import several JournalEntries with their JournalEntries_Lines, using GetBusinessObjectFromXML, or the JournalEntries.Browser.ReadXml method? Or, if there is another way to do that?

Could someone help me?

Thanks a lot,

Ribeiro Santos

Accepted Solutions (1)

Accepted Solutions (1)

former_member185703
Active Contributor
0 Kudos

Hi,

There's no option to export more than one object at a time; you will have to handle it by yourself:

1) Export each object separately

<?xml version="1.0" encoding="UTF-16"?>

<BOM>

<BO>

.... here are the data of a single Business Object...

</BO>

</BOM>

2) Add them to one XML that is structured like this:

<?xml version="1.0" encoding="UTF-16"?>

<BOM>

<BO>

.... here comes the first Business Object...

</BO>

<BO>

.... here comes the second Business Object...

</BO>

</BOM>

3) For import you can use both: GetBusinessObjectFromXML or GetBusinessObject + afterwards use .Browser.ReadXML.

In both cases you should use exception handling (in case there are errors in the XML) + you will have to call "Add" and determine whether or not it succeeded.

Please note that there has been a post ("DI: Import XML") regarding the XmlExportType property of the Company object that is also featured in the developer area...

HTH,

Frank

Former Member
0 Kudos

Hi,

My problem is with the JournalEntries_Lines of the JournalEntries, what is the XML structure?

I tried

<?xml version="1.0" encoding="UTF-16"?>

<BOM>

<BO>

<JournalEntries><row> .... </row> </Journal_Entries>

<Journal_Entries_Lines><row> .... </row> </Journal_Entries_Lines>

<JournalEntries><row> .... </row> </Journal_Entries>

<Journal_Entries_Lines><row> .... </row> </Journal_Entries_Lines>

</BO>

</BOM>

but it gives an error when call oJE = oCompany.GetBusinessObjectFromXML(xmlfile, 0)

Additional information: <ErrorList><Error>System Id = 144621288, Line Number = 1, Column Number = 387, Description = Type not found in http://www.w3.org/2001/XMLSchema:ERROR</Error><Error>System Id = 144621288, Line Number = 1, Column Number = 387, Description = Untyped element: Version</Error><Error>System Id = 137966328, Line Number = 1, Column Number = 3362, Description = Element 'JournalEntries' is not valid for content model: '(AdmInfo?,JournalEntries?,JournalEntries_Lines?)'</Error></ErrorList>

Maybe the question is: what is the XML structure to objects with "childs"?

By example, how it works with the Contacts and BusinessPartners?

Thanks,

Ribeiro Santos

former_member185703
Active Contributor
0 Kudos

Hi,

Besides the fact that the start tag (<JournalEntries>) does not match the end tag (<Journal_Entries>) - and that is what the exception says, didn't you save a journal entry to XML first?

The tag for the journal entry header data is either <JDT1> or <JournalEntries_Lines> depending on what you set XmlExportType to.

xet_AllNodes - the default value - will generate a XML you cannot read in in any case. You will have to use one of the other options (see DI API 2004 helpfile).

Unfortunately there seems currently to be some bug so that only xet_ExportImportMode works (for both) ReadXML + BetBusinessObjectFromXML - at least without any need to modify anything.

HTH,

Frank

Answers (0)