Skip to Content
Author's profile photo Former Member

Can we test Binary Files in Interface/Operation Mapping???

Recently, I saw one interesting thread in forum having a requirement to add a water mark effect to the incoming payload (PDF file) during mapping. One of the quick solution, for such requirement will  be a java mapping using external API’s such as iTextPDF which can do a water mark effect on the input PDF file/stream. Well, now we have a solution but, can we verify the java mapping code without configuring an end to end scenario in SAP PI? Obviously yes, we can test the snippet of code in standalone mode outside XI/PI, using java main method wrapper and passing the input file stream to execute (or) transform methods and writing output stream to a file. However, the standalone tests do not signify exactly the same java runtime behaviors of SAP XI/PI. So, how to proceed in such cases? Do we need to configure an end to end scenario and spend lot of time on interface testing end to end by involving various parties?

In this blog, I will explain the undocumented feature of SAP PI mapping test tab export functionality. I searched SDN, if this solution is already available, but I could not find any.


  1. As usual, load the compiled java mapping code classes along with required external jar files into imported archive section.
  2. Create a temporary interface/operation mapping using existing source and target message/service interfaces and under mapping choose java mapping type and then choose step1 java main class program.
  3. As usual, go to test tab and click on “Load Test Instance”. It will pop-up with File Open dial box. By default, the file type will be of *.xml type. Choose “All Files”. Now, select and open the required binary file (PDF file) from your local machine.
  4. The mapping tool will pop-up dialog box with error “Unable to display tree view; Error when parsing an XML document (Content is not allowed in prolog.)”. This behavior is obvious, since the loaded data is not XML.
  5. Now execute your mapping. The output will pop-up with error pop-up similar to step 4 along with process log. Check process log for any java exceptions that might during transformation.
  6. Close the error pop-up and process log and then export the generated output AS-IS by using export push button.
  7. By default, the output will always be stored as a zip file with data file as “instance.xml” irrespective of actual output data type. Extract the zip file and then rename the .xml extension to desired extension accordingly. The file should open with it associated application. Now we can verify the output data 🙂


1. Reduced testing efforts

2. No need to configure an end to end scenario or not even active version objects required

3. Quick upload of compiled java code and load test data directly from mapping test tool







Extract the zip file and rename instance.xml to instance.pdf and open with Acrobat Reader application.


Result: Water marked PDF


That’s all.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Nice one Praveen! I'm a big fan of undocumented features 😆

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Trevor. I am a big fan too... 🙂

      Author's profile photo Iñaki Vila
      Iñaki Vila

      Thank very much Praveen, I didn't know that it was possible to test the binary files directly in ESR and with this the testing effort is reduced.

      Author's profile photo Nageshwar Reddy
      Nageshwar Reddy

      Thanks Praveen. Good to know that binary files can be tested ....

      Author's profile photo Mark Dihiansan
      Mark Dihiansan

      Thanks Praveen! This will save a lot of effort on future developments.

      Author's profile photo Grzegorz Glowacki
      Grzegorz Glowacki


      I wouldn't think of trying to save the output, once the error was raised. I thought it means no output was created at all. Nice one! 🙂



      Author's profile photo Former Member
      Former Member
      Blog Post Author

      I agree with your comment. Most of the PI consultants have been under the same impression for years since XI3.0 🙂

      Author's profile photo Baskar Gopalakrishnan
      Baskar Gopalakrishnan

      Nice one Praveen. This shows that various file extension type can be tested in our ESR/IR tool. Thanks.