Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
DenizZilyas
Participant
11,345

Introduction

What is Open Connectors?

Open Connectors is a set of pre-built connectors that can be used to connect to systems and services without the need for custom coding. It offers over 160 ready connectors.

We can use Open Connectors to simplify, standardize, and accelerate connections with third-party cloud applications. Open Connectors provide open RESTful APIs and support JSON data format services.

Open Connectors can automate critical business processes, eliminate manual data entry, and reduce the risk of errors. They ensure data consistency across systems and work seamlessly without the need for extra code. Additionally, you can transport your connectors to a different environment in JSON format.

Whether connecting SAP systems to external applications, integrating cloud applications, or synchronizing data across various systems, Open Connectors simplify and accelerate the integration process, ultimately helping your business achieve its digital transformation goals.

It is a component of the SAP Integration Suite, and you can easily add this capability to the integration suite.

SAP Open Connectors enable users to connect to various applications, services, and data sources through APIs. They are designed to be user-friendly, making it easy for SAP customers and developers to configure and manage integrations. You can use standard open protocols to ensure the consistency of the integration process and compatibility across different platforms.

SAP Open Connectors aim to facilitate the flow of data between different application ecosystems and optimize business processes, ultimately making processes more efficient.

 

DenizZilyas_0-1706697716499.png

                                                  Open Connectors Relations with Cloud Integration

 

Prerequisites:

  • SAP BTP account (Open Connectors supports trial accounts)

Now, I will demonstrate how to use Open Connectors.

Firstly, we need to add Open Connectors as a capability on the Integration Suite's Home screen. After that, we must assign the role related to Open Connectors to our user.

Step 1:Integration Suite --> Capabilities --> Manage Capabilities

DenizZilyas_1-1706697716504.png

 

Step 2: Click on Add Capabilities

DenizZilyas_2-1706697716505.png

 

Step 3: Select Extend Non-SAP Connectivity

DenizZilyas_3-1706697716509.png

 

Step 4:Click on Create Connectors

DenizZilyas_4-1706697716511.png

 

OPEN CONNECTORS

We will be working on Google Drive. Therefore, we are selecting Google Drive from the connectors.

  • Connectors--> Google Drive--> Resources--> Authenticate instance.

DenizZilyas_5-1706697716515.png

I am creating an instance named 'Files'.

DenizZilyas_0-1706722942570.png

 

After this step, you will be redirected to a different page to integrate with Google Drive. You can connect it to your desired Gmail account. The Cloud Elements V2 application is requesting access permission. You must accept this.Once permissions are granted, your connector will be integrated with your Google Drive.

 

GET METHOD

Firstly, I will demonstrate how to download a file from Google Drive using the GET method.

I want to access and download the 'response.xml' file inside a folder named 'testing' on Google Drive. Then, press the Execute button.

DenizZilyas_1-1706723028373.png

                                                                 Get Method Google Drive

It shows a 200 HTTP status, indicating that the service has run successfully, and we have communicated with Google Drive to retrieve the specified file. After saying 'Download file', our 'response.xml' file is now accessible locally.

DenizZilyas_2-1706723086399.png

 

POST METHOD

If we want to upload a file under the 'testing' folder, we should use the POST method.

Note:The folder id is where the file should be uploaded to, this is required when calculateFolderPath is set to false. If calculateFolderPath is set to true and folderId is provided, then the folderId will be ignored. folderId is of higher priority, so if the path parameter is also provided, then it will be ignored.

DenizZilyas_7-1706723724770.png

DenizZilyas_4-1706723322900.png

                                                                         POST Method

After selecting our file, we execute. We can verify by checking the 'testing' folder.

DenizZilyas_11-1706697716548.png                                                                        Testing Folder

 

DELETE METHOD

If we want to access and delete a file within a folder, we can use the DELETE method. Similarly, we should specify the path of the file we want to delete. And click on Execute.

DenizZilyas_12-1706697716553.png

                                                                     Delete Method

We can check our folder again.

DenizZilyas_13-1706697716554.png

We made a change to the file and would like to note it as a comment. We can do this using the methods provided by our connector.

Let's say there was a change in the Personnel field, and I want others to see this.We should use the POST method.

DenizZilyas_5-1706723623372.png

 

                                                                 Comment in document

When we go to the document in the 'testing' folder, we should be able to see this.

DenizZilyas_6-1706723659465.png

So far, we have been executing ready APIs through the Open Connectors interface. Now, if we want to perform a scenario in CPI, how should we proceed? Our goal is to use CPI to receive, pull, or delete a file. Let's proceed with a simple scenario.

First, we will use the POST method to upload a file to Google Drive. After 10 seconds, we will delete the file from the folder using the DELETE method.

 

END TO END SCENARIO WITH CLOUD INTEGRATION

1-Firstly, my sender adapter should be HTTPS. I will create a CPI link and make my call through this link, specifying an endpoint. If we are using a POST method for a CSRF-protected resource, we should remove the check; otherwise, we may receive a 403 error from the service.

 

DenizZilyas_0-1706708777458.png

DenizZilyas_9-1706710149698.png

                                                              Sender Adapter Informations

2-The goal is to be able to upload an XML, TXT, XSD, etc., file to Google Drive. We need to access the service's header information in Connectors. Accordingly, we will make the definition in the content modifier.

DenizZilyas_17-1706697716567.png

                                                     The header information of the service

DenizZilyas_1-1706708869766.png

                                                                    Content Modifier Headers

3-After defining the headers, I need to add a Groovy script to ensure a healthy submission as form data.

 

 

 

import com.sap.gateway.ip.core.customdev.util.Message

import javax.activation.DataHandler

import javax.mail.internet.ContentType

import javax.mail.internet.MimeBodyPart

import javax.mail.internet.MimeMultipart

import javax.mail.util.ByteArrayDataSource



Message processData(Message message) {

    byte[] bytes = message.getBody(byte[])

    //  Construct Multipart

    MimeBodyPart bodyPart = new MimeBodyPart()

    ByteArrayDataSource dataSource = new ByteArrayDataSource(bytes, 'image/jpeg')

    DataHandler byteDataHandler = new DataHandler(dataSource)

    bodyPart.setDataHandler(byteDataHandler)

    bodyPart.setFileName('response.xml')

    bodyPart.setDisposition('form-data; name="file"')



    MimeMultipart multipart = new MimeMultipart()

    multipart.addBodyPart(bodyPart)



    // Set multipart into body

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream()

    multipart.writeTo(outputStream)

    message.setBody(outputStream)



    // Set Content type with boundary

    String boundary = (new ContentType(multipart.contentType)).getParameter('boundary');

    message.setHeader('Content-Type', "multipart/form-data; boundary=${boundary}")



    return message

}

 

 

 

4-As per the scenario, I will first upload 'response.xml' under the 'testing' folder, and 10 seconds later, the file will be deleted from this folder. That's why I used a sequential multicast.

Branch 1 = POST, Branch 2 = DELETE.

The file transfer will be completed upon the completion of the POST method.

DenizZilyas_2-1706709058543.png

                                                                            POST Method

5-When Branch 1 is completed, and Branch 2 (DELETE) is entered, a Groovy script named 'delay' will run before the DELETE method, and the transferred file will be deleted after 10 seconds from Google Drive.

 

 

 

import com.sap.gateway.ip.core.customdev.util.Message;

import java.util.HashMap;

def Message processData(Message message) {

    sleep(10000);

    return message;



}

 

 

 

DenizZilyas_3-1706709479433.png

                                                                       DELETE Method

6-In the content modifier, we can easily add a message to the Message Body indicating that the file has been deleted.

DenizZilyas_4-1706709544231.png

                                                      Content Modifier Response Text

7-Save the flow and deploy.

DenizZilyas_5-1706709577222.png

                                                                  Save And Deploy

8-To test it with Postman, I need the CPI link, username, and password. After entering the necessary information in the respective fields in Postman, click 'Send.'

DenizZilyas_9-1706724055484.png

                                                                               Postman

DenizZilyas_24-1706697716586.png                                                                    Check Google Drive

9-To check, you can open the trace of the flow from monitoring and examine it in detail.

DenizZilyas_10-1706724355209.png

                                                                         The file content

10-When testing the CPI link generated from the deployed flow in POSTMAN, it is advisable to use an exception subprocess to capture detailed errors. If we don't add an exception, we can analyze the 500 error returned from the service after monitoring. Returning the error as a response along with the error code will make the integration more efficient.For this reason, I added exception handling. I enriched the status and code of the error with a Groovy script. The code content is as follows.

 

 

 

import com.sap.gateway.ip.core.customdev.util.Message;



def Message processData(Message message) {



// get a map of iflow properties

def map = message.getProperties();



// get an exception java class instance

def ex = map.get("CamelExceptionCaught");

if (ex!=null) {



// an http adapter throws an instance of org.apache.camel.component.ahc.AhcOperationFailedException

if (ex.getClass().getCanonicalName().equals("org.apache.camel.component.ahc.AhcOperationFailedException")) {



// save the http error response as a message attachment

def messageLog = messageLogFactory.getMessageLog(message);

messageLog.addAttachmentAsString("http.ResponseBody", ex.getResponseBody(), "text/plain");



// copy the http error response to an iflow's property

message.setProperty("http.ResponseBody",ex.getResponseBody());



// copy the http error response to the message body

message.setBody(ex.getResponseBody());



// copy the value of http error code (i.e. 500) to a property

message.setProperty("http.StatusCode",ex.getStatusCode());



// copy the value of http error text (i.e. "Internal Server Error") to a property

message.setProperty("http.StatusText",ex.getStatusText());



}

}



return message;

}

 

 

 

The content can be enriched with the use of more methods. The crucial point to note is that if the file already exists inside, the service may return an error and not overwrite it. To reflect the error in the response, an exception subprocess can be added to the integration.

 

 

 

 

 

 

2 Comments
Labels in this area