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

/wp-content/uploads/2016/02/02_875423.jpg

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.

/wp-content/uploads/2016/02/01_875424.jpg

  • 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

/wp-content/uploads/2016/02/03_875425.jpg

  • 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.

/wp-content/uploads/2016/02/04_875462.jpg

  • 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:

/wp-content/uploads/2016/02/05_875463.jpg

  • This is what you should see at the end

/wp-content/uploads/2016/02/06_875464.jpg

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

/wp-content/uploads/2016/02/08_875477.jpg

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

/wp-content/uploads/2016/02/09_875479.jpg

  • Copy the link to the repository in the clipboard

/wp-content/uploads/2016/02/10_875489.jpg

  • 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

/wp-content/uploads/2016/02/11_875490.jpg

  • 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:

/wp-content/uploads/2016/02/13_875491.jpg

  • 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

/wp-content/uploads/2016/02/14_875513.jpg

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

/wp-content/uploads/2016/02/16_875514.jpg

  • 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

/wp-content/uploads/2016/02/17_875515.jpg

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

/wp-content/uploads/2016/02/18_875516.jpg

  • 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

/wp-content/uploads/2016/02/19_875517.jpg

  • Click on the Destinations tab and create a new destination with the following parameters:
Parameter Value
Name ESPM
Type HTTP
Description

ESPM

URL <the application URL copied previously>
Proxy Type Internet
Authentication No Authentication
  • Define also the following additional properties:
Property Value
TrustAll true
WebIDEEnabled true
WebIDESystem ESPM
WebIDEUsage odata_gen
  • This is how the new destination looks like at the end

/wp-content/uploads/2016/02/20_875518.jpg

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)

/wp-content/uploads/2016/02/21_875547.jpg

  • 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

/wp-content/uploads/2016/02/23_875548.jpg

  • Enter the following details and click on Next

/wp-content/uploads/2016/02/24_875558.jpg

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

/wp-content/uploads/2016/02/25_875559.jpg

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.

/wp-content/uploads/2016/02/26_875638.jpg

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

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply