Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
engswee
Active Contributor

Update 3 Oct 2018: Added Excel converters


 

Introduction


If you have worked on SAP PI over the past few years, there is a possibility that you may have come across FormatConversionBean – One Bean to rule them all! It is an open source project I developed, providing various format conversion functionalities (complementing SAP's offering) packaged in a custom PI adapter module.

 

Although CPI provides similar capabilities, some of its converters lack customising options for more complex scenarios.

 

The good news is - FormatConversionBean is now available in CPI! Over the past weeks, I've began porting over the development to fit into CPI's Camel-based framework, and the bulk of functionality is now ready to be used.

 

Converters


The following table lists the converters that are available as part of FormatConversionBean in CPI. The reference link for each converter provides more details on the available configuration options/parameters.

 

Note: The converter classes are in a different package (com.equalize.converter.core) compared to their PI counterparts.

 

 

Usage in Integration Flow


Due to differences between the nature of the design of integration flows in CPI compared to PI, the approach of using it can be summarised in the following steps.

1) Upload JAR file

2) Configure parameters (via Content Modifier or script)

3) Add Groovy script

 

Below is a sample integration flow utilising FormatConversionBean.



 

Further details of each step are as follows:-

Step 1 - Upload JAR file

i) Download latest release of converter-core-x.x.x.jar from GitHub repository.

ii) Use Resources view to upload JAR file as an Archive into Integration Flow.



 

Note: To use the Excel converters, the following Apache POI 3.17 libraries need to be uploaded into the Integration Flow as well.

 

Step 2 - Configure parameters

Parameters are passed into FormatConversionBean using Exchange Properties. These can be configured via Content Modifier (sample below) or Script (Groovy or Javascript). Refer to each converter's blog post for details on available parameters.



 

Step 3 - Add Groovy script

This is the entry point for the execution of FormatConversionBean. Add a Groovy script step in the Integration Flow with the following code.
import com.sap.gateway.ip.core.customdev.util.Message
import com.equalize.cpi.converter.FormatConversionBean

def Message processData(Message message) {

def fcb = new FormatConversionBean(message.exchange, message.getProperties())
def output = fcb.convert()
message.setBody(output)
return message
}

 

That's it! It is as simple as that! 🙂

 

Source Code, Enhancements & Collaboration


The source code for FormatConversionBean is hosted at the following GitHub repository.

https://github.com/engswee/equalize-cpi-converter

It is a Maven-based project with the following attributes:

  • Mixed Java and Groovy development

  • Unit tests written in Spock

  • Automated Maven build process




 

Anyone and everyone is welcome to fork/clone the repository to further enhance privately or collaborate publicly on this project.

 

More details utilising Eclipse/Maven to develop and build the project to follow in a future blog post.

 

Bugs & Feature Requests


If you encounter any bugs or would like to request for a particular feature, the preferred approach is to raise an issue at the following GitHub repository.

https://github.com/engswee/equalize-cpi-converter/issues

This provides a better avenue to track, communicate and collaborate on the issue instead of the comment section of this blog post.
40 Comments
Labels in this area