Skip to Content
0

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

Nov 21, 2016 at 07:51 PM

270

avatar image

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
avatar image
Former Member Nov 23, 2016 at 12:17 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Edy Simon Nov 22, 2016 at 12:54 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Michal Hadrys Nov 22, 2016 at 10:10 AM
0

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).

Share
10 |10000 characters needed characters left characters exceeded