Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
sumanth171
Active Participant
6,774
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!
15 Comments
Labels in this area