Skip to Content
Technical Articles
Author's profile photo Santhosh Kumar Vellingiri

SAP CPI – A Guide to MPL Search

**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

  • Application ID set to Customer Number from IDOC, however, I also require a search based on IDOC number.
  • Application ID set to Order Number from message sent over message broker, however, I also require a search based on Message-ID from Message broker.

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.



Set Application ID

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

Also, extract the IDOC number into a header field.

IDOCNUM XPath XPath to IDoc number field i.e /DEBMAS07/IDOC/EDI_DC40/DOCNUM


Content Modifier

Set Custom Header

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.


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
			messageLog.addCustomHeaderProperty("IDOCNUM", IDOCNUM);		
	return message;

Message Processing Log

This is how the MPL is for a BP 1000000001 processed with IDoc 0000000123456789.

Standard MPL Headers

Search based on Application ID

This is a straight forward search in SAP CPI Message processing Monitor. A search for ID “1000000001” yields two messages processed for this BP.

Search based MPL Headers

Search based on Custom Header ID

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=Name 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.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Fatih Pense
      Fatih Pense

      Hello Santhosh,

      Nice find in the APIs! I hope it is only a matter of UI update and not about indexing/performance. Maybe someone from SAP can enlighten us ๐Ÿ™‚


      Author's profile photo Santhosh Kumar Vellingiri
      Santhosh Kumar Vellingiri
      Blog Post Author

      Hi Fatih,

      Thanks for your comment ? I guess itโ€™s indexed, but SAP can enlighten us.

      Is this something you could give us in the SuperEasy extension in the meantime ?


      Author's profile photo Fatih Pense
      Fatih Pense

      Hi Santhosh,

      If it will make one of your daily tasks easier, sure! ๐Ÿ™‚ I will try to find a good UI logic. Do you need to search for multiple Custom Header Properties with "and", "or"? I haven't tried, but the API should support it since it is an OData service.


      Author's profile photo Santhosh Kumar Vellingiri
      Santhosh Kumar Vellingiri
      Blog Post Author

      Hi Fatih,

      Thanks for offering help ๐Ÿ™‚

      Usual ODATA filter conditions with "and", "or" etc should be supported. It's good to have a basic search with just one custom header, to begin with.


      Author's profile photo Daniel Graversen
      Daniel Graversen

      Nice search option. My guess is this is not indexed, so it could be used with caution.


      Author's profile photo Kader Kara
      Kader Kara

      Nice blog , thanks for the trickย  Santosh.

      Likely SAP have also read this and add the custom header properties in the search criteria ย no need to use this manual API so ๐Ÿ‘๐Ÿ‘๐Ÿ‘

      Author's profile photo Philippe Addor
      Philippe Addor

      Hi Santhosh

      Of course, it's up to every interface designer or organization to decide on this. But: In my opinion it's more sensible to write a technical message ID of the application to the standard MPL header "SAP_ApplicationID". In case of SAP senders, that would be an IDoc number or the XI message ID. After all, the search field in the monitor is the same as for CPI's own message and correlations IDs. Also, like this we don't mix up too many different IDs (with different meanings) into this one field.

      Instead, I usually use the custom MPL headers for interface/scenario specific identifiers, like an order or invoice number, for example. There, you have the advantage that you can specify the individual names of the fields.

      Best regards,


      Author's profile photo Florian Guppenberger
      Florian Guppenberger

      Whic client do you ouse to retrieve the values?