Showcase of two UI5 user interfaces, one built with freestyle SAPUI5 (or rather OpenUI5), the other using SAP Fiori elements, with a CAP backend, using OData V4 with Draft mode.
This app uses simple attendee registration and administration for events as an example scenario for demonstrating the data handling and overall setup. The app consists of three parts: an end-user UI implemented in freestyle SAPUI5, a metadata-driven administrator UI generated with Fiori elements and a Node.js-based CAP backend. While the code implements a complete end-to-end full-stack app, it is kept as simple as possible and the main focus is on freestyle SAPUI5 code making use of OData V4 as well as of "Draft" functionality to persist non-final datasets.
Further details about how the functionality is implemented can be found in the documentation.
- Node.js (latest LTS version which supports npm workspaces)
- SAP CAP CLI (do
npm install -g @sap/cds-dk
) - sqlite3 (only needed separately on Windows, commandline tools zip need to be downloaded, extracted, and directory added to the PATH)
-
Clone the project.
git clone https://github.com/SAP-samples/ui5-cap-event-app cd ui5-cap-event-app
-
Use npm to install the dependencies.
npm i
Execute the following command to run the project locally for development (start the CDS server running the admin UI and form UI embedded):
npm start
As also shown in the terminal after executing this command, the CDS server is running on http://localhost:4004/.
For the form UI, you can use user name employee@test.com
with password 123
. For the admin UI, use admin@test.com
and password 123
.
Execute the following command to build the project and get one integrated app that can be deployed (build the form UI, admin UI, and CDS server):
npm run build
Prerequisite: npm run build
runs cds build
in the CDS server package which requires @sap/cds-dk
. Please ensure to install @sap/cds-dk
globally via:
npm i -g @sap/cds-dk
After building the individual packages, the build results will be copied to the central dist
folder. The resulting package inside the dist
folder consists of the CDS server hosting the form UI and the admin UI as well as a sandbox Fiori launchpad to start the individual UIs.
To start the generated package, just run npm install
and npm start
inside the dist
folder. This installs the dependencies and starts the CDS server hosting the UIs. Now the sandbox Fiori launchpad can be opened on http://localhost:4004/.
We have prepared two ways of debugging the Node.js part of the app easily:
The launch configuration "debug server in vscode" is part of the project and can be used to run the CAP server in debug mode and debug directly in VSCode (e.g. set breakpoints).
Note: the UI parts are not started by this launch configuration. To debug the interaction of server and UI, the form UI or admin UI has to be started separately with npm run start:ui-form
or npm run start:ui-admin
.
The local database uses in-memory mode. Data will be re-initialized after each restart.
The sample does not cover deployment of the app, where additional considerations e.g. regarding database and authentication are needed.
The sample code is provided as-is. No support is provided.
Other projects demonstrating similar use-cases:
- https://github.com/vobu/ui5-cap - a repository showcasing the use of UI5 Tooling, CAP + UIveri5-based testing in an app for media upload and preview (as presented at UI5conBE in Feb 2020) by Volker Buzek.
- https://blogs.sap.com/2020/07/08/ui5-freestyle-app-in-cap - a UI5 freestyle app in CAP, with approuter, by Wouter Lemaire.
- https://blogs.sap.com/2020/09/06/developing-a-fiori-elements-app-with-cap-and-fiori-tools/ - about developing a Fiori elements app with CAP and Fiori Tools
- https://blogs.sap.com/2020/04/07/ui5-tooling-a-modern-development-experience-for-ui5/ - an overview on the UI5 Tooling and its extensions for a modern development experience.
Copyright (c) 2020-2023 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.