on 08-30-2007 12:54 PM
Hi All:
I have a scenario where I am want to use Java Mapping.
Input Data :
Fname
Mname
Lname
EmpNo
DOB
Output Data:
Employee (Only one filed with type Sting.)
With the help of Java Mapping I need to concatinate all the input fields and want to assign/map it in filed called Employee (singel target field)
Can any one let me konw what are the basics steps for it?
Thanks & Regards,
Farooq.
You can do:
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationConstants;
/**/
public class JavaMapping
implements StreamTransformation {
private Map param = null;
private MappingTrace trace = null;
public void setParameter(Map param) {
this.param = param;
if (param == null) {
this.param = new HashMap();
}
}
public void execute(InputStream in, OutputStream out) {
try{
this.trace = (MappingTrace) param.get(
StreamTransformationConstants.MAPPING_TRACE);
//MAKES PROCEDURE TO DO Inputstream to XML Document
//NOW you have an XML -> PROCEDURE TO DO search XML nodes
String prewString = nodeValueA + nodeValueB...
String outString = ("<?xml version="1.0" encoding="UTF-8"?>
" +
"<ns:OUT xmlns:ns10="http://namespace">" +
prewString +
"</ns:OUT>
");
out.write( outString.getBytes());
trace.addInfo("TRACE OK");
}catch (Exception e) {
trace.addInfo("TRACE EXCEPTION:" + e.getMessage());}
// Put this i forgot!
String receiverName = (String) param.get(
StreamTransformationConstants.RECEIVER_NAME);
}
}
null
Message was edited by:
Iñaki Vila (i forgot the final code)
Message was edited by:
Iñaki Vila
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The procedure that itold you:
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.DOMException;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
public Document iBeginParser(InputStream in) throws
Exception {
Document doc = null;
try {
DocumentBuilderFactory factoria = DocumentBuilderFactory.newInstance();
factoria.setIgnoringComments(true);
DocumentBuilder parser = factoria.newDocumentBuilder();
doc = parser.parse(in);
return doc;
}
catch (IllegalArgumentException x) {
throw new Exception(x.getMessage());
}
catch (DOMException exc) {
throw new Exception(exc.getMessage());
}
catch (Exception e) {
throw new Exception(e.getMessage());
}
}
public String SearchValue(Document doc, String label){
NodeList lista = doc.getElementsByTagName(label);
return lista.item(0).getFirstChild().getNodeValue();
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You want to use java mapping for learning purposes?
Because if it's not, message mapping can solve that really easily.
Regards,
Henrique.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.