This project is a development template for building mobile and desktop sap btp & Fiori applications
using Angular and Ant Design.
English | 中文
This is a template for building SAP BTP and Fiori apps with Angular framework and Ant Design. It is based on Nx and UI5 Tooling.
- Node.js 18
- Angular 17
- Tailwindcss 3
- Storybook 7.5
- ui5-tooling 1
- CAP SDK 7
yarn install
install all dependencies.yarn start
oryarn start:btp
run webapp and watch changes to reload in url http://localhost:4200/.yarn start:btp:sandbox
run btp app in sandbox environment.yarn ar
run approuter in url http://localhost:5000/.yarn sb
run storybook to preview components in url http://localhost:4400/.yarn start:s4h:mock
Start launchpad app for s4h system environment. Open in http://localhost:4200/.yarn start:s4h:live
Start launchpad app for live s4h system environment, Open in http://localhost:4200/.
Before you start, install npm packages by running npm install
or yarn install
.
Before other packages that this project is depend on upgrade to Angular 17 version, please use
npm install --legacy-peer-deps
to install dependent packages.
Run docker-compose up -d
to start the docker container of the pg database service.
If you first run this BTP project, run yarn deploy:btp:local
to deploy db models to local database.
To start the development server run yarn start
or run nx serve launchpad
and yarn --cwd caps/app-store w-sandbox
separately. Open your browser and navigate to http://localhost:4200/. Happy coding!
Run yarn start:s4h:live
or yarn start:s4h:mock
to start the application for s4h system.
The application has two environments, development
and production
. The default environment for build
is production
, and default environment for serve
is development
. You can change the environment by setting the --configuration
option when running the build
or serve
command.
The features in environment are:
- production - enable production mode, disable debug log, and others.
- platform - S4H | BTP | LOCAL
- enableFiori - enable load all Fiori apps in SAP system as menus in this application.
- enableNotification - enable notification service in S4HANA system.
- enableWaterMark - enable water mark on page of the application.
- mockData - is mock data in local.
- embeddedAnalytics - Enable embedded analytics in S4HANA system.
- enableDemo - Enable demo pages, you can view demo features.
We use the Nx CLI to generate code npx create-nx-workspace <workspace-name>
.
Add tailwind css use command npx nx g @nx/angular:setup-tailwind launchpad
.
Add UI library Ant Design of Angular ng-zorro-antd use command npx nx g @nx/angular:ng-add ng-zorro-antd --style=less
.
Add storybook use command npx nx g @nx/angular:storybook-configuration launchpad
.
You can execute the following npm scripts to preview the application:
- start - starts the application (btp).
- start:btp - starts the application for btp.
- start:s4h:live - starts the application for s4h system with live service.
- start:s4h:mock - starts the application for s4h system with mock data.
When running npm run start
the local development application and calling the live OData service, you need to configure the proxy to forward the request to the ABAP server.
Here is the configuration file apps/launchpad/proxy.conf.json, all the requests starting with /sap/
are forwarded to the server target, and the authorization account information auth is configured.
{
...,
"/sap/": {
"target": "<your sap abap server url>",
"secure": false,
"changeOrigin": true,
"auth": "<SAP Username>:<SAP Password>"
}
}
When using npm run start-mock
to start the application and a mock server to reflect the OData endpoint, you can use the application without having to connect to a live OData service and generate mock data on the fly.
If you want to add new OData mock data, you need to create a folder in the src/mock/odata/odata service name
directory with the name corresponding to the OData service you want to simulate. Inside this folder, you should add a metadata.xml
file, which should contain the metadata for the respective OData service. You can also create a data
subfolder to store mock data files.
You also need to add a service configuration (for example: EPM_REF_APPS_PO_APV_SRV
) in the ui5-mock.yaml configuration file, as follows:
...
server:
customMiddleware:
- name: sap-fe-mockserver
configuration:
mountPath: /
services:
...
- urlPath: /sap/opu/odata/sap/EPM_REF_APPS_PO_APV_SRV
metadataPath: ./src/mock/odata/EPM_REF_APPS_PO_APV_SRV/metadata.xml
mockdataPath: ./src/mock/odata/EPM_REF_APPS_PO_APV_SRV/data
generateMockData: false
debug: true
watch: true
Please refer to @sap-ux/ui5-middleware-fe-mockserver for more detailed usage instructions.
In dealing with mock data containing navigation, the mock server might throw an error related to a toString()
call. Please check the following code in the getV2KeyString
function within the @sap-ux/fe-mockserver-core/dist/data/dataAccess.js
file:
default: {
// keyStr = encodeURIComponent(`'${currentKeys[Object.keys(currentKeys)[0]].toString()}'`);
// Change to
keyStr = encodeURIComponent(`'${currentKeys[Object.keys(currentKeys)[0]]?.toString()}'`);
break;
}
Ready to deploy, you can ref to How to deploy?.
For BTP platform, you can disable
yarn b:btp
Build for BTP platform.yarn d:btp
Deploy to BTP platform, you might be login using cf cli firstly.
- Base url
The deployed application needs to be opened in a non-root path, so you need to configure the base url when building the app. Replace your_project_name
with the name of the BSP application in command yarn b:s4h:app
.
{
"b:s4h:app": "nx build launchpad -- --base-href /sap/bc/ui5_ui5/sap/your_project_name/",
}
- Deploy
Run yarn d:s4h
to build and deploy to s4h system, other details ref to Deploying to ABAP.