Technical Articles
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!
Great post Anil.
Thanks Sanjay:)
Hello Anil,
Thanks for sharing this "Message Overview" for CPI!
Regards,
Fatih
Thanks Fatih. Happy you checked this post.
Hi Anil,
Yes,it’s need this kind of tool in Support.
Thank you for sharing!
Thank you,
Syam
Thanks Syambabu.
Superb Anil. This will definitely save a lot of time of consultants who want to report all messages being processed by CPI.
Thanks Surabh.
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
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
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
HI Satish,
Just change the url to runtime url in configuration of iflow, you will get runtime url in service key.
Regards
Mukheed
Thanks for your reply.
After changing URL, issue got resolved. Thanks for your support.!.