
Log/Store payloads using write data store operation in any required integration process. I will not cover many details on this topic. In the current scenario I am storing the payloads in data store: DS_Payloads:
StorePayload
Step 2: Create an iFlow:
Main iFlow
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="xml" encoding="utf-8" omit-xml-declaration="yes"/>
<!-- Stylesheet to remove all namespaces from a document -->
<!-- template to copy elements -->
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<!-- template to copy attributes -->
<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
<!-- template to copy the rest of the nodes -->
<xsl:template match="comment() | text() | processing-instruction()">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>
import com.sap.gateway.ip.core.customdev.util.Message
import java.util.HashMap
import com.sap.it.api.ITApiFactory
import com.sap.it.api.mapping.ValueMappingApi
import groovy.xml.MarkupBuilder
import groovy.time.*;
def Message processData(Message message)
{
def a = ITApiFactory.getApi(ValueMappingApi.class, null);
def body = message.getBody(java.lang.String) as String;
def Test = new XmlParser().parseText(body);
def writer = new StringWriter();
def builder = new MarkupBuilder(writer);
def ToBeDeleted = []
def ID = []
def TimeDuration = []
String Create = '';
builder.Target
{
'Record'
{
Test.entry.each {
it.properties.each{
def mappedValue = "${it.Id[0].text()}";
if ( mappedValue.equals("") || mappedValue ==null )
{
ToBeDeleted.push("No")
}
else
{
Create = "${it.CreatedAt[0].text()}"
def CreatedAt = Create.substring(0,19)
CreatedAt = CreatedAt.replace("T", " ")
def Newdate = Date.parse("yyyy-MM-dd HH:mm:ss",CreatedAt)
def Currentdate = new Date()
TimeDuration duration = TimeCategory.minus(Currentdate, Newdate);
TimeDuration.push(duration)
if(duration.getDays() > 3){
ToBeDeleted.push("Yes")
ID.push(mappedValue)
}
}
}
}
}
'Id'(ID)
}
// Generate output
message.setBody(writer.toString())
message.setProperty("ToBeDeleted", ToBeDeleted)
message.setProperty("EntryID", ID)
message.setProperty("TimeDuration", TimeDuration)
return message;
}
Delete Message Logs: Sub process to delete data store entries
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import groovy.json.*;
def Message processData(Message message) {
def body = message.getBody(java.lang.String) as String
def DelEntryID = message.getProperties().get("EntryID")[0]
def ToBeDeleted
if ( DelEntryID.equals("") || DelEntryID ==null )
{
ToBeDeleted= 'No'
}
else{
ToBeDeleted= 'Yes'
}
message.setProperty("DelEntryID", DelEntryID)
message.setProperty("ToBeDeleted", ToBeDeleted)
return message;
}
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import groovy.json.*;
def Message processData(Message message) {
def body = message.getBody(java.lang.String) as String
//Remove EntryID from lookup list
def packages = message.getProperties().get("EntryID").reverse() as Stack
packages.pop()
packages = packages.reverse() as Stack
message.setProperty("EntryID", packages)
return message;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 |