Hi Experts,
I am practicing the java mapping in PI, My requirement is simple I just want to concatenate the two input strings. And my code is like this
I have few doubts :-
1) execute method is mandatory
CODE :-
import java.io.*;
import java.util.*;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
import com.sap.aii.mapping.api.AbstractTrace;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
public class Java_Test extends AbstractTransformation {
public String var1;
public String var2;
public void transform(TransformationInput input, TransformationOutput output)throws StreamTransformationException
{
InputStream ins=input.getInputPayload().getInputStream();
OutputStream outs=output.getOutputPayload().getOutputStream();
int n,m;
String result=null;
try{
DocumentBuilderFactory dfactory=DocumentBuilderFactory.newInstance();
DocumentBuilder dbuilder=dfactory.newDocumentBuilder();
Document doc=dbuilder.parse(ins);
NodeList nl=doc.getElementsByTagName("PMI_SOURCE_PROD");
NodeList nl1=doc.getElementsByTagName("LOGISTA_CODE");
String PMI_SOURCE_PROD=nl.item(0).getTextContent();
String LOGISTA_CODE=nl1.item(0).getTextContent();
n=nl.getLength();
m=nl.getLength();
if(n==m)
{
for(int i=0;i<=n;i++)
{
result=PMI_SOURCE_PROD+LOGISTA_CODE;
}
outs.getOutputPayload().getOutputStream().Writes(result.getBytes()); // I am getting the error in this line Kindly check and help me in this.
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
Thanks ,
Vijay Kumar K.V.N