cancel
Showing results for 
Search instead for 
Did you mean: 

Error in mapping or source ?

Former Member
0 Kudos

Hello Experts,

I hope you can help me with following issue ...

I trying to set-up an file to idoc scenario using file content conversion but I have an issue in my mapping and I know what is missing but don't know how to fix it...

My source xml is missing ns0:

I have this

<?xml version="1.0" encoding="utf-8" ?>

<MT_ACC_DOCUMENT>

<Recordset>

<DOCUMENT>

instead of this

<?xml version="1.0" encoding="utf-8" ?>

<ns0:MT_ACC_DOCUMENT xmlns:ns0="http://connectsystems.be/MAINFR/AccDocument">

<Recordset>

<DOCUMENT>

Can somebody please help me or advice me how to solve this??

Thank you very much.

Best regards,

Daisy Heremans

Accepted Solutions (1)

Accepted Solutions (1)

former_member854360
Active Contributor
0 Kudos

Hi daisy,

This is a very simple requirement,

You need to provide your namespace in File content conversion parameter.

Parameter Name: Document Namespace

This is the second parameter from the TOP .

Under Document Namespace, enter the namespace of the document. Means http://connectsystems.be/MAINFR/AccDocument

The namespace is added to the name of the document. This is mandatory for the mapping.

Refer this:

http://help.sap.com/saphelp_nw04/helpdata/en/2c/181077dd7d6b4ea6a8029b20bf7e55/content.htm

Hope this solves your problem.

Document Specifications
Make the following entries for the document:

u25CF      Under Document Name, enter the name of the XML document. 

The document name is inserted in the message as the main XML tag. This is mandatory for the mapping.

u25CF      Under Document Namespace, enter the namespace of the document.

The namespace is added to the name of the document. This is mandatory for the mapping.

Answers (5)

Answers (5)

Former Member
0 Kudos

THANK YOU .... I have missed this !!

former_member854360
Active Contributor
0 Kudos

You are welcome........:)

Former Member
0 Kudos

Hi Daisy,

I think you have not provided the XML Namespace in the source Message Type. So, ns0 is missing.

Please check and provide the Namespace..

Thanks,

anupam_ghosh2
Active Contributor
0 Kudos

Hi Daisy Heremans,

You could use a java mapping code as shown below.


import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;

public class DOMParser3 implements StreamTransformation{




public void execute(InputStream in, OutputStream out)
throws StreamTransformationException {


try
{
	DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
	DocumentBuilder builderel=factory.newDocumentBuilder();
	/*input document in form of XML*/
	Document docIn=builderel.parse(in);
	/*document after parsing*/
	Document docOut=builderel.newDocument();
	TransformerFactory tf=TransformerFactory.newInstance();
	Transformer transform=tf.newTransformer();
	Element root;
	Node p;
	
	
	NodeList l;
	int mm,n1;
	root=docOut.createElement("ns0:MT_ACC_DOCUMENT");
	root.setAttribute("xmlns:ns0","http://connectsystems.be/MAINFR/AccDocument");
	p=docIn.getElementsByTagName("MT_ACC_DOCUMENT").item(0);
	System.out.println(p.getNodeName());
	l=p.getChildNodes();
	n1=l.getLength();
	System.out.println(n1);
	for(mm=0;mm<n1;++mm)
	{
		Node temp=docOut.importNode(l.item(mm),true);
		root.appendChild(temp);
	}	
	docOut.appendChild(root);
	transform.transform(new DOMSource(docOut), new StreamResult(out)); 
}
catch(Exception e)
{
	e.printStackTrace();
}


}

public void setParameter(Map arg0) {


}

public static void main(String[] args) {
try{
	DOMParser3 genFormat=new DOMParser3();
	FileInputStream in=new FileInputStream("C:\\Apps\\my folder\\sdn\\input1.xml");
	FileOutputStream out=new FileOutputStream("C:\\Apps\\my folder\\sdn\\output1.xml");
	genFormat.execute(in,out);
}
catch(Exception e)
{
e.printStackTrace();
}
}


}

sample input1.xml as seen is internet explorer


  <?xml version="1.0" encoding="utf-8" ?> 
- <MT_ACC_DOCUMENT>
- <Recordset>
  <DOCUMENT>mydocument</DOCUMENT> 
  </Recordset>
  </MT_ACC_DOCUMENT>

Output1.xml as seen in browser


  <?xml version="1.0" encoding="UTF-8" ?> 
- <ns0:MT_ACC_DOCUMENT xmlns:ns0="http://connectsystems.be/MAINFR/AccDocument">
- <Recordset>
  <DOCUMENT>mydocument</DOCUMENT> 
  </Recordset>
  </ns0:MT_ACC_DOCUMENT>

If you are new to java mapping you can follow the links shown below

for PI 7.1

http://wiki.sdn.sap.com/wiki/display/XI/SampleJAVAMappingcodeusingPI7.1+API

for pi 7.0

http://wiki.sdn.sap.com/wiki/display/XI/BeginnersguidetoJavamappingusingDOMparserinSAPXI

Hope this helps.

regards

Anupam

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

<?xml version="1.0" encoding="utf-8" ?>

<MT_ACC_DOCUMENT>

<Recordset>

<DOCUMENT>

instead of this

<?xml version="1.0" encoding="utf-8" ?>

<ns0:MT_ACC_DOCUMENT xmlns:ns0="http://connectsystems.be/MAINFR/AccDocument">

<Recordset>

<DOCUMENT>

You have two ways to fix this, one is already given by Baskar. The other one is to simply delete the XML namespace in your source message type, to do this:

1.) Open your source message type

2.) Under the XML namespace, delete the entry, save and activate

Regards,

Mark

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You can achieve this using XSLT mapping or java mapping.

YOu can change namespace prefix for an existing namespace but cannot add a new namespace using XMLAnonymizer Bean module. So XMLAnonymizerBean is not going to support.

Hope that helps.