Attila, S/4HANA, BTP Fullstack Developer (EN, DE, HU)

Command Line Commands for SAP Development
NPM
Install package globally (system-wide)
npm install --global <package_name>
# for example
npm install --global @ui5/cliInstall package locally + add as dependency
- Adds package into the
package.jsonunderdependencies - Installs the package in your workspace under
node_modulesfolder
npm install <package_name>
# for example
npm install @sap/cds-fioriInstall package locally + add as dependency for development
- Adds package into the
package.jsonunderdevDependencies - Installs the package in your workspace under
node_modulesfolder
npm install --save-dev <package_name>
# for example
npm install --save-dev @ui5/cliInstall
Installs modules found in the package.json file into the node_modules folder
npm installCheck outdated Local packages
Open terminal in the folder where the package.json file is located. To see which packages are outdated issue command
npm outdatedUpdate outdated Local packages
npm updateCheck outdated Global packages
npm outdated -g --depth=0Update a single Global package
npm update -g <package_name>Update all Global packages installed already
npm update -gRecreate package-lock.json after deleting it
npm install --package-lock-onlyList Global packages installed already
npm list -g --depth 0Wipe node_modules folder in all depths
npx rimraf --glob **/node_modulesCAP
You can set up a CAP project using the wizards or command lines. CAP project wizards add unnecessary junk in many cases like standalone approuter, completely unnecessary in many cases.
Install CAP Tooling
npm install --global @sap/cds-dkInitialize an empty CAP project in the folder
cds init
npm installStart CAP Server with live reload
cds watchBuild HANA DB artifacts
Takes your .cds schema definitions from the db folder and generates the HDI deployment artifacts by default to the gen/db folder.
cds build --for hanaAdd SAP HANA configuration for Hybrid Testing
To speed up incremental development, You can connect the app – running in your workspace – to the HANA Cloud HDI Container for testing. The below statement extends package.json with a hybrid run profile which uses HANA instead of the implicitly configured local SQL Lite
Note: SQL Lite will be still used locally during development using cds watch without specifying the hybrid profile. To utilize the hybrid profile you need to explicitly specify it with cds watch --profile hybrid.
You can combine this with cds deploy --to hana to reach faster development cycles in the development org and space.
- package.json is extended with cds.requires.[hybrid].db : “hana”
undeploy.jsonis added to the db folder
cds add hana --for hybridDeploy to HANA directly
In combination with hybrid testing – to speed up deployment – You can directly push to HANA Cloud only instead of/before full MTAR deployment. Thus You can run the app locally in your workspace without deploying it to BTP, but consume a remote HDI container instance. Never do this in production org and space!
In case You have not deployed your project yet and have no mta.yaml, then this operation:
takes the name from package.json and adds
- takes the
nameproperty value from package.json, adds postfix-dbthen uses this as HDI Container and Service instance name during deployment - creates binding to your workspace putting credentials to
.cdsrc-private.json
cds deploy --to hana --profile hybridAdd SAP HANA configuration for Production
- Extends
package.jsonwith production profile to use HANA in production, but still SQL Lite will be used locally during development usingcds watch. - Adds files
db/undeploy.json, eventuallydb/src/.hdiconfig.json, in case You built sg already
cds add hana --for productionSet up User Authentication and Authorization (XSUAA)
- Adds Authorization and Trust Management service configuration. Creates
xs-security.jsonincluding scopes and role templates - Updates
package.jsonsetting to use xsuaa authentication - Adds required dependencies
cds add xsuaa --for productionUpdate xs-security.json after modifying CDS Access Controls
After modifying authorization requirements (OAuth Scopes or Role Templates) in your service cds file using annotations @restrict or @requires, updating the XSUAA configuration is required. You can do it with the following command, saving over manual work. The command will look for service entities defined within the srv subfolder of the project and update the configuration.
CAP CDS Role => XSUAA Scope. XSUAA
role-templatesis the syntax (in xs-security.json) to collect Scopes into BTP Roles during Cloud Foundry deployment. Roles are then grouped into BTP Role Collections in xs-security.json usingrole-collectionsor manually in BTP Cockpit. Role Collections are assigned to Users.Security artefacts collision will occur when deploying the same app into the same subaccount but different space. Deployment tries to create the role or role collection, what exists in the subaccount already. In that case mta.yaml is an option to place security configuration and using CF variables like ${org} or ${space} in the artefact names.
cds compile srv/ --to xsuaa > xs-security.jsonAdd SAP Build Workzone Configuration – standard edition
This saves manual configurations required at variety of places in your project so that your applications have the required attributes required by Workzone. Note this command provided by SAP is valid for Workzone standard edition plan only.
- package.json in the project root folder is extended with
destinations, html5-repoandworkzoneproperties undercds.requires
If you have UI5 applications within the app folder already, then also
- Adds
ui5-task-zipperand build scripts to thepackage.jsonof your UI5/Fiori App:app/<yourUI5AppName>)/package.json - Adds ui5-deploy.yaml:
app/<yourUI5AppName>)/ui5-deploy.yaml - Adds managed AppRouter configuration xs-app.json file to each Fiori application folder:
app/<yourUI5AppName>)/xs-app.json - Adds sap.cloud properties to the manifest.json of each app:
app/<yourUI5AppName>)/webapp/manifest.json
In case You did not added FLP Configuration with Semantic Object and Action when generating the frontend project, that will be added also. Highly suggested to so it in advance during project generation, due Tile Title and Subtitle with translatable i18n properties are also added, not like with the below command
cds add workzone-standardGenerate MTA deployment descriptor (mta.yaml)
Creates mta.yaml based on the package.json file.
Before generating mta.yaml review the package.json what is added as requirement under cds.requires already. This section controls, what services are added to the mta.yaml during generation.

cds add mtaBuild Multi Target Application
mbt buildDeploy to Cloud Foundry
cf deploy mta_archives/incident-management_1.0.3.mtarmbt build command created the multi-target archive file mta_archives/incident-management_1.0.3.mtar. The file can be deployed using the Cloud Foundry Command Line Interface.
One shot Build and Deployment
- Adds
mta.yaml - Build with
mbt - Deploy with
cf
cds upBinding to BTP Service instances
You can bind your local CAP application running within your workspace to an existing BTP service instance for testing.
This can be a HDI Container as seen in the below example. The credentials to access the service will be saved into the .cdsrc-private.json file under the hybrid section. So that when testing with the hybrid profile using cds watch --profile hybrid the given BTP service is consumed during runtime.
If you have an existing Service Key (SharedDevKey) to the service already, you can reuse it, otherwise new will be created.

cds bind -2 MyHANAApp-dev:SharedDevKeyYou can run the CAP app using the bound HANA Cloud instance afterwards
cds watch --profile hybrid
UI5 / Fiori
For fully fledged setup see this dedicated post. npm commands are “platform independent”.
Setup Local Dev Environment for Fiori/UI5 Development on Windows
Cloud Foundry CLI
Installation
https://docs.cloudfoundry.org/cf-cli/install-go-cli.html
SSO Login
Take values from your subaccount to log in.
Login BTW. is supported by dedicated login windows inside BAS with input helps.
Terminal login described here is required in VSCode only, but works in BAS as well of course.

cf login -a https://api.cf.eu20-001.hana.ondemand.com --sso -o sapdevbuild -s dev
Switching API endpoints, orgs and spaces and login after selecting target
# Set the Cloud Foundry API endpoint cf api <API Endpoint of your landscape> # forex cf api https://api.cf.us10-001.hana.ondemand.com # Log in cf login --sso # Set Organization and Space cf target -o ORG -s SPACE # forex cf target -o 11817002trial -s dev
Undeploy Application
Hope You are sure what you are doing !
# This will delete application and services instance as well => ALL DATA AS WELL cf undeploy <yourapp> --delete-services --delete-service-keys --delete-service-brokers # Shortcut to above is, when package.json has the undeploy script # (move mouse above in BAS/VSCode and Run it directly) npm run undeploy # to remove only the application cf undeploy <yourapp>
Retrieve logs for a given application
# Last log entries cf logs --recent <appname> # All log entries cf logs <appname>
Deploy MTA
cf deploy <multi_target_archive_file> # forex cf deploy myApp_1.0.0.mtar
Start a stopped HANA Cloud Instance
cf update-service <name_of_the_hana_trial_instance> -c '{"data":{"serviceStopped":false}}'
List Multi Target Applications
cf mtas
HANA
Install Command Line Utility
npm install -g hana-cli
Inspect a DB Object, like a View and dump out definition in CDS format
Comes handy when exposing custom HANA Artefacts via the CAP schema.
hana-cli inspectView -v V_INTERACTION -o cds
Output:
@cds.persistence.exists
@cds.persistence.calcview
Entity ![V_INTERACTION] {
key ![ID]: Integer @title: 'ID: ID' ;
![PARTNER]: String(10) @title: 'PARTNER: PARTNER' ;
![LOG_DATE]: String @title: 'LOG_DATE: LOG_DATE' ;
![BPCOUNTRY_CODE]: String(3) @title: 'BPCOUNTRY_CODE: BPCOUNTRY_CODE' ;
![TEXT_ID]: String(10) @title: 'TEXT_ID: TEXT_ID' ;
![LANGU]: String(2) @title: 'LANGU: LANGU' ;
![LOGTEXT]: String(1024) @title: 'LOGTEXT: LOGTEXT' ;
}
Cloud MTA Build Tool
Installation of the Tool
Prerequisite is make ( just for windows )
# Install the tool using npm npm install -g mbt # Install CF CLI Plugin for that as well cf install-plugin multiapps
Build MTA Module
mbt build -t ./
Git
Clone Git repository into a given subfolder
git clone <git-repository-url> <folder_name> # forex git clone https://github.com/attilaberencsi/capnodejsfullstack.git cpapp
Initialize local Git repository in the project folder
git init
Unset Credentials when different credentials are needed
git config --local --unset credential.helper git config --global --unset credential.helper
Set credential timeout
git config --global credential.helper "cache --timeout=86400"
Store credential permanently
git config credential.helper store
Checkout Branch. Issue this in the project folder, where the .git folder is also present (windows)
git checkout <branch> # forex git checkout main
Linux
Remove folder
rm -rf


