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: 

Introduction

Today I'm going to show you how to create your own OData source and use it with SAP Web IDE.

There is a free to use OData source provided by SAP and for this OData source you also have source code so if you are interested, you can modify and create your own customized OData provider. This OData source is a Java application named ESPM: once built, you can install it inside the HCP and consume its provided data by building apps with the SAP Web IDE tool.

Prerequisites

The only prerequisites for this are:

1. JAVA JDK installed with JAVA_HOME variable properly defined

2. An account to the HANA Cloud Platform  (you can also use Trial Landscape and this is what we are going to use here)

3. A GIT Client. If you haven't one installed yet, you can download it from http://git-scm.com/downloads according to your workstation's requirements. During the installation pay attention to switch to the option "Use Git from the Windows Command Prompt", otherwise you won't be able to use Git from the Windows shell

Steps

1. Install Apache Maven

2. Clone the ESPM repository

3. Compile the source code

4. Install the war package in the HCP and create a destination to the new application

5. Test the new OData source by building a test app

6. Import the Java source code in Eclipse

Let's get started!

1. Install Apache Maven

This could have been listed among the above prerequisites, but since this kind of software is not so commonly installed on every developer's machine I prefer to show here how to download and install Apache Maven.  Apache Maven is a software project management and comprehension tool. Based on the concept of a Project Object Model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. The latest version at the moment I'm writing is 3.3.9.

  • Once done, unzip the file somewhere on your machine. For example I've extracted it under the path c:\apache-maven
  • Now you need to setup a couple of environment variables:
    • add Maven to the path;
    • define the M2_HOME variable
  • For the first variable, you just need to open the Control Panel\System and Security\System and click on the Advanced system settings link

  • From here, click on the Environment Variables button. Among the System variables, locate the variable "Path" and click on Edit. Just append the string ";c:\apache-maven\bin" at the end of the existing one and click on OK.

  • For the second variable you need to create a new one. Click on the New button just below the system variables, define the following and click on OK:

  • This is what you should see at the end

  • Now if you open the Windows terminal and type the command "mvn -version" you should get the following result:

2. Clone the ESPM repository

The ESPM repository is located on the SAP Github website. You can access it by clicking on  https://sap.github.io/index.html?sort=asc&filter=featured and then searching for the keyword ESPM.

  • Click on the Sample OData Delta-Token-Enabled Web Service link

  • Copy the link to the repository in the clipboard

  • Create a new folder on the C drive (i.e. espy) and run the clone command in this folder through the Windows Command Prompt


git clone https://github.com/SAP/cloud-espm-scenarios.git


You should get something like this

  • The ESPM repository has been successfully cloned on your machine.

3. Compile the source code

It's time now to compile the source code.

  • Go inside the new folder named "sap_mobile_platform_espm_olingo_services" with the command

cd C:\espm\sap_mobile_platform_espm_olingo_services

  • Enter the command

mvn clean install

  • You should get something like this:

  • Looking in the target folder you should find the file ESPM_V1.war. This file will be installed in the HANA Cloud Platform in the next chapter

4. Install the war package in the HCP and create a destination

  • Browse for the .war file we just created at the previous step and assign it a new name. As a Runtime Name choose Java Web and then click on Deploy

  • The deployment phase takes some time. Once done, click on the Start button to start it immediately

  • The application starts and you can check its status from the HANA Cloud cockpit. Write down or copy in the clipboard the application URL because it will be used to create a destination to this application

  • Click on the Destinations tab and create a new destination with the following parameters:
ParameterValue
NameESPM
TypeHTTP
Description

ESPM

URL<the application URL copied previously>
Proxy TypeInternet
AuthenticationNo Authentication

  • Define also the following additional properties:
PropertyValue
TrustAlltrue
WebIDEEnabledtrue
WebIDESystemESPM
WebIDEUsageodata_gen

  • This is how the new destination looks like at the end

5. Test the new OData source by building a test app

We can test the new OData provider by creating a test application with SAP Web IDE

  • Open SAP Web IDE
  • From the File menu choose New --> Project from Template. Select for example the SAP Fiori Worklist Application and give a name to the project (i.e. TestESPM)

  • On the Data Connection step, select the Service URL source, select the ESPM destination we created previously, provide the path to the resource (i.e. "/ESPM_V1/api/") and click on the Play button to show the services available. Then click on Next

  • Enter the following details and click on Next

  • Click on Finish
  • Congratulations! You have successfully consumed your own OData source with your new Fiori application

6. Import the source code in Eclipse

As a final step in this blog, you might want to import the source code in Eclipse so that you can change it and update your .war file. In order to import the source code you need first to generate the Eclipse project containing it.

  • Open a Windows Command Prompt and go to the folder where the top level pom.xml file is located. In our case it should be: "C:\espm\sap_mobile_platform_espm_olingo_services"
  • Once in this folder run the command:

mvn eclipse:clean eclipse:eclipse

  • This will generate the project to import. Now open eclipse and click on File --> Import
  • Choose General --> Existing project into workspace
  • Browse for the folder C:\espm\sap_mobile_platform_espm_olingo_services and import the project. You can now start modifying your Java code.

NOTE: Remember that each time you change the anything in the project, you need to re-generate the .war file and update it inside the HCP