Groovy script to print comments/texts in the attachment in SAP CPI
I have searched a lot about how to print the comments using Groovy script (for reference whether the flow is executing or not without storing the payload) in CPI. But I couldn’t find any blogs, so I’m posting this.
Here using Groovy script, I am printing the comments/texts (whatever we want) in the attachment of SAP CPI environment. Just to check whether the flow has been completed or not.
<comments is the variable declared to get the value to be displayed>
Use the below script in Groovy Script
def Message processData(Message message)
def comments=”Hello Groovy script”;
def messageLog = messageLogFactory.getMessageLog(message);
messageLog.addAttachmentAsString(“ResponsePayload:”, comments, “text/plain”);
Once deployed, in Monitoring — go to Attachment, then you will see the logs and the commesnts will be displayed like below in the log.