Skip to Content
style=”font-size:10pt;”>In this blog we will take a quick look at one of the ways to raise runtime exceptions in XI mapping so that it terminates the processing.

We came across a scenario in our project where we had to look up a database table for populating a particular element value in our message mapping. During mapping execution (runtime), if the database was not available for some reason then we had to raise an exception to terminate the process.

Steps involved:

1.Create a java program which connects to the DB table to access the required field(s). Handle Runtime exceptions appropriately.

2.Import this java program as archive into XI.

3.Create a user-defined function which uses this java program to access the table and utilize the retrieved value in your message mapping.Handle exceptions appropriately.

4.Create a Java Mapping program which Raises the exception and terminates the process.Import it as an archive.

5.Include this Java mapping program as the second step in your Interface mapping.

Let me take you through an example scenario to understand how we raised a message mapping exception. In the sample mapping snippet(“File_to_DB”) shown below, there are four input values (EMPID,EMPNAME,CIRCLE,DEPT), utilizing which we do a database lookup using the user-defined simple function “deriveValue” and map the value to IDDAT field.

image

The user-defined function “deriveValue” utilizes the method “getFieldValue” available in the DBLookUp class to access the database table.Runtime exception is thrown whenever there is a database connection error as shown in the code snippet below:

Under normal conditions i.e., when the database connectivity is available, the DESIG value returned from the database table will be populated for the IDDAT field. If there is some problem with the connection then the runtime exception will be raised.

image

This runtime exception is caught and an appropriate message is added using the “Mapping Trace Object”. In this example, we have added a warning message “Mapping Error …Restart Possible”. You can also addInfo or addDebugMessage. At runtime this warning message will be shown in the XI monitor when you point your mouse on the red flag. When the exception is caught, note that I’m populating the “sDesigcode” with a string “MappingTransformationError”. This value is returned by the user-defined function and it will be populated in the element IDDAT of the transformed XML message. Why do we do this? Let me explain.

image

The following is the Java Mapping program that we have used to terminate the process at runtime and raise a runtime exception. The functionality of this program is to check the transformed XML message of the message mapping “File_to_DB” for the string “MappingTransformationError”. If this string is available in the transformed XML message then the runtime exception “Mapping Error Occurred” is raised terminating further process. If this string “MappingTransformationError” is not available in the output XML message then the process proceeds to next step of execution at runtime.

The Java mapping provided above is generic enough and can be used by anyone who needs to raise exceptions.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply