cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Custom Header in CPI

ZTK196
Explorer
0 Kudos
794

Hi, I added a script in my iFlow to add custom headers in MPL - I'm using the standard script however the custom header still shows in the message log even though the property has no value or equals to null. 
customHeaders.png

 The "po_property" stores a value from a local variable (which I deleted in this scenario) so basically it's considered as null? (correct me if I'm wrong)

Here's my script:

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("Local Variable Test", po_number);		
        }
	}
	return message;
}

Has anyone encountered this or did I miss something? 

Accepted Solutions (1)

Accepted Solutions (1)

PriyankaChak
SAP Champion
SAP Champion

Hi,

Can you change to condition as below instead of if (po_number!=null)?

if (po_number)

Also, have you saved the local variable content in the property? In the below script shared by you, you are trying to retrive the value from header instead of property.

Regards,

Priyanka

 

ZTK196
Explorer
0 Kudos

Yes, I have saved the local variable content in the property - po_number and thank you for your suggestion it works that way. 😄

Answers (0)