SAP Ariba Validate And Enrich with SAP BTP Integration Suite – Part 2

This is part 2 of the 3 series blog. In this series, I will explain the steps to configure, and test Validate and Enrich functionality of the SAP Ariba Procurement Application using BTP Integration Suite.

The content is divided into a series of 3 blogs:

Part 1: Ariba Steps

Part 2: BTP Integration Suite Steps

Part 3: Get URL and Security Credentials from BTP Integration Suite to update them in SAP Ariba Procurement Application’s End Point

Access Integration Suite Cloud Integration Workspace

On the SAP Integration Suite home page, select the Design, Develop, and Operate Integration Scenarios tile.

In the Cloud Integration application, click on the pencil icon (Build and develop integration content) to access the workspace. You will create your integration package and integration flow here.

Click on Create to create a new package

Create Integration Package and Integration Flow

On the Header tab, follow the below steps to create an integration package. Refer to screenshot for sample values.

  1. Give a relevant name for the package you are creating.
  2. Technical Name is auto-populated based on the Name you provided.
  3. Provide a relevant Short Description.
  4. Click on Save.
  5. Select the Artifacts tab. In this tab, you will continue with the creation of the integration flow.

On the Artifacts tab, follow the below steps to create an integration flow. Refer to screenshots for sample values.

  1. Click on Add
  2. Select Integration Flow to display Add Integration Flow screen.

On the Add Integration Flow screen, populate the fields as shown in the screenshot and click on OK.

Click on Save and Open the integration flow you just created.

Follow the below steps to continue building your integration flow.

  1. Click on Edit
  2. Click on Restore. This will display the Properties screen. This is where we configure parameters associated with each step of the integration flow.

Build Integration Flow

Define Sender Channel and Sender Adapter

  1. Click on Sender to display the small circles to the right of Sender.
  2. Click on the circle with ->.
  3. Drag and drop into Start. Adapter Type screen is displayed.

On the Adapter Type screen, select SOAP

On the Message Protocol screen, select SOAP 1.x

On the SOAP property sheet, perform the following:

  1. Click on Connection tab
  2. Provide the Address as /arba/vehandler/ProcessRequisitionExternallyExport.
    • Address should start with a “/”.
    • Address should end with “/ProcessRequisitionExternallyExport” to be compatible with Ariba configurations.
  3. Leave the rest of the fields with default values.

Add VE Response Generator

VE Response Generator is a Script Message Transformer that will host a groovy script to generate the Process Requisition Externally Web Service’s response using the Sample XMLs you prepared earlier.

Below are the steps to create VE Response Generator

  1. On the palette, click on Message Transformer
  2. Select Script to display Script screen.

On the Script screen, Select Groovy Script. Mouse cursor will change into a script icon.

Move the mouse cursor to the intended place in integration flow as shown in the screenshot and click. This will add a step to the integration flow.

  1. Click on the Groovy Script Message Transformer step you just added to the integration flow to display the Groovy Script Properties screen.
  2. Click on the General tab.
  3. Provide a name of your choice as shown in the screenshot.
    • The name you provide will be reflected on the corresponding step of the integration flow as well.

Groovy Script to generate Process Requisition Externally Web Service Response

Download this groovy script and save it in your local with a “.groovy” extension. For instance, let’s name it as arbve.groovy

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;
}

On the Groovy Script properties sheet:

  1. Click on Processing tab
  2. Click on Select
  3. Click on Upload from File System
    • Choose the groovy script you saved in your local. (arbve.groovy)

  1. Groovy script will appear as shown in the screenshot.
  2. Click on Save
  3. Click on Deploy
  4. Click on the eye icon (Operate and monitor integration scenarios)

Next in Series

SAP Ariba Validate And Enrich with SAP BTP Integration Suite – Part 3