This article provides a sample Java mapping code to decode Base64 string in SAP PI/PO. You can decode Base64 string in SAP PI/PO with User-Defined Function (UDF), Java Mapping and Adapter Modules. In this example, we will discuss how to achieve Base64 conversion using Java Mapping. Feel free to read my previous article on Base64 encoding and decoding methods in SAP ABAP. Additionally, you can refer to my SAP blog on the same subject.
Base64 Decoding Example Scenario:
Let’s assume, a sender message contains Base64 string and we need to assign the decoded string to the target message.
Source message xml node <Base64EncodedString> contains the encoded message. Decoded string should be mapped to node <Base64DecodedString> of the target message.
This example will be implemented in an SAP Process Integration (PI) system version 7.50 single stack.
Expected Functionality of Java Mapping:
Final result with input message and desired output message are as below.
The first function of Java Mapping is to convert Base64 encoded string in ‘Base64EncodedString’.
Encoded string ‘U0FQSW50ZWdyYXRpb25IdWIuY29t’ translates to ‘SAPIntegrationHub.com’.
Next, Java Mapping should form the output or target xml message.
Base64 Decoding Java Mapping example - Source Message
Step 3: Create Imported Archive and Operation Mapping (OM).
Create Imported Archive by uploading Java Mapping class defined in step 2 as a .jar to ESR. Then configure the Operation Mapping with the Imported Archive.
Test Base64 Decoding Java Mapping:
You can test Java Mapping using Operation Mapping test tool in ESR.
Base64 encoded string is ‘VGVzdGluZyBkZWNvZGVyLg==’.
Hopefully, you will be able to reuse the structure of this Base64 decoding Java Mapping class for integration scenarios. Please, leave a comment below if you have any questions about Base64 decoding or Java Mappings.