Java Mapping in SAP PI

This blog will cover how to do Java mapping in SAP PI.  Java Mapping is always a concern for any PI consultant, so today I will try to explain the techniques which will make it interesting and easier.

In PI mapping can be done in the following ways

  1. Graphical Mapping – The most popular and easier way.
  2. Java Mapping
  3. XLST Mapping
  4. ABAP Mapping – This will not be applicable in case you have a single stack instance.

In this blog, we will cover Java Mapping in SAP PI.

It can be done in 2 ways

  1. Using the external editor.
  2. Java Mapping directly in ESR.

Here we will focus on the 2nd option which will be easier for beginners.

For option 1 here is a good article which can be used

Develop Java Mapping in Eclipse

 

Java Mapping within ESR

This is good option especially for people not well versed with Java and want to write codes without bothering about eclipse configuration or loading Java libraries.

It is really cool idea and some of the advantages

  1. No need to install Java editor – for beginners some time it is confusing and time-consuming.
  2. No need to spend time looking for java libraries.
  3. Debugging will be easier as you can use a graphical mapping editor.
  4. No need of importing the jar as Imported Archive.
  5. For small changes no need to recompile and reimport the jar files to ESR, directly make the change in ESR.

Here are steps to follow for creating Java mapping in ESR directly.

Create Message Mapping

The first step is same as graphical mapping –create a Mapping

Select Source and Target message type

Note: As this is Java mapping these will not be validated

Go to Functions tab > Attributes and Methods

Java Mapping in SAP PI

 

Start with writing transform (PI >=7.1)/execute(PI< 7.1) method directly as all the import statements are already there in import section as shown above.

Example: In this example, I am changing the target structure completely.

Java Mapping in SAP PI

Save and test as is done for Message Mapping

if you notice the target structure is changed completely.

Java Mapping in SAP PI

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.