cancel
Showing results for 
Search instead for 
Did you mean: 

Java Mapping

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

iaki_vila
Active Contributor
0 Kudos

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

Answers (2)

Answers (2)

iaki_vila
Active Contributor
0 Kudos

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();

}

Former Member
0 Kudos

Hi,

plz send me step by step document (java mapping ) ...

mail is:sureshwinny@gmail.com

reg,

suresh

henrique_pinto
Active Contributor
0 Kudos

You want to use java mapping for learning purposes?

Because if it's not, message mapping can solve that really easily.

Regards,

Henrique.

Former Member
0 Kudos

Yes I now I can so it with Graphical Mapping..even I did it with XSLT...

But I am looking for Java Mapping