Skip to Content

When I started using HCI I faced some problems with the payload logging.
Especially when it comes to an iterating step,

For example HCI is getting some data from SAP ByD, it performs iterating step to do some manipulations on the items one by one, finally it gathers all items to create an XML file in an FTP Server.

The log I expect is like this :
Log ByD
Log Item 1
Log Item 2
.
.
Log Item N
Log FTP server

But since the monitor sorts the attached files by name I get this :

Log ByD
Log FTP server
Log Item 1
Log Item 2
.
.
Log Item N

Imagine that we have a dozen of log files, and everything will be sorted by name, so we wont be able to analyse correctly the flow’s execution.

I added some logic to the Groovy script I’m using to generate a timestamp prefix, to force HCI to sort  it correctly.

Now I’m having this :

08:44:51.674  Log ByD
08:44:51.704  Log Item 1
08:44:51.722  Log Item 2
.
.
08:44:53.174  Log Item N
08:44:53.201  Log FTP server

Bellow is the log script.
You can use it and just change the value ” STEP NAME ” with your step name.

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import com.sap.it.api.mapping.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;


def Message processData(Message message) {

	map = message.getProperties();
	property_ENABLE_PAYLOAD_LOGGING = "TRUE";
	if (property_ENABLE_PAYLOAD_LOGGING.toUpperCase().equals("TRUE")) {
		def header = message.getHeaders() as String;
		def body = message.getBody(java.lang.String) as String;
		
		String timeStamp = new SimpleDateFormat("HH:mm:ss.SSS").format(new Date());
		String logTitle = timeStamp + " STEP NAME ";
		  
		def messageLog = messageLogFactory.getMessageLog(message);
		if (messageLog != null) {
			messageLog.addAttachmentAsString(logTitle, body, "text/xml");
		}
	}
	return message;
}

 

To report this post you need to login first.

6 Comments

You must be Logged on to comment or reply to a post.

  1. Victor SAUVAGEOT

    It has been a few weeks that I am now working with Mohamed Amine on HCI and i can not stop being impressed by his work.
    Nice job and thanks for sharing

     

     

    (1) 

Leave a Reply