Groovy Examples

Go to list of examples

MPL Custom Header Property

MPL Custom Header Property

You can add additional metadata to your MPL log with this script. It will show up in Logs > Open Text View

Search with more than one identifier

Normally you can only add single identifier to search with SAP_ApplicationID. This feature enables storing several identifiers at the same time like IDoc number, PO number, etc. and searching them.

Since 2021 January, this field is included in the standard monitoring fields, so it should be indexed and fine to use.

SAP Community Blog for explaining the feature https://blogs.sap.com/2020/09/13/sap-cpi-a-guide-to-mpl-search/

Script

Try it on Groovy IDE
import com.sap.gateway.ip.core.customdev.util.Message;

def Message processData(Message message) {
    
	def messageLog = messageLogFactory.getMessageLog(message);
	if(messageLog != null){

		def po_number = message.getHeaders().get("po_number");		
		if(po_number!=null){
			messageLog.addCustomHeaderProperty("po_number", po_number);		
        }
	}
	return message;
}

Input Headers

Key Value
po_number 1234567890