Skip to Content

SAP PI / XI: Interface Message Filtering Utility

SAP PI / XI: Interface Message Filtering Utility

Applies To:

SAP XI 3.0, PI 7.0 and 7.1, 7.3 and SAP PO

Summary:

This paper discusses how to identify & filter out the flawed records from the source file based on certain conditions.

Author:

Anupam Chakraborty

Sudip Kumar Paul

Prasanna Vittal

Created: January 6th 2014.

Introduction

More often than not, while dealing with business interfaces, we have situations where we encounter issues with data, leading to the failure of the complete interface even though only a small percentage of the data has issues. Hijacking business for such reasons is uncalled for and can be avoided in certain cases. If could identify & filter out the flawed records from the source message based on certain conditions(business rule), and only pass the correct records to the target system, then we can get our job done. The flawed records(data) can be written to a separate file/error logs which business can review and correct at a later point of time.

This approach can be generalized and can be achieved by a utility a.k.a. Filtering utility which could be made plug-and-play and configuration only.

IT Requirement

  • The input message coming into SAP PI might contain flawed records(data issues).
  • While the mapping gets executed, it fails entirely since there is error in one/few of the records.
  • The idea is to filter the message before the mapping gets called so that the maps get executed only with the correct records, whereas the bad records are sent back to some file server as-is.


This Utility (Java class) can be used by just plugging it into any message mapping. No development time is required. Only some additional configuration needs to be done, which will be explained in the next section.

Solution

The salient features of the solution are as follows:

  • Generic solution which could be re-used across multiple interfaces
  • Configuration only solution; no development time required for each interface once the solution is completed.
  • This solution is parameterized so that it is flexible enough to cater to different kind of requirements.

The solution works as follows:

  • Java Mapping is used for filtering the erroneous records from the good ones.
  • The good records are then mapped to the required target message and pushed forward.
  • The erroneous records are written to a file and sent to a specific location
  • An alert is raised with the location where the error file is written.

The Filtering Utility(Java class) written for filtering the records is capable of doing the below functionality:

  • Fields to be checked and conditions for the fields are read from Value Mapping. The value mapping is based on the Sender Component, Sender Service Interface and the Receiver Component. This way we can uniquely identify the value mapping set for each interface.
  • Parsing the xml message and breaking down into good and bad records.
  • The filtering of good and bad records is done based on certain condition checks on specific fields.
  • For any message, if the header is wrong, then the entire message is considered as erroneous.

Implementation Guide

Let us consider an example of a File Server sending an XML file to SAP. Below is the structure of the source message:

The requirement is that, we need to filter out all the records that contain a blank for the field MaterialNumber


1.1       Design Steps

  1. Import the Java Map CheckXPath.jar as an imported archive

  2.  Create a one to one graphical mapping by using the above structure on both the sides.

4 . Provide details under long and short text.

1.4 Alert Configuration in RWB

  1. Go to ‘Alert Configuration’ under Runtime Workbench.
  2. Click on ‘Add Rule’, and provide our sender interface name and save the rule.

3. Attachment Guide Content

Java Mapping Source

No comments
Comments are closed.