SAP-archive / cloud-espm-v2

This sample is a reference application project, showcasing an end-to-end development scenario for a Java-based app on SAP BTP. The app has a SAPUI5 web frontend, uses OData to connect to a Java-based cloud backend which in turn connects via JPA to an SAP HANA DB in the cloud.
https://open.sap.com/courses/hcp2-1
Apache License 2.0
104 stars 85 forks source link
espm sample sample-code sap-btp sap-hana sap-hana-db sapui5

Important Notice

This public repository is read-only and no longer maintained.

Enterprise Sales Procurement Model (ESPM) Application

The ESPM (Enterprise Sales & Procurement Model) application is a reference application which demonstrates how to build applications on SAP Business Technology Platform (BTP) with the Java runtime. The application also consumes and showcases services like the Persistence Service, Document Service, SAP Jam Collaboration, and API Management which are offered by the platform. The application User Interface (UI) is built with the SAPUI5 framework after the SAP Fiori design principles.

Demo URL of the application https://espmrefapps.hana.ondemand.com/espm-cloud-web/webshop/

Business Scenario

The business scenario is that of an eCommerce site that sells electronic products.

Usecase Diagram

Get the Source Code

Clone the Git repository or download the latest release.

1. Quick start guide

Setting up the developer environment

  1. Install Oracle Java SE Development Kit (JDK) 8 and set up the JAVA_HOME and PATH environment variables on your local machine.
  2. Install Eclipse. Please install Eclipse Oxygen.
  3. (Optional: Only if you use SAP JVM) Set up SAP JVM in Eclipse.
  4. Install SAP Development Tools for Eclipse. Please use the link for Eclipse Oxygen.
  5. Install SAP Business Technology Platform SDK. Please install Java Web Tomcat 8.
  6. Register for a free developer account on SAP Business Technology Platform, follow the tutorial.

Build the application and deploy

Below are the steps to build and run the ESPM application:

1.Git configuration in Eclipse
2.Maven configuration
3.Clone Git repository and import Maven project
4.Update dependencies and build Maven project
5.Deploy the application on local Cloud Runtime
6.Deploy the application on SAP BTP via the cockpit
7.Bind the database to espm application and start espm application

1.Git configuration in Eclipse

EGit Configuration

Note! For most people the proxy value doesn’t need to be set but if you are working behind a proxy, then it should be set as per you environment.

2.Maven configuration

Maven Settings Configuration

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <localRepository>${user.home}/.m2/repository</localRepository>
    <profiles>
        <profile>
            <id>development</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
            </properties>
        </profile>
    </profiles>
    <proxies>
        <proxy>
            <active>true</active>
            <protocol>http</protocol>
            <host>proxy</host>
            <port>8080</port>
        </proxy>
    </proxies>
</settings>

Note! For most people the proxy value doesn’t need to be set, you can remove the entire proxy section from the snippet, but if you are working behind a proxy, then it should be set as per you environment.

3.Clone Git repository and import Maven project

Repo URL

Git Clone

4.Update dependencies and build Maven project

The unit tests and the integration tests are run by default when building the project with goal "clean install"

5.Deploy the application on local Cloud Runtime

i)Run the application in BTP Java Web Tomcat 8 Server

Run ESPM Locally

Run ESPM Finish

ii)Create Users and Assign Role

Create User locally

6.Deploy the application on SAP BTP via the cockpit

Note! The application name must be "espm", else the above URL will change based on the application name given during deployment

1.Go to BTP Cockpit --> Click on Java Application under Applications --> Click on Deploy Application

BTP Cockpit

2.Add War File Location, Give Application Name "espm" ,select Runtime Name "Java Web Tomcat 8" and JVM Version "JRE 8"

BTP Deploy

3.After Successful Deployment , Click on Start

Deployed

You can access the application from the URL

Note! The application name must be "espm", else the above URL will change bsaed on the application name given during deployment

7.Bind the database to espm application and start espm application

Below is the process to bind the database to the java application in BTP trial account using a Shared HANA database

Demo script for ESPM Webshop

Demo script for ESPM Retailer-SalesorderApproval

Demo script for ESPM Retailer-StockUpdate

Documentation for Document Service

Documentation for SAP JAM Integration

2.Deep-dive guide

Architecture Overview

The following diagram provides an overview of the ESPM Sample application architecture:

Architecture Diagram

Reading the above architecture diagram from top to bottom, we have the following components

The ESPM Sample Application is a Maven based project which has a parent pom.xml file and 2 sub projects as below

The JPA Class diagram

JPA Class Diagram

ESPM Source Code packages

The espm-cloud-jpa has the following packages:

espm-cloud-web has the following packages:

The UI is located in webapps folder. The frontend is implemented in SAPUI5.

Securing OData Services

Web.xml for security

Secure URL

Secure URL

After deploying the application in BTP, assign the Retailer role to the user who will act as the retailer of the eCommerce site. Please refer to documentation of SAP Business Technology Platform on how to assign roles to users.

Important Disclaimers on Security and Legal Aspects

This document is for informational purposes only. Its content is subject to change without notice, and SAP does not warrant that it is error-free. SAP MAKES NO WARRANTIES, EXPRESS OR IMPLIED, OR OF MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.

Coding Samples

Any software coding and/or code lines / strings ("Code") included in this documentation are only examples and are not intended to be used in a productive system environment. The Code is only intended to better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, unless damages were caused by SAP intentionally or by SAP's gross negligence.

Copyright and License

Copyright 2016 SAP SE

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at: http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.