Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 
Active Contributor

Dear Scn users,

This Document gives the approach of executing XSLT mapping using java class in PI 7.4.


The approach of handling parameterized values for a particular field and normal XSLT mapping for other fields. So a combination a parameterized and normal XSLT mapping is handled in this scenario which will be normally applied in most of the business cases.To achieve this a Java class is written which will is used to call the parameters and this java class is called in XSLT mapping.Hence the combination of Java and XSLT mapping is used to acheive the purpose.

In my scenario, I have 4 fields in the input structure



3.Date of joining

4. Serial.

And the fields in the output structure are as below.

1.Name - concatenation of FirstName + LastName.

2. Date of joining-For this field parameterized mapping is used i.e. Date is obtained as parameter from Integration directory.


Create Data Types.

One data Type for Input.

One for Output

Step 2:

Create Message Types and Service Interfaces.Just use the data types created and create 2 message types and 2 service interfaces for Input & Output Structures.

Step 3.

Create Java project in NWDS.

1.Open NWDS->New Java project.

2.Then Create a package and class which is used for parameterized mapping for Date field and the export the same as .jar file.

3.Below is the Java code which I used to extract parameters.

package com.po;
import java.util.Map;
public class JavaCode extends  AbstractTransformation{

   public final static String namespace = "http://pi";

   public final static String Date = "Date";

   public  void transform(TransformationInput in, TransformationOutput output) throws StreamTransformationException
    DynamicConfiguration dc = in.getDynamicConfiguration();

    InputParameters parameters = in.getInputParameters();

    // add the seperate values
    getTrace().addInfo("Date " + parameters.getString("Date"));
    DynamicConfigurationKey userKey = DynamicConfigurationKey.create(namespace, Date);
    dc.put(userKey, parameters.getString("Date"));

    //copy the original content
     InputStream instream = in.getInputPayload().getInputStream();
     OutputStream outstream = output.getOutputPayload().getOutputStream();
     byte[] buf = new byte[1024];
     int numRead=0;
     while(( != -1){
      outstream.write(buf, 0, numRead);

    }catch(IOException ioe){
     throw new StreamTransformationException(ioe.getMessage(),ioe);

    * Method called from the XSL to return the value of the attribute
    * Remeber to have <xsl:param name="inputparam"/> in the XSL and call with
    * xslsave:getValue($inputparam, 'USERNAME')
    * @param map the inputparams
    * @param key the key to lookup
    * @return
   public static String getValue(Map map, String key){
     DynamicConfiguration dc = (DynamicConfiguration)map.get("DynamicConfiguration");
     DynamicConfigurationKey keyConfig = DynamicConfigurationKey.create(namespace, key);
     return dc.get(keyConfig);
    }catch(Exception e){
     return "Error fetching key "+ key + " because: " +e.getMessage();



Step 4:

Create an .XSL file to transform input->output structure as per the requirement.For date field it will a call of java class using Java code.Below is the XSLT code.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:ns0="" xmlns:javamap="java:com.po.JavaCode" xmlns:xsl="">
<xsl:param name="inputparam"/>
<xsl:template match="/">
xsl:value-of select="concat(concat(ns0:XSLTTestECC/FirstName,' '), ns0:XSLTTestECC/LastName)" />
<xsl:value-of select="javamap:getValue($inputparam, 'Date')"/>
  <xsl:value-of select="ns0:XSLTTestECC/Serial" />


Call the Java class in the XSLT for parameterized mapping.

Step 5:

After completing the code import the JAVA class(.jar file) and XSLT code(.rar file) as imported archive in ESR.

Step 6:

Create the operation mapping by using the service interfaces created and in the mapping program.Select java class at first and XSLT as second as shown below.

And dont forget to select the "use SAP XML Toolkit"option.Now define a parameter and bind it with the java class Date.

Step 7:

After doing all the steps you can test and it can be seen that the Date which is a parameter is passed successfully in to the XSLT class and displayed in the output Structure

And for creating ID objects it is a normal way as we do for interfaces and in the Interfaces Tab of Integrated configuration the value of parameter Date should be declared.


Labels in this area