Skip to Content
Technical Articles
Author's profile photo Anil Yakkali

CPI Messages processed Report

CPI implementations happening very fast and during hyper care, many customers interested to see the message statistics in middleware systems. In PI/PO, we have a link to download the interfaces processed excel file with success and failed count for each interface.

In CPI standard Monitoring there are filters available but the table view for all the interfaces status count is missing. CPI team has to manually verify the message count and update in the report. To resolve this mundane time consuming task, a custom iFlow can be used to generate a report and forward to right stakeholders.

The iFlow can be cloned or downloaded from git repository Link . Below fields selected from the MessageProcessingLogs Resource from CPI Odata API.

Fields: MessageGuid,LogStart,LogEnd,IntegrationFlowName,Status,IntegrationArtifact

Below script is used to set start and end times.

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.time.TimeCategory

def Message processData(Message message) {
def properties = message.getProperties();
int s_Minutes = properties.get("Minutes").toInteger();
def currentDate = new Date()
LogEnd = (currentDate.format("yyyy-MM-dd'T'HH:mm:ss"))
use( TimeCategory ) {
logStart = currentDate -  s_Minutes.minutes
}
LogStart = (logStart.format("yyyy-MM-dd'T'HH:mm:ss"))
message.setProperty("logStart", LogStart);
message.setProperty("logEnd", LogEnd);
return message;
}

A mapping created for the transformation of MPL response to custom structure needed for XML to CSV conversion. Below 2 scripts used at mapping level for aggregation of messages count for each interface.

Calculation of completed messages for each interface.

def void completedCount(String[] status, String[] iflow, Output output, MappingContext context){
    
    def count = 0;
    
    for(int i=0;i<=iflow.length-1;i++){
        count = 0;
        for(j=0;j<=status.length-1;j++){
            if(status[j].contains(iflow[i]) && status[j].contains("COMPLETED"))
            {
                count++;
            }
        }
        output.addValue(count);
    }
}

Calculation of Failed messages for each interface.

def void FAILEDCount(String[] status, String[] iflow, Output output, MappingContext context){
    
    def count = 0;
    
    for(int i=0;i<=iflow.length-1;i++){
        count = 0;
        for(j=0;j<=status.length-1;j++){
            if(status[j].contains(iflow[i]) && status[j].contains("FAILED"))
            {
                count++;
            }
        }
        output.addValue(count);
    }
}

Configure Odata, Mail channel externalized parameters and deploy the integration flow.

The output report will be generated as below.

With the help of this iFlow, the developers / support team time will be saved for 30 – 60 minutes by avoiding the report preparation. Feel free to enhance the iFlow based on the business requirements.

 

Happy Learning!

Assigned Tags

      14 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Sanjaya Kumar Bihari
      Sanjaya Kumar Bihari

      Great post Anil.

      Author's profile photo Anil Yakkali
      Anil Yakkali
      Blog Post Author

      Thanks Sanjay:)

      Author's profile photo Fatih Pense
      Fatih Pense

      Hello Anil,

      Thanks for sharing this "Message Overview" for CPI!

      Regards,
      Fatih

      Author's profile photo Anil Yakkali
      Anil Yakkali
      Blog Post Author

      Thanks Fatih. Happy you checked this post.

      Author's profile photo Syambabu Allu
      Syambabu Allu

      Hi Anil,

      Yes,it’s need this kind of tool in Support.

      Thank you for sharing!

      Thank you,

      Syam

      Author's profile photo Anil Yakkali
      Anil Yakkali
      Blog Post Author

      Thanks Syambabu.

      Author's profile photo Saurabh Kabra
      Saurabh Kabra

      Superb Anil. This will definitely save a lot of time of consultants who want to report all messages being processed by CPI.

      Author's profile photo Anil Yakkali
      Anil Yakkali
      Blog Post Author

      Thanks Surabh.

      Author's profile photo Jagadish Babu Parri
      Jagadish Babu Parri

      Excellent Post..
      Hi All,

      Even i have the similar requirement. Could some one can help me how to generate report for Messages from DATA STORE with Overdue and WAITING status

      Author's profile photo Anil Yakkali
      Anil Yakkali
      Blog Post Author

      Hello Jagadish,

      Thanks for appreciating. I checked for data store feature in standard OData API but seems it doesn't exists at this moment. In future if SAP release an entity, we can work on it.

      Regards,

      Anil

      Author's profile photo satish b
      satish b

      Hi Anil.

      Thanks for your Post on message status report!

      I have follwoed your steps and designed the IFLOW but getting the below error, Could you please help here?

      com.sap.gateway.core.ip.component.odata.exception.OsciException: An exception of type 'WstxUnexpectedCharException' occurred., cause: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '=' (code 61); expected a semi-colon after the reference for entity 'client_id' at [row,col {unknown-source}]: [1,1013]

       

      Regards,
      Satish

      Author's profile photo Mohd Mukheed
      Mohd Mukheed

      HI Satish,

       

      Just change the url to runtime url in configuration of iflow, you will get runtime url in service key.

       

      Regards

      Mukheed

      Author's profile photo satish b
      satish b

      Thanks for your reply.

      Author's profile photo satish b
      satish b

      After changing URL, issue got resolved. Thanks for your support.!.