Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Punith_Oswal
Participant
5,993
As members of the Integration team, we frequently encounter requests from both the sender and receiver teams to trace specific messages based on a key value. Currently, searching for these individual messages within a large stack can be quite laborious.

By introducing custom headers, we can simplify this task. These headers would allow us to store key fields associated with each message, which can then be displayed on the monitor page. This way, we can easily search for messages using the values stored in these custom headers, significantly reducing the effort required to locate a particular message from the heap of stacked messages.

To streamline our integration process, I highly propose implementing custom headers as a solution.

To incorporate custom headers effectively, we can employ a brief Groovy script immediately after the component responsible for receiving the input file within the integration flow (iflow).

Scenario:

In the scenario of integrating SuccessFactors with a third-party (Ariba) system, where we receive input in XML format, we can utilize the "person_id_external" field (employee number) as a key identifier. To simplify message tracing for specific employees, we propose assigning this key field to a custom header called EMPID.

By implementing this approach, we can populate the EMPID custom header with the employee number value during the integration process. Subsequently, when there is a need to track a particular employee, we can conveniently leverage the EMPID custom header on the monitoring screen. This enables us to swiftly locate and trace the relevant messages associated with the desired employee, streamlining the overall monitoring and troubleshooting process.

 

Input : I just used a small piece of input file here

<?xml version='1.0' encoding='UTF-8'?>
<queryCompoundEmployeeResponse>
<CompoundEmployee>
<id>681</id>
<person>
<created_by>wlutes</created_by>
<created_on_timestamp>2016-12-21T01:05:56.000Z</created_on_timestamp>
<date_of_birth>1995-08-28</date_of_birth>
<last_modified_by>rbajoria</last_modified_by>
<last_modified_on>2017-04-26T08:24:54.000Z</last_modified_on>
<logon_user_id>2011823</logon_user_id>
<logon_user_is_active>false</logon_user_is_active>
<logon_user_name>12345</logon_user_name>
<person_id>681</person_id>
<person_id_external>2044298</person_id_external>
</person>
</CompoundEmployee>
</queryCompoundEmployeeResponse>

 

Groovy Script :

I have used XmlSlurper to parse the input XML in this script, the script will change based on the input format.
import com.sap.gateway.ip.core.customdev.util.Message;

import java.util.HashMap;

import java.lang.*;

import groovy.xml.MarkupBuilder;



def Message processData(Message message)


{

def messageLog = messageLogFactory.getMessageLog(message);

def body = message.getBody(java.lang.String) as String;

if(messageLog != null)


{

        def doc = new XmlSlurper().parseText(body);


        String str = "";


        doc.'**'.findAll { it.name() == 'person' }.each

        {

            str=it.person_id_external.text();

            messageLog.addCustomHeaderProperty("EMPID", str);

        }

}


return message;

}



Thats all, Now lets see how to search the message in the monitoring screen.





Monitoring Page:



Once you have selected the Artifact name, proceed to click on the "Use more fields" filter. Within this filter, you will find the "Custom Header" option. Here, you can input the Custom header name and its corresponding value, which in this case would be the employee you are searching for.



After entering the Custom header name and value, simply press the enter key. The monitoring screen will then display the message(s) associated with the specified employee, allowing you to easily locate the desired information. You can refer to the image below for a visual representation of this process.




 

I hope this is helpful, comment if you think we can enhance this script in a better way.

 

Cheers,

Punith
1 Comment
Labels in this area