Working with Java Transformers in IFS

One major challenge in integrations is that data formats vary among different systems. In order to successfully connect multiple systems, it is essential to have a method of translating the data types and formats between the systems.

Transformer is the component in IFS integration framework which plays this essential role of translating source document to target document format. They can be applied to incoming documents to convert any file format into an IFS compatible format and to convert outgoing document from IFS into any format required by the receiver.

About IFS Transformers

IFS supports two types of transformers

  • Stylesheet – Transformer which defined in XSLT format
  • Java – Java class implementation to perform the transformation.

Stylesheet (XSLT) transformers are easy to create, use global standards and handy with transforming XML type documents but when we need to transform data between non-xml formats, it is hardly useful.

Java transformers are purely based on java standards and provide much more freedom to transform the documents and to use third party libraries if required.

A Java transformer can be compiled to a single class file or build to a jar library. second option is useful when you use third party libraries in your transformer so you can build the jar with all dependencies.

Transformer definitions are saved in IFS database and deployed into integration runtime. Therefore customer can manage it as a configuration as far as code maintenance is handled separately.

In this post, I wish to explore following topics

Getting Started with IFS Java Transformer Development

Java transformer can be develop by creating a class implementing the IFS Java Transformer interface.

Note that transformer interface has changed in IFS Applications 10 and therefore use the correct interface for your IFS version from below.

  • App10: ifs.fnd.connect.xml.Transformer
  • App9 or below: ifs.fnd.tc.framework.xml.Transformer

Required libraries

  • IFS_HOME\repository\server\javaruntime\ifs-fnd-connect.jar
  • IFS_HOME\repository\server\javaruntime\ifs-fnd-base.jar

IFS Java transformer interface requires overriding below functions

  • init() – called only once when the class is loaded from the database into memory.
  • transform() – called to transform the actual data.

Class Template for Java Transformer:

Note that you should not place the class inside a package. It should be inside the default package.
import ifs.fnd.base.IfsException;
//app10
import ifs.fnd.connect.xml.Transformer;
//app9
import ifs.fnd.tc.framework.xml.Transformer;

public class javaTransformer implements Transformer {

   @Override
   public void init() throws IfsException {
   }

   @Override
   public String transform(String sIn) throws IfsException {
      return sIn;
   }
}

Example Java Transformer

In this example, we will create a simple java transformer which converts incoming CSV document of accounts to XML format which can be input to IFS with ReceiveAccount BizApi.

Complete code for this transformer can be found in my GitHub.

Given below is the source CSV and the resultant XML from transformer looks

Source CSV and resultant XML using IFS Java Transformer
Source CSV and resultant XML using IFS Java Transformer

Folder structure of the transformer project:

Folder structure of the transformer project

I’ve not used any IDE to create the transformer and trying to minimise usage of other java libraries in this example. You can use your own code structure or IDE and use java libraries compatible with IFS java runtime. Take extra precautions to properly handle exceptions since unhanded errors could lead to severe situations like crashing the middleware or stop integration processing.

Content in the src/csvToXmlApp10.java is self-explanatory and what it basically does is get the file content as a java String and create the XML structure.

Compiling the code:

Open command prompt and navigate to src folder

Make sure you use the recommended JDK for your current IFS version. Using newer JDK version will result in version incompatibility errors in runtime and transformer unusable.
Tip: JDK 1.8 is the used JDK version in IFS Applications 10 and 9.
..\src>javac -d ..\bin -cp ..\lib\ifs-fnd-base.jar;..\lib\ifs-fnd-connect.jar; csvToXmlApp10.java

Testing the Transformer locally

src/testTransformer.java uses the testFiles/accounts.csv CSV file and prints the transformer output. Compile the test file with following.

..\src>javac -d ..\bin -cp ..\lib\ifs-fnd-base.jar;..\lib\ifs-fnd-connect.jar; testTransformer.java

To run the Test class, navigate to bin folder and execute following.

..\bin>java -cp ..\lib\ifs-fnd-base.jar;..\lib\ifs-fnd-connect.jar; testTransformer

Deploying the Java Transformer in IFS

Login to IFS EE and navigate to Setup IFS Connect window. RMB on Trnasformer node, New.

Provide a Transformer name and select JavaTransformer as Instance Type.

Press Load and select the transformer class

Using the Transformer

A transformer can be used to convert incoming documents as well as outgoing documents. In IFS, inbound and outbound document destinations are defined using Routing Address. Multiple transformers can be added to a Routing Address and each transformer is applied in a sequence to the message content.

Routing Address in IFS Applications 10.
Routing Address in IFS Applications 10.

Response Transformers is used to transform the response of synchronous flow and works similar to the message transformer.

IFS provides set of transformers which is helpful in common integration scenarios such as eInvocing, SEPA, Taxation …etc.

2 thoughts on “Working with Java Transformers in IFS

Add yours

  1. Hi Damith,
    I am not clear according to transformer when I create a mapping using third party .

    After creating mappings from third party I get a packaged jar file (for example bizzapi xml from IFS to other xml format), when I execute it independent of IFS it works.

    My question is what do I need to do that with this jar file (for example name: myexample.jar) to import into IFS app8 so that it can be executed? Do I need to create a transformer using IFS Developer Studio and include this jar file (myexample.jar) as a library?

    I think it would be useful if you have any example so I could see how to package it so that IFS app8 consume it. I’ve read the ifs documentation but haven’t found an example that explains this to me to be clear.

    1. Hi Igor,
      If you are transforming XML to another XML format, easiest is to use create a XSLT transformer instead of java.

      However, if you still need to goin your path, you need to create a IFS transformer class and add your jar to do the transformation.

      Here are the steps you need to add a 3rd party jar in your transformer.
      * Create a transformer project in developer studio (you can use sample .zip file used in IFS documentation and open in developer studio)
      * copy the jar to the /lib folder in your project and build the transformer using the classes in your jar
      * modify the build target in the build.xml to include the 3rd party jar file in the transformer

      Eg:


      <target name="build" depends="compile">
      <jar jarfile="${dist}/IFSTestTransformer-1.0.1.jar" basedir="${build}">
      <fileset dir="${lib}" includes="your-external-lib.jar" />
      <manifest>
      <attribute name="Transformer-class" value="TestTransformer"/>
      </manifest>
      </jar>
      </target>

      view raw

      build.xml

      hosted with ❤ by GitHub

Leave a comment

Website Powered by WordPress.com.

Up ↑