cancel
Showing results for 
Search instead for 
Did you mean: 

How to prepare xml document (Business object) for import through DI?

0 Kudos

Hello everyone.
I need to create document (and other business object) in SAP B1 from imported file.
I would like to use XML, but my first steps to learn working with XML and B1 are annoying. I need some advice:
I saved XML schema for Business Partner object (GetBusinessObjectXmlSchema), and then I get object GetAsXML (XMLAsString = true, XmlExportType = xet_ExportImportMode). Q:
1. XML file encoding is set to UTF-16, but content is UTF-8, any idea why?
2. XML file is not valid with earlier saved schema, what is wrong?
3. My goal is prepare valid XML file outside SAP and use it to create object using DI API, can You give some advice?
I will be very grateful for any help or knowledge.

Accepted Solutions (1)

Accepted Solutions (1)

pedro_magueija
Active Contributor
0 Kudos

Hi Michal,

One common approach is to export the GetAsXML file and clean the data. Then use that as a template when creating your importable file.

The UTF-16 has always been like that, and if I recall correctly it's not necessary to include the XML declaration tag (not 100% sure) in your file when importing.

About the validation of the XML file against the schema, I've never done it (since I use the approach above), but I'd expect it to validate. That could perhaps be an issue with the schema returned as well.

Pedro Magueija

LinkedIn | Twitter | Blog

Answers (2)

Answers (2)

0 Kudos

Thank You for answer. I know this method. But I need to create XML file for import in other application. In other words: need to create empty XML file, fill it with data and finally import to B1.
The problem is how to generate empty, importable XML file.
Mayby the problem is that I don't understand schema file. (sample XML object I saved from B1 is not compliant with scema file).

edy_simon
Active Contributor
0 Kudos

Hi Michal,

If you need to be able to import back the xml file, before you export the object, you need to set

oCompany.XmlExportType =BoXmlExportTypes.xet_ExportImportMode

Note, that this property is for 1 session, so you need to set once only for the current oCompany object.

I noticed that encoding, not sure why, but you can import it without changing the UTF declared.

Regards
Edy