Thursday, May 12, 2022

Groovy Script to read the data whenever C4C sends SAP_UUID or not. If SAP_UUID is not able then it will store Payload Logging using Groovy Script.

First using Request Reply we need to connect C4C(Cloud for Customer) System. From the C4C system it will send SAP_UUID some time it won't send SAP_UUID. If it's not send SAP_UUID then we need to store Payload Logging using below Groovy scripts.


Using Content Modifier, We need to store SAP_UUID after using groovy. We can check whether SAP_UUID is available or not.

Groovy Scripts:

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();

def SAP_UUID1=map.get("SAP_UUID")    

if(SAP_UUID1.equals(""))
{
def body = message.getBody(java.lang.String) as String;
def messageLog = messageLogFactory.getMessageLog(message);
if (messageLog != null) {
messageLog.addAttachmentAsString("C4C_Error_Response:", body, "text/xml");
 }
}
return message;
}

Router Condition:

After the Groovy script we need to use the router and check if SAP_UUID is not available at the end of the iflows, If SAP_UUID is available then it will go further.










No comments:

Post a Comment

The sender will pass the data in JSON format without converting it to XML format. We need to read the particular field.

The sender will pass the data in JSON format without converting it to XML format. We need to read the particular field to check the conditio...