text: A letter from Java Mapping to ESR
  Dear ESR,
  I am happy that you have provided such a wonderful Graphical Editor with rich GUI for Message Mapping, but a bit jealous also that you never cared about me. They treat me as last resort when nothing else works. It’s a bit unfair that I never had the privilege of friendly environment like you provided to your dear Message Mapping.
  I agree that with swing based ESR it was difficult, but even with Eclipse based ESR I can’t see any improvement. Everyone know that Message Mapping is also kind of Java Mapping at heart. Still you helped him compiling the code with Mapping API and generating jar. I’d also love to be more visible and flexible instead of just hiding behind Imported archive.
  Regards,
  Java Mapping
  I am sure you agree writing Java Mapping outside ESR has always been a pain. Even for doing a small change, you have to follow the whole cycle of checking your source code in a Java Editor, recompiling it with Mapping API and finally uploading the jar generated as Imported archive. And what if you don’t find the source code as earlier developer never bothered to keep a source code copy in Imported Archive, then one more unofficial step of decompiling the jar first.
  Won’t it be a cool idea if you could manage your Java mapping directly in ESR. Here is the list of advantage you get
  1. No need of Mapping API
  2. No need to write mapping class from scratch
  3. No need of manual compilation and Jar creation
  4. No need of importing the jar as Imported Archive
  5. With visible code, changing the mapping would be more transparent
  If you can’t wait till the idea becomes reality, you have a workaround. Here you go!
  1. Create Message Mapping
  2. Select some dummy message type in Source and Target as that it is not validated in java mapping
  3. Go to Functions tab > Attributes and Methods
  4. Start with writing transform(PI >=7.1)/execute(PI< 7.1) method directly as all the import statement are already there in import section. For example to change namespace prefix from ns0 to pfx, you can try this code.
  5. Save and test as is done for Message Mapping
  public void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException {
  try {
  // Your logic goes here
  }
  catch (Exception e) {
  throw new StreamTransformationException(e.getMessage());
  }
  }
  If you are lucky enough to have PI>=7.3, you can easily write code using Eclipse based ESR with auto completion feature(Ctrl + SPACE).
  The first 2 steps are same as above.
  3. Open Message Mapping in Java Editor
  4. Start with writing the transform method
  5. Save and test as is done for Message Mapping
  Hope you like this idea of writing Java Mapping directly in ESR. You can also vote to promote this at IdeaPlace.
  Reference:
  Hack: Using XPATH in XI Message Mappings
  Hi Sunil,
  Liked your JM letter 😉 and as well your idea.
  Regards,
  Praveen Gujjeti
  Nicely formatted letter. Yes, we have already come to a stage of just single (java) stack alone. It will be really cool if we get this feature.
  Nice Letter 🙂
  Good Idea to use a Graphical mapping as a Java mapping by adding code in Transform method….Keep blogging..
  Thanks
  Rakesh
  Nice Idea
  Very well presented. Good trick.
  That was informative….Thank you..
  Dear
  Sunil Chandra
  I am a new PI developer. I have some doubt about your way. After writing code of transform function, I try to test message mapping, i always got an error which showed that target cannot be created. Could you please clarify me about necessary step I missing. 🙁
  Good idea. I will try to use this trick for out next java mapping challenge.
  I think with the direction of a consolidated IDE i.e Eclipse for SAP PI/PO, one wouldnt really even open ESR eventually 🙂
  The IDE will then become centric to all development, including Java mapping.
  This is really coo idea 🙂
  Here how to use trace method to check values during testing?
  Hi Shiva,
  Did you find a method for adding trace info?
  Cheers,
  Emil
  getTrace method can be used to add trace during testing.
  getTrace().addInfo("...");
  Regards,
  Sunil Chandra
  Hi Sunil,
  Can you provide an working example from a message mapping? I can only get the AbstractTrace to work in the “old normal” java mapping. Not in the default method provided within the message mapping.
  Thanks.
  Emil
  This one is really informative to use and manage JAVA mapping directly in ESR. Keep blogging.
  Thanks,
  Gopi
  Well Explained!! Very helpful for the Beginners like me!! Please come up with a blog/letter on UDF using parameters.
  Thanks
  Abhi
  Nice Concept.. good introduction…explained well..
  thank you very much… 🙂
  Hi Sunil,
  Brilliant idea, but I can’t make it really work. I’m on PO 7.4 single stack, and using NWDS ESR Perspective.
  At first, I wrote a simple Identity Mapping with your method (let the InputStream flow into the OutputStream) and it looked like it was working.
  Now I came to something “real” (an Extended Receiver Determination, btw) and when I run it, a simply obtain the empty standard Receivers xml doc.
  I wanted to trace something (or even better debug it, but no clue) but when you state that getTrace() will do the job, it is in fact a method of AbstractTransformation, which a normal message mapping (even when opened in the Java editor) doesn’t extend itself. I will try adding it, but am I allowed?
  Do you have any suggestion?
  Many thanks and regards
  Alex
  Nice to see a comment from you Alex 🙂
  As per my observation, getTrace() execution behavior is same in both swing based or NWDS java editor. Although it displays the line as error in NWDS java editor, it won’t be a problem while activating the mapping. The other way is to explicitly extend the class with AbstractTransformation as you mentioned already.
  I am not sure why it is not working for Extended Receiver Determination. Could you share more details about it.
  Regards,
  Sunil Chandra
  Sunil,
  Thanks for replying! 🙂
  Actually I was able to make it work, but let me point out a couple of bad drawbacks that this approach brings on:
  Today I had to switch a tricky mapping to the old-fashioned Java Mapping in order to be able to debug it properly.
  So, to make a long story short, in my opinion this approach can be ok for simple code, but if things get hard, maybe the good old Java code and imported archive is still best.
  Just my 2 cents. 😉
  Good blog, Sunil, very good blog.
  Take care.
  Cheers
  Alex
  Hi Alex
  I’ve used this technique by Sunil on quite a number of relatively complex Java mapping logic and they have all been working fine during development phase and also now running in production.
  Just wanted to share some of my experience in relation to the points that you mentioned.
  2. You can get the trace using the code below. Although this flags up as a syntax error in NWDS ESR Perspective Java Editor, it actually compiles fine.
  Although it is not indicated in the Java Editor, the mapping actually internally extends com.sap.aii.mappingtool.tf7.AMappingProgram, which then extends AbstractTransformation which has the getTrace() method.
  You can check out Praveen’s reply in the comment section of his blog on this.
  ESR: Message and Java Mapping’s – in a Single Message Mapping!!
  3. I tested my mapping with a non-XML file in NWDS and it works fine too. In the ESR perspective, I right-clicked the Message Mapping and clicked Generate > XML File, but actually replaced the XML content with non XML content. After that I created a Run Configuration and linked the file as a test case and execute it. It seems to work fine.
  4. I initially had a lot of issues running mapping on NWDS ESR perspective. Finally the tricked that worked for me was to use SAP’s JVM, and ensure that my NWDS version/SP/patch matches the PI system.
  Also, to ensure that the changes in the Java editor always gets saved and activated correctly, I always use “Right-click > Open With > Java Editor” to access the source code, then save it in a change list. I noticed that if I open the mapping in the Mapping Editor first, saving it into a change list before switching into the Java Editor and making edits, although the code is there, but it does not work correctly. It’s weird but if you want to directly edit the Java code, go directly to the Java Editor first.
  Hope some of these might come in handy for you.
  Rgds
  Eng Swee
  Good to know.
  Thanks for sharing!
  Cheers
  Alex
  Excellent piece !
  Never expected that my first Java mapping would be MessageMapping in ESR only 🙂
  Thanks a ton for the post !
  Nice 🙂 and nice…
  Hi Sunil – Is there a way to access DynamicConfiguration object in this method of java mapping. Can the ‘map’ object from where the DynamicConfiguration object is obtained in a ‘normal’ java mapping, be accessed in this method as well?