cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to get the ExchangeId, messageId in SAP CPI in main Iflow

sinhasouvik
Participant
0 Kudos
1,762

Hi Experts,

I am working in scenario where SAP CPI is inserting the data to SFSF. If something fai,l in response CPI will send the error response back to Sender with below format. But I am not able to get the MessageId, Exchnage id , IFLOW name in main integration flow.

But in Exception sub process it is working fine.

 def ExchangeID = ${exchangeId};
def MessageID = ${id};
def Timestamp = ${date:now:dd-MM-yyyy HH:mm z};
def IFlowName = ${camelId};

I am using the above expression in code to get the values.

Could you please help us how do I get the values?

regards,

Souvik

Accepted Solutions (1)

Accepted Solutions (1)

Sriprasadsbhat
Active Contributor

Hello Souvik,

You can put a content modifier and set property of type Expression and use all above as value.

For message id use value ${header.SAP_MessageProcessingLogID}

Regards,

Sriprasad Shivaram Bhat

sinhasouvik
Participant
0 Kudos

Thanks Sri for the quick response.

Regards,

Souvik

Answers (2)

Answers (2)

r_herrmann
Active Contributor

Another option, if you want to access the Simple Expression results in Groovy script without adding a Content Modifier upfront, would be to interpret the Simple Expressions in Groovy like:

import com.sap.gateway.ip.core.customdev.util.Message
import org.apache.camel.builder.SimpleBuilder

def Message processData(Message message) {	
        def simple = SimpleBuilder.simple('${exchangeId}')
	def ExchangeID = simple.evaluate(message.exchange, String)
	//Do whatever you want to do with the exchange id
	return message
}

Follow this guide from engswee.yeoh if you want to learn more about it: https://blogs.sap.com/2018/04/05/using-camels-simple-in-cpi-groovy-scripts/

sinhasouvik
Participant
0 Kudos

Thanks Raffael for the alternative option.

Regards,

Souvik

MortenWittrock
Active Contributor

Hi Souvik

You are combining Groovy (the def stuff) and the Simple Expression Language (the ${...} stuff) in a way that doesn't work.

The easiest way to reuse your Simple expressions, is to add a Content Modifier and create four properties (type "Expression") to store the values of your expressions. Then access those properties in a Groovy script using message.getProperty('property-name-here').

Regards,

Morten

sinhasouvik
Participant
0 Kudos

Thanks Morten for the clarification. it is resolved now.

Regards,

Souvik