SK SKYVVA Documentation

1. How to create an outbound synchronous interface in SAP PI/PO using SKYVVA SAP PI/PO adapter using REST Protocol with JSON format?

How to create an outbound Synchronous interface from Salesforce Skyvva to SAP

1.    Overview

This document describes how to create an outbound synchronous interface from Salesforce to SAP using SAP PI/PO as middleware In Salesforce, we need to use the Skyvva SAP PI/PO adapter and provide the necessary PI/PO details to configure the adapter. Here, in this case we are going to send the account data from Salesforce to PI, where SAP PI/PO adapter will send this data in JSON format. Pre-requisites:

2.    Salesforce Interface Development

2.1  Create Integration in Salesforce

Logon to the Salesforce, and navigate to the Integration.

Click on New to create the new integration. Provide the integration name and save it.

Once Integration is created navigate to the interfaces and click on “New Interface” to create the new interface.

Provide the necessary details to create the outbound interface. In this example, I have created the interface under "SAP PI/PO Integration App V1"

If we use the message type defined in skyvva then we have to do mapping in skyvva as shown.

Now mapping need to be done in the Skyvva interface to push what are the fields need to send from Account S-Object.

Now mapping need to be done in the Skyvva interface to get what are the fields need to get from SAP

Save the mapping and the inbound response interface. Download the inbound and outbound  interface XSD's and upload it into SAP PO for mapping. Parameters:

Name SF_2_SAP_Account_Request_REST_Out

Source/Target Name Account

Status Deployed

Processing Mode Synchronous

Interface Direction Outbound

Connect with Middleware

Outbound Adapter

Now save the interface. Note: Here we need to update the below details in interface.

MetaData provider, Repository and Source/target message type are used in Skyvva standard REST template, which is used by SAP CPI adapter to send the data JSON format. This is the standard template which needs to be used in Skyvva outbound interface for CPI integration. Hierarchy level: MetaData contains Repository, repository contains Source/Target Message type

To create the metadata provider, navigate to the MetaData Providers and create “New” and provide the metadata provider name. Note: Metadata provider name can be anything based on the project naming convention

Once metadata provider created then go down and create “Repository” as shown in below screenshot.

Under the Repository, there is option to create the Message type. Click on new and create message type. Message Type: There are two ways to create message type with the below structure.

Using REST template: (Easy way) To create the message type using REST template, navigate to the below path. Metadata provider > Repositories > Open Editor

Choose filetype as “JSON” and provide Input a JSON format with below JSON text. {

  "REST Service": {

    "Request": {

      "URL": {},

      "Header": {},

      "Body": {

        "Account": {

        }

      }

    },

    "Response": {

      "root": {

        "Account": {

        }

      }

    }

  }

The above is the standard REST template that will used to create message type.

Click on save. Once saved we can find the message type as below.

Now edit the message type to add the TYPE, LEVEL, SEQUENCE NUMBER AND PARENT. Click on action to edit the message type structure.

Update the details like type and other parameters as below.

Similarly, need to update all. E.g. Account

Ensure that message type looks as below.

From the above screen shot, we can find Response where this will be used in the synchronous interface. Message Type Name à REST Service, can be free text where we can use any other name also depends on the project naming convention. If we need different name, we need to define it in the REST template.

Creating Manually: To create below structure, please follow below steps.

To create message type, click on the “New” and provide the message type name, choose the Type, choose the Level, choose the sequence number and choose the Parent. For example, if we need to create the “Account” under Body with type Salesforce object.

Other example, to create the Body in structure

Note: Here Body has child so, we need to check the option “hasChild” Once Metadata provider, Repository name & Message types are created, then add these in Interface. Navigate to interface and add these as shown below.

Now save the interface. Mapping in Skyvva Interface:

Open mapping in interface, please find below screenshot for reference.

We can find the mapping as below which has both source and target structures. Map the fields based on the requirement and save it.

2.3  Create Skyvva SAP CPI adapter

To create the CPI adapter for outbound interface, navigate to the below path. Integration > Details > SAP Control Board > Adapter

Under adapter click on new to create the adapter.

Create a new SAP PI/PO adapter by providing the necessary details.

CPI Adapter Parameters:

Adapter Name CustomerCreation_Rest

Type SAP PI/PO

Direction Outbound

Authentication Type Basic

Status Active

Protocol HTTP

API Service Endpoint URL PI/PO interface endpoint url

Operation POST

Username Test

Password *

RequestFormat JSON

Response Format JSON

Salesforce Id Handling Return Salesforce Id into the Response

Once all the details are provided then save it. Now add the SAP PI/PO adapter in outbound interface under Outbound Setup as below.

2.3  Generate the Skyvva XSD for PI/PO development

Generation of Skyvva XSD (Structure) will be used in PI for PI message transformation. To generate the XSD from interface navigate to below path Integration > Interface > Repository

Under repository, in message types click on “Account” to download the XSD file.

3.    SAP CPI Development

Logon to CPI tenant, navigate to the Design > Packages > Artifacts > Create new integration flow Step: 1 Create the sender HTTPS communication channel and provide the connection parameters.

Step: 2 Import the Skyvva XSD created in Salesforce (refer section 2.3) into SAP CPI system.

Once the source XSD is loaded then import the target structure (in available format) Below is the integration flow created in SAP CPI

  1. Payload Script XML à Script to log the converted XML file

  1. XSLT Mapping à This XSLT mapping is used to add the prefix and namespace to the converted XML. Below XSL code for reference.

5.Payload Script XSLT, Script to log the XSLT payload

  1. Message Mapping,  Source to Target transformation
  1. Payload script After mapping, Script to log the payload after mapping

4.    Testing

4.1 Push the data from Salesforce to CPI using APEX code

Now we are going to push the account data from Salesforce (Skyvva) to SAP CPI. Account data should be available in Salesforce. Please find below screenshot for reference.

To push this data from Salesforce, navigate to Developer console.

Navigate to below path Debug > Open Execute Anonymous Window

Use the below APEX code to trigger the data. //Account_CPI_OB --Interface

skyvvasolutions.CallOutControl c=new skyvvasolutions.CallOutControl();

c.returnJSONComplete=true;

c.actionDoIntegrate=true;

c.isCreateMessage=true;

String[] ids=new String[]{'0011j00001FbXAnAAN'};

skyvvasolutions.Iservices.invokeCalloutV3('CPI Integrate','Account_CPI_Interface_OB',ids,'SYNC', c);

Click on Execute Highlighted to push the data. Now monitor the message in Salesforce and CPI.

4.2 Salesforce message monitor:

Navigate to Message monitoring and provide the details as below.

Click on search In below messages we can notice that message triggered to CPI “Green flag Status”

4.3 CPI monitoring:

Navigate to the Message monitoring in CPI and we can find the respective message in CPI with all logs.

From the above screen shot we can noticed that account data got processed in CPI.

Open this article in the interactive viewer →