Skip to Content
Technical Articles

CPI Runtime Artifacts Error Alert Process

In my previous blog I had discussed about interface for message monitoring excel report generation but I recently got a question from one of my client as what happens when a deployed interface failed in runtime with any issue? This blog will provide the solution for this behavior.

An Integration flow created for error alert notification process which will monitor runtime artifacts deployed in CPI tenant. In case of an artifact went to error state, this Iflow will send an alert to distribution list or mailing list configured in interface.

The interface zip file can be download from Git repository click here

Design pointers:

Timer is externalized and set to run for every 1 hour, change it as necessary.

OData entity: IntegrationRuntimeArtifacts to get artifact information and status.

Filter = Status equals to ERROR.

In case of error, the iflow ID will be captured using content modifier and pass to HTTP channel.

HTTP channel URL: https://<<CPI Tenant Host>>/api/v1/IntegrationRuntimeArtifacts(‘${}’)/ErrorInformation/$value

Response from HTTP channel is in JSON format. Use groovy script to parse JSON data and capture error information. Message body for alert notification prepared in the same script.

import java.util.HashMap;
import groovy.json.*;

def Message processData(Message message) {
    //Get Body 
    def body = message.getBody(String.class);
    def jsonSlurper = new JsonSlurper()
    def payload = jsonSlurper.parseText(body)
    def error = payload.childInstances.parameter
    //Get Properties
    def map = message.getProperties();
    def if_name = map.get("name")
    //prepare message body
    body = "<HTML><BODY>"+
                        "<P>Hi Team<BR><BR>"+
                        "An Interface is in Error in CPI. Please find the details below.<BR><BR>"+
                        "<B>IFlow Name: </B>"+ map.get("name") +"<BR>"+ "<B>ErrorMessage: </B>"+error+"<BR><BR>"+"Regards,<BR>"+"SAP CPI Admin <BR><BR>" +
                 "***This is an autogenerated email for Errors in SAP CPI tenant***"+
    //set message body
    return message;

Message body prepared in HTML format. So used the Body content type as Text/HTML. The sample error notification as below.

Hope this will be useful for consultants and suggestions are welcome. Happy Learning!

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