SAP-samples / cap-sflight

Using SAP Cloud Application Programming Model and SAP Fiori elements to build a simple travel management app, both with Node.js and Java.
https://cap.cloud.sap
Apache License 2.0
187 stars 131 forks source link
sample sample-code sap-cap sap-fiori sap-fiori-elements

Welcome to the CAP SFLIGHT App

This is a sample app for the travel reference scenario, built with the SAP Cloud Application Programming Model (CAP) and SAP Fiori Elements.

The purpose of this sample app is to:

Process Travels Page

The app still contains some workarounds that are going to be addressed over time. In some cases, the model and the handlers can be improved or simplified once further planned CAP features become available. In other cases, the app itself could be improved. For example, calculation of the total price for a travel currently simply sums up the single prices ignoring the currencies.

For enabling all features of the Analytical List Page (ALP) in the Node.js runtime, we have switched on the new OData parser (odata_new_parser: true in package.json), which is still in an experimental state. Early adopters may use this feature in own projects on their own risk. You can also use the ALP with the standard OData parser, but then some features like grouping in the table are not available.

REUSE status

Run locally

Build and Run - Node.js Backend

Prerequisite:

npm i -g @sap/cds-dk typescript tsx

In the root folder of your project, run

npm ci
npx cds-typer "*"
cds-tsx watch

Build and Run - Java Backend

In the root folder of your project, run

npm ci
mvn spring-boot:run

Accessing the SAP Fiori Apps

Open these links in your browser:

Log in with user amy and empty password.

Integration Tests

To start OPA tests, open this link in your browser: http://localhost:4004/travel_processor/webapp/test/integration/Opa.qunit.html

Test documentation is available at: https://ui5.sap.com/#/api/sap.fe.test

Deployment to SAP Business Technology Platform

The project contains a configuration for deploying the CAP services and the SAP Fiori app to the SAP Business Technology Platform (SAP BTP) using a managed application router. The app then becomes visible in the content manager of the SAP Launchpad service.

The configuration file mta.yaml is for the Node.js backend of the app. If you want to deploy the Java backend, copy mta-java.yaml to mta.yaml.

Prerequisites

SAP Business Technology Platform

Local Machine

Build the Project

Build the project from the command line:

mbt build

The build results will be stored in the directory mta_archives.

Deploy

  1. Log in to the target space.
  2. Deploy the MTA archive using the CF CLI: cf deploy mta_archives/capire.sflight_1.0.0.mtar

Assign Role Collection

Any authorized user has read access to the app. For further authorization, assign a role collection to your user in the SAP BTP Cockpit:

Integrate SFlight with SAP Build Workzone, Standard Edition

CAP SFlight uses the managed AppRouter, which in case of a trial account, is provided by the Launchpad Service in SAP Build Workzone, Standard Edition. Please consult this tutorial to make sure that your Launchpad Service is configured correctly to serve the CAP SFlight Frontend.

Local Development with a HANA Cloud Instance

You need to have access to a HANA Cloud instance and SAP BTP.

  1. Deploy the HDI content to a HANA HDI container (which is newly created on first call): cds deploy --to hana.
  2. Start the application with the Spring Profile cloud.
    1. From Maven: mvn spring-boot:run -Dspring-boot.run.profiles=cloud
    2. From your IDE with the JVM argument -Dspring.profiles.active=cloud or env variable spring.profiles.active=cloud

The running application is now connected to its own HDI container/schema. Please keep in mind that the credentials for that HDI container are stored locally on your filesystem (default-env.json).

Deployment to SAP Business Technology Platform - Kyma Runtime

The deployment to Kyma Runtime is explained in file README-Kyma-Runtime.md.

Creating an SAP Fiori App from Scratch

If you want to implement an SAP Fiori app, follow these tutorials:

Get Support

In case you've a question, find a bug, or otherwise need support, use the SAP Community to get more visibility.

License

Copyright (c) 2022 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file.