Convert Recordlist to XML doc validate w schema

I’m also new to Integrator. I’ve searched all the docs and conversations but I still need a little help!

I have a flow - 1st step calls a BAPI in SAP - there is a resulting Recordlist. At first I took the easy road and created an XML output template to send the data to the calling client. This worked until one of the values contained an “&”! So, I think what I need to do now is to add steps to actually create the XML document by mapping from Recordlist. I have created a schema and imported into BC as a BC Schema - but I am unsure what to do next. Is there a predefined service I should use? pub.web.recordToDocumet looks like the right service except that I don’t see how to selectively map fields from the recordlist into a predefined schema.

Thanks for any guidance you can give me.


When you created the schema did you create a matching record? If not, you’ll need to.

Then map from your record to the new XML record. The make a call to documentToRecord and map your XML record into boundnode. Make sure you specify the fully qualified name of your record in the recordName varible (folder.subfolder:record). If you want empty tags for nulls then set generateRequiredTags to “true”.

Check out the Built In Service Guide for more details. There is a link to in under Help in the Developer.

Hope this helps.


No i didn’t but i’ll do that. so, i iterate over each record in the Recordlist, map to the XML record, then map from that to the XML schema? I have the 5 pages on the recordToDocument in front of me - and one thing that remains a bit confusing - it says that it can either generate an XML fragement OR a legal XML doc - but if you want a legal XML doc (with one root schema node) it can only produce it for ONE record (boundnode). Perhaps I should just add the declaration, ns, and schema tags manually, and use the recordToDocument to create the fragments for each record. Sound logical?

Thanks so much for your time.

you could also usem this code snippet as a shared resource to deal with the ampersand

public static String encodexml(String xmldata) {
xmldata=findnreplace("&", “&”, xmldata);
return xmldata;

public static String findnreplace(String ch, String ent, String xmldata) {
int L=ent.length();
if (xmldata.indexOf(ch)>0) {
int lastpos=0;
int currentpos=xmldata.indexOf(ch);
while (currentpos>0) {
xmldata =xmldata.substring(0,currentpos) + ent + xmldata.substring(currentpos+1);
currentpos=xmldata.indexOf(ch, lastpos);
return xmldata;


When converting recordlist to XML use encoding set to true.
This takes care of your & ! problems.Theres share code listed in shareware for converting recordlist to XML.
For further queries you can mail me.

Thanks for the responses and your time! The examples were a big help. I’m still having a small problem but I think I can work it out.


Got it. I had defined the element under the root node as a Record, so I was only getting XML for one record. Redefinding it as a RecordList solved the problem.

I am still having the ampersand problem, even with encode set to “true”. I am going to try the java above, but shouldn’t the encoding solve this?

We ran into ampersand issues in our XML as well. I set the encode to true and it seemed to fix the problem. Later, in testing we encountered the problem again further down the line. The delivery process kicked off by the rule had another record to document step that did not encode and the ampersand appeared in the document again. Once I fixed that the encode solved the problem. Maybe you have something similar going on?

I implemented a new service using Java based on the example above, and it worked. Then, I went back just for grins and set “encoding = true” again , and this time it worked! (Could of sworn it didn’t the first time, of course my other problem with the recordlist probably obscured the fact that it was working…) So, I have a useful example for implementing a nugget of Java as a service, but in the end, setting the “encoding = true” in the recordToDocument service was the solution.