**Updated on 07/Dec/2020 for Custom Status**
Most of us already know that the ID based message search in SAP CPI is limited to Message ID or Correlation ID or Application ID. In this blog let us explore on using more Searchable Identifier(s).
While Message ID and Correlation ID are technical identifiers generated by CPI, we are left with just Application ID to set a process/functional identifier like Purchase Order Number, Sales Order Number, Customer Number, etc. This helps to search the MPL based on the business identifier for monitoring/troubleshooting.
However, in my SAP CPI journey, there were multiple instances where I had a need to have more than one ID to use for MPL search, for eg
I achieved this use case by setting the additional ID as a Custom Header in MPL. Let us see in this blog on implementing it.
Let us see the implementation in a scenario where a DEBMAS IDoc is sent for Business Partner Replication. We would set BP Number as Application ID and IDoc Number as Custom Header. Then we see how to search MPL based on both these IDs.
Use the Content Modifier step to set the below standard MPL headers.
SAP_Sender | Header | Constant | Sender System Name |
SAP_Receiver | Header | Constant | Receiver System Name |
SAP_MessageType | Header | Constant | Message Type |
SAP_ApplicationID | Header | XPath | XPath to read the business identifier i.e. /DEBMAS07/IDOC/E1KNA1M/KUNNR |
SAP_MessageProcessingLogCustomStatus | Property | Constant | Custom Status |
IDOCNUM | XPath | XPath to IDoc number field i.e /DEBMAS07/IDOC/EDI_DC40/DOCNUM |
Use the groovy script to read the IDoc Number extracted in Content Modifier and set it as a Custom Header using addCustomHeaderProperty method of MessageLogFactory Interface.
import com.sap.gateway.ip.core.customdev.util.Message;
def Message processData(Message message) {
def messageLog = messageLogFactory.getMessageLog(message);
if(messageLog != null){
//Read IDoc number from Header
def IDOCNUM = message.getHeaders().get("IDOCNUM");
//Set IDoc number as Custom Header
if(IDOCNUM!=null)
messageLog.addCustomHeaderProperty("IDOCNUM", IDOCNUM);
}
return message;
}
This is how the MPL is for a BP 1000000001 processed with IDoc 0000000123456789.
This is a straight forward search in SAP CPI Message processing Monitor. A search for ID "1000000001" yields two messages processed for this BP.
The standard UI does not allow us to search message based on the Custom Header Identifier OOTB. Hence we will use MPL OData API to retrieve the Message ID.
https://{{cpi_tmn_host}}/itspaces/odata/api/v1/MessageProcessingLogCustomHeaderProperties?$filter=Na... eq 'IDOCNUM' and Value eq '0000000123456789'&$expand=Log&$format=json
Note: Custom Header is inserted as a Name/Value pair, hence the $filter parameter should be passed with the Custom Header Name and the value that we are searching for.
The API Call fetches the Message ID matching the custom header search condition. Use it in the standard Message Processing monitor to search and troubleshoot.
Use the Custom Header to Insert one or more searchable identifiers. However, use it wisely as any wrong usage can lead to a large MPL size on the tenant. I also hope that in a future update SAP will enable us to search messages based on Custom Header in the Monitor UI. Until then we could use the SuperEasy extension from fatih.pense.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
9 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 | |
4 | |
3 |