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
- Graphical Mapping – The most popular and easier way.
- Java Mapping
- XLST Mapping
- 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
- Using the external editor.
- 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
- No need to install Java editor – for beginners some time it is confusing and time-consuming.
- No need to spend time looking for java libraries.
- Debugging will be easier as you can use a graphical mapping editor.
- No need of importing the jar as Imported Archive.
- 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
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.
Save and test as is done for Message Mapping
if you notice the target structure is changed completely.