import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.xml.*
def Message processData(Message message)
{
def messageLog = messageLogFactory.getMessageLog(message);
def msgBodyOrig = message.getBody(java.lang.String) as String;
def xml = new XmlSlurper().parseText(msgBodyOrig);
//Get Requisition Id from SOAP Request. This will be included in the response dynamically
def reqid = xml.Requisition_ProcessReqExtHeaderDetails_Item.item[0].UniqueName.text();
//Groovy code sample to get EventName value from message body - Approve, Submit etc
//def eventname = xml.Requisition_ProcessReqExtHeaderDetails_Item.item[0].EventDetails.EventName.text();
//Groovy code sample to get header custom field value from message body. Custom field name is VEUpdate and type String
//def veupdate = xml.Requisition_ProcessReqExtHeaderDetails_Item.item[0].custom.'*'.find { node -> node.name() == 'CustomString' && node.@name == 'VEUpdate' }.text();
//This block of code is needed only if the validation has failed and need to send the SOAP response with error message. The error message will be displayed to user on SAP Ariba Procurement Application UI
def validationmsg = "<urn:ValidationError_ValidateErrorImport_Item> <!--Zero or more repetitions:--> <urn:item> <!--You may enter the following 3 items in any order--> <urn:Date>2022-02-22T16:37:14Z</urn:Date> <!--Optional:--> <urn:ErrorDetails> <!--Zero or more repetitions:--> <urn:item> <!--header level error - need not specify line and split number--> <urn:ErrorCategory></urn:ErrorCategory> <urn:ErrorCode>100</urn:ErrorCode> <urn:ErrorMessage>Error Message to display on UI</urn:ErrorMessage> <urn:FieldName>cus_VEUpdate</urn:FieldName> <urn:LineNumber></urn:LineNumber> <urn:SplitNumber></urn:SplitNumber> </urn:item> </urn:ErrorDetails> <urn:Id>" + reqid + "</urn:Id> </urn:item> </urn:ValidationError_ValidateErrorImport_Item>";
def sucfail = "Success"; //Use sucfail = Failure value to test failed validation with error message
//If validation is successfull then validation block of the response is not needed. Set it to empty string
if(sucfail == 'Success') {
validationmsg = '';
}
//Groovy code sample to log to Integration Suite logs
//messageLog.setStringProperty("Log-Key", "Value to Log");
//This is the main body of response going to SAP Ariba Procurement Application
//Enriches a custom field called VEUpdate = true
def msgDummy = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:Ariba:Buyer:vrealm_3\"> <soapenv:Header> <urn:Headers> <!--You may enter the following 2 items in any order--> <!--Optional:--> <urn:variant>?</urn:variant> <!--Optional:--> <urn:partition>?</urn:partition> </urn:Headers> </soapenv:Header> <soapenv:Body> <urn:ProcessRequisitionExternallyExportReply partition=\"?\" variant=\"?\"> <!--You may enter the following 3 items in any order--> <!--Optional:--> <urn:Requisition_ProcessReqExtValidationStatusResponseImport_Item> <!--Zero or more repetitions:--> <urn:item> <!--You may enter the following 3 items in any order--> <!--Optional:--> <urn:EventDetails> <urn:StatusResponse>" + sucfail + "</urn:StatusResponse> </urn:EventDetails> <urn:UniqueName>" + reqid + "</urn:UniqueName> </urn:item> </urn:Requisition_ProcessReqExtValidationStatusResponseImport_Item> <!--Optional:--> <urn:Requisition_ProcessReqExtEnrichResponseImport_Item> <!--Zero or more repetitions:--> <urn:item> <urn:UniqueName>" + reqid + "</urn:UniqueName> <urn:custom> <urn:CustomString name=\"VEUpdate\">true</urn:CustomString> </urn:custom> </urn:item> </urn:Requisition_ProcessReqExtEnrichResponseImport_Item>" + validationmsg + "</urn:ProcessRequisitionExternallyExportReply> </soapenv:Body> </soapenv:Envelope>";
message.setBody(msgDummy);
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 |
---|---|
6 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |