Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
The Web Service Layer for Cloud Connector (WSL4CC) utility is designed to solve a very particular problem.

Problem


Say you're interested in integrating with an on-premise SAP ERP through the SAP Cloud Platform (Neo) and SAP Cloud Connector. Currently, you are required to develop and deploy a Java web application to the SAP Cloud Platform and make use of the SAP Java Connector (JCo) library to invoke the RFC/BAPI functions on the on-premise SAP ERP remotely.

  • Don't have the time or inclination to develop, test and maintain the Java/JCo web application?

  • Want to skip building the Java/JCo web application and start integrating right away?


If yes, then WSL4CC is your answer! Read on.

Solution


WSL4CC is a pre-built Java/JCo web application that can be deployed to the SAP Cloud Platform and which exposes a RESTful web service endpoint that allows you to quickly and easily invoke RFC functions on your on-premise SAP ERP through the Cloud Connector!

As input, WSL4CC accepts a JSON document with the name of the BAPI and the input parameters and tables. For example, the following JSON input body instructs WSL4CC to invoke the BAPI named STFC_CONNECTION with the specified REQUTEXT parameter.
{
"name": "STFC_CONNECTION",
"input": {
"REQUTEXT": "The quick brown fox jumps over a lazy dog."
}
}

WSL4CC will invoke the specific BAPI with the input parameters and tables synchronously. It returns a JSON output with the status of the invocation along with an error message (only if an error occurred) and the output parameters and tables.

For example, the following output indicates that the status of the invocation was successful and the export parameters were ECHOTEXT and RESPTEXT.
{
"status": "OK",
"message": null,
"output": {
"ECHOTEXT": "The quick brown fox jumps over a lazy dog.",
"RESPTEXT": "SAP R/3 Rel. 740 Sysid: ABA Date: 20180523 Time: 153720 Logon_Data: 800/IDADMIN/E"
},
"tables": null
}

This was a simple example to illustrate the most basic use case. WSL4CC supports input and output tables and other parameter types.

A more illustrative and realistic example is shown below. In this input, WSL4CC is instructed to execute the BAPI_CUSTOMER_FIND function in order to find a customer whose name begins with the phrase Royal British. The search clause is provided as an element of the SELOPT_TAB input table. Here is the complete input body:
{
"name": "BAPI_CUSTOMER_FIND",
"input": {
"MAX_CNT": 100,
"PL_HOLD": "X"
},
"tables": {
"SELOPT_TAB": [
{
"COMP_CODE": "1000",
"TABNAME": "KNA1",
"FIELDNAME": "NAME1",
"FIELDVALUE": "Royal British *"
}
]
}
}

WSL4CC automatically interprets and translates the input parameters and tables and executes the RFC. When execution is completed successfully, it returns an HTTP status 200 and the output data as shown below. The output parameters and tables are converted back to JSON and returned to the user.

It's important to note that WSL4CC does not change any names or values. It simply translates the RFC output into JSON and returns back to the caller.
{
"status": "OK",
"message": null,
"output": {
"RETURN": {
"TYPE": "S",
"ID": "FN",
"NUMBER": "800",
"MESSAGE": "No errors have occurred",
"LOG_NO": "",
"LOG_MSG_NO": "000000",
"MESSAGE_V1": "",
"MESSAGE_V2": "",
"MESSAGE_V3": "",
"MESSAGE_V4": ""
}
},
"tables": {
"RESULT_TAB": [
{
"COMP_CODE": "1000",
"TABNAME": "KNA1",
"FIELDNAME": "NAME1",
"FIELDVALUE": "Royal British Rail",
"CUSTOMER": "0000001500",
"PSTG_BLK_G": "",
"PSTG_BLK_C": "",
"DEL_FLAG_G": "",
"DEL_FLAG_C": "",
"TYPE": "S",
"ID": "FN",
"NUMBER": "800",
"MESSAGE": "No errors have occurred",
"LOG_NO": "",
"LOG_MSG_NO": "000000",
"MESSAGE_V1": "",
"MESSAGE_V2": "",
"MESSAGE_V3": "",
"MESSAGE_V4": ""
}
],
"SELOPT_TAB": [
{
"COMP_CODE": "1000",
"TABNAME": "KNA1",
"FIELDNAME": "NAME1",
"FIELDVALUE": "Royal British *"
}
]
}
}

Endpoint


The endpoint that WSL4CC exposes is shown below. The destination name must be configured as an RFC destination on the SAP Cloud Platform.
POST https://{hostname}/wsl4cc/destinations/{dest}/rfc

HEADERS
-------
Content-Type: application/json
Accept: application/json
Authorization: {Bearer token generated by OAuth2}

BODY
----
{JSON document as shown in examples above}

The parameter {hostname} is the hostname in the Application URL of the wsl4cc java application that you downloaded and deployed to the SAP Cloud Platform (see installation instructions below)

and {dest} is the name of the RFC destination that is configured to point to the SAP ERP instance. The creation and setup of the RFC destination is described in the following blog starting with section 4.4:

https://blogs.sap.com/2015/07/13/cloud-connector-a-brief-guide-for-beginners

Installation


You may download the latest WSL4CC software from the following GitHub repository. Look under releases tab for a pre-built, downloadable wsl4cc.war file. Installation instructions can be found in the README.md file. WSL4CC is completely secure and protected using OAuth2 over a secure https connection.

https://github.com/sunilwadhwa/wsl4cc

Feedback


Please post and comments or feedback here in the blog. I'd love to hear your experience with this utility and if it was useful to you. Thanks.
8 Comments