Escolar Documentos
Profissional Documentos
Cultura Documentos
Search
Search
Techplay
./techplay
Home
About
1/15
1/30/2014
Give the project a name and select the correct Java runtime. In my case I selected JRE 1.4.2. Then click Finish.
http://techplay.plozzle.com/?p=21
2/15
1/30/2014
This will then have created your project. Right-click on your project and select Properties. Select Java Build Path and select the Libraries tab. This will
give you the following screen.
http://techplay.plozzle.com/?p=21
3/15
1/30/2014
Click on Add External JARS and then find the location of the library aii_map_api.jar mentioned in the requirements above.
After adding the library, you should get the following screen.
http://techplay.plozzle.com/?p=21
4/15
1/30/2014
You should have the dialog box below. Enter a package name optionally and then enter a Class name and click add to add an interface.
http://techplay.plozzle.com/?p=21
5/15
1/30/2014
http://techplay.plozzle.com/?p=21
6/15
1/30/2014
You should now have the screen below. Click Finish to create the Class.
You will now have something like the following image. The method execute is where the mapping occurs and is where you would insert your code. Input
comes in the form of the InputStream arg0, and output is passed in the OutputStream arg1. The method setParameter allows you to obtain a reference to the
mapping parameters. In my scenario I used this to access the mapping trace.
package com.sap.pi.demo;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
http://techplay.plozzle.com/?p=21
7/15
1/30/2014
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.Map;
import com.sap.aii.mapping.api.AbstractTrace;
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationConstants;
import com.sap.aii.mapping.api.StreamTransformationException;
public class TextMapping implements StreamTransformation {
private Map map = null;
private AbstractTrace trace = null;
public void setParameter(Map arg0) {
map = arg0;
if (map == null) {
this.map = new HashMap();
}
}
public void execute(InputStream arg0, OutputStream arg1)
throws StreamTransformationException {
String line = null;
BufferedReader br = new BufferedReader(new InputStreamReader(arg0));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(arg1));
// Get reference to mapping trace
trace = (AbstractTrace)map.get(StreamTransformationConstants.MAPPING_TRACE);
trace.addInfo("Processing message");
try {
//Read all lines of input stream arg0
while ((line=br.readLine()) != null) {
//Write output to output stream arg1
bw.write(line.replaceAll("remove", "delete"));
}
bw.flush();
br.close();
bw.close();
} catch (IOException ioe) {
trace.addWarning("Could not process source message");
throw new RuntimeException(ioe.getMessage());
}
trace.addInfo("Processing completed successfully");
}
}
Importing the Java mapping into the Integration Repository (Enterprise Services Repository)
Once youve completed your mapping code and would like to import it into SAP PI start by right-clicking on you project and then select Export
http://techplay.plozzle.com/?p=21
8/15
1/30/2014
Click Browse and find a suitable location to store you exported archive and then click Finish.
http://techplay.plozzle.com/?p=21
9/15
1/30/2014
Now go to the Software Component and namespace you wish to import the mapping into. Right-click on Imported Archives and select New
Find the Jar file that was previously exported and select Open.
http://techplay.plozzle.com/?p=21
10/15
1/30/2014
Be sure to save and activate this. Without activating the mapping will not be available for selection.
Now create your interface mapping as follows and then give it a sensible name.
http://techplay.plozzle.com/?p=21
11/15
1/30/2014
From the dropdown in the Mapping Program section select Java Class.
Select your Java Mapping Class from the search help under name.
Now you can test your Interface Mapping. The below shows the test of the mapping I created earlier. Note that the word remove gets replaced by
delete and we write two lines to the mapping trace.
http://techplay.plozzle.com/?p=21
12/15
1/30/2014
1.
hari
2.
Murugan
3.
Ali
13/15
1/30/2014
Reply
Really great job man
Thanks
Ali
4.
kevin
1.
admin
Leave a Reply
Your email address will not be published. Required fields are marked *
Name: *
Email: *
Website:
Message: *
http://techplay.plozzle.com/?p=21
14/15
1/30/2014
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite="">
<cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Submit Comment
Copyright
2014 Techplay.
Return to top
Powered by WordPress and the Graphene Theme.
http://techplay.plozzle.com/?p=21
15/15