This blog explain you how to develop a java mapping class for using it in your Interface Mapping in SAP PI. It’s a tutorial for beginers.

Implements a Java class for mapping purpose require the next steps:

  1.- Development Tool like SAP Netweaver Developer Studio, NetBeans, Eclipse ….

  2.- Import aii_map_api.jar library.

  3.- Write the Source code for the mapping program. (We need to know DOM or SAX parsing proccesing)

  4.- Generate .jar file with the compiled class.

  5.- Import Jar File in SAP PI.

  6.- Use the program mapping in Interface Mapping.

1.- Open a Development Tool.

Firstly, we are going to open the SAP Netweaver Developer Studio for create a new project.

2.- Next, we must to import the aii_map_api.jar library. The file aii_map_api.jar is located in j2ee\cluster\server0\apps\\ directory.


3.-  Write Java Source.

package com.xi.test;

import java.util.HashMap;
import java.util.Map;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

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


public class NameMerge 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 input, OutputStream output)
        throws StreamTransformationException {

        AbstractTrace trace = null;
        String RESULT = new String();

        trace =
            (AbstractTrace) param.get(

        try {
            //Create DOM parser
            DocumentBuilderFactory factory =
            DocumentBuilder builder = factory.newDocumentBuilder();

            //Parse input to create document tree
            Document doc = builder.parse(input);

            //Map the elements
            Node root = doc.getFirstChild(); // gets the root element
            NodeList children = root.getChildNodes();
            for (int item = 0; item                 if (children.item(item) instanceof Element) {
                    root = (Element) children.item(item);
                    NodeList ch = root.getChildNodes();
                    RESULT = RESULT.concat(ch.item(0).getNodeValue() + ” “);



        } catch (Exception e) {

        //Return the output document
        String document_exit =
                + RESULT
                + “

        try {
        } catch (IOException e1) {



4.- Generate JAR file.

   Go to File->Export in SAP Netweaver Developer Studio a choose the project where you have developed the mapping program and you must export it to a file.

5.- Import JAR File.

   Go to Integration Repository, Mapping Object -> Imported Archives. You must to create a new Imported Archives and import the file that you had generated in SAP NDS.

6.- Use the program mapping in Interface Mapping

Finally, you have to use the java class in an Interface Mapping.

The XML used for creating the java test class are:


ivan prieto

New NetWeaver Information at

Very Helpfull

User Rating: Be the first one !