Skip to Content
Author's profile photo Bhavesh Kantilal

HCI – Payload Logging using Groovy Scripts – Part 2 – Use Externalized Parameters


As discussed in my previous blog, HCI – Payload Logging using Groovy Scripts logging of payloads should be used prudently. Typically you would like the logging to be disabled and have options to enable this only on a need basis.

If you are from a PI background, you would be well aware of parameters like TRACE_LEVEL, LOGGING_SYNC and Integrated Configuration Logging Options that enable you to turn on / off logging & staging when required. So how can this be done in HCI using the Groovy scripts we described in the previous blogs?

Externalized Parameters in HCI

Some background first – HCI enables you to define parameters that can be controlled externally in your Integration Flow. Typical examples of these are SOAP/HTTP URLs, FTP Server Host,etc which will typically vary in each environment. There is already content on Externalized Parameters for HCI on SCN and would recommend you read that or the corresponding documentation from SAP – Externalizing Parameters of Integration Flow

To be able to define Logging Dynamically we will be using a custom Externalized Parameters, so you can enable and disable logging without having to make changes to your Integration Flow or the Groovy script.

Integration Flow Changes

We will continue to use the sample Integration Flow described in my previous blog with an additional Content Modifier Step and some changes in the Groovy script as described below.


Step Description
Delta Changes
Content Modifier
  • The  New Content Modifier step is used to read the External Parameter into a local property.
  • Name = logger ( Message Property to be used in the Groovy Script )
  • Type = External Parameter
  • Data Type = java.lang.String
  • Value = externalParamLogger ( Name of the External Parameter whose value will be set externally )


Groovy Script Change
  • Read Message Properties
  • Read the value of property logger as set in the previous content modifier step
  • If Logger is set to 1, then log the payload else, do not perform any logging.

import java.util.HashMap;
def Message processData(Message message) {
    def body = message.getBody(java.lang.String) as String;
    def messageLog = messageLogFactory.getMessageLog(message);
    def propertyMap = message.getProperties()
    //Read logger from the Message Properties
    String logger = propertyMap.get("logger");
        if(messageLog != null){
            messageLog.setStringProperty("Logging#1", "Printing Payload As Attachment")
            messageLog.addAttachmentAsString("ResponsePayload:", body, "text/plain");
  return message;

Setting of Externalized Parameters

Once the Content Modifier step is defined, the Externalized Parameters tab should contain the Parameter with the name as defined in our Content Modifier step. In this case: externalParamLogger. Set the default value of the Parameter as 0 (Zero). Save and Deploy your Integration Flow.


Test your flow with External Parameter Value set to 0

Trigger your Integration flow with the External Parameter Value set a 0. The Integration Flow executes and the Groovy Script does not log the payload as the value is set to 0. As seen in the image below no attachment is available.


Test your flow with External Parameter Value set to 1

To update your external parameters, navigate to Window –> Show View –> Other. In your Show View dialog box, navigate to Other –> Configurations


In the Configurations Pane that opens, navigate to your project and double click on the same. In my case the name of my project is – Prj_PayloadAsAttachment

Go to Externalized Parameters tab and update the value of externalParamLogger as 1 and click on Save Parameters


Right Click on your project in Configurations –> Deploy Integration Content. Your Integration Flow is now updated to have the Logging Enabled!


Re-trigger the Interface and you should see the logs with the attachment as the Logger is now set to Value 1.


Final Note

As seen in this blog, Externalized Parameters provide you with options to provide parameters to your Integration flow dynamically. This along with some smart Groovy Scripting enables you to dynamically control payload logging.

Assigned Tags

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

      Well explained.


      Author's profile photo Former Member
      Former Member

      Hi Bhavesh,

      Good blog bhavesh,

      One doubt, as explained how to use the externalized parameters in SOAP for trigger or in SFTP. (Via  the SOAP UI )

      Thanks in advance,

      Author's profile photo Bhavesh Kantilal
      Bhavesh Kantilal
      Blog Post Author

      Hello Vijay,

      This help link is a good starting point on how to Externalize Parameters for the adapter's in question. Externalizing Parameters

      Author's profile photo Jay Malla
      Jay Malla

      Hi Bhavesh,

      We are not able to create an external parameter for the Content modifier exchange property as it is greyed out:


      We can set this up in Eclipse:

      When we deploy, the deployment is successful - but the content modifier still does not show this property.  Seems like a issue with SAP HCI.  Is there a work around to do this?  It seemed like this feature was not supported in the Web UI so it was recommended to create the external parameter through Eclipse but it's not working.

      Thanks for your help in advance.






      Author's profile photo Jay Malla
      Jay Malla

      I did the same steps as per your BLOG:


      Deployment shows successful - but when I open this up in Web UI - it still has the old constant that I had defined in the Web UI.  So somehow the issue is with the deployment it seems.


      Any ideas why this is not working?







      Author's profile photo Manoj Pothuganti
      Manoj Pothuganti

      Hi Jay ,


      We too had the same issue. we tried the below steps and it worked.

      1. Make the changes as per the blog.
      2. Copy the artifact to your local drive.
      3. And zip only META-INF, src, .project, (ignore : log,bin,.settings folders)
      4. Go to web UI and route to your corresponding Artifact.
      5. From Actions--> Vew Metadata--> Edit and upload the previously zipped file.
      6. Now finally deploy from the web ui.




      Author's profile photo Jay Malla
      Jay Malla

      Hi Manoj,

      The best way that I found was to import the flow into Eclipse and make the changes there.  Then you have to export the flow as an archive zip file.  You have to replace the flow in the WebUI.  I don't know why it is taking SAP so long to add this functionality to the WebUI.  But it is taking way too long to have this simple functionality implemented.



      Author's profile photo Manoj Pothuganti
      Manoj Pothuganti

      Hi Jay,

      I think your wish is fulfilled now.

      1. We are able to import and export easily now with zip files.
      2. And now the functionality to Externalize the other Content modifier types also enabled. Like Constant, Expression etc...




      Author's profile photo Jay Malla
      Jay Malla

      Thakns Manoj - That's great news!  So now we don't have to keep on switching between the HCI web development interface and Eclipse.


      Author's profile photo Marco SILVA
      Marco SILVA

      Hi all,

      I still have the "External parameter" option grayed out:

      Were you able to define this kind of parameter thru CPI web interface?


      Marco Silva

      Author's profile photo naveen arockiaraj c
      naveen arockiaraj c

      Hi All,

      As per Payload Logging, I am storing data as request and response payloads in Message Monitoring logs. How i will delete the payload Logging logs. Please suggest me the way how to delete.



      Author's profile photo Dilip Mehra
      Dilip Mehra

      Hi Everyone,


      This is a very nice blog .But at that time the web ui had limitations that it could not handle external parameter at content modifier.But latest version of Content modifer has solution to it.

      Please follow below link: