Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
dvankempen
Product and Topic Expert
Product and Topic Expert








UPDATE: May 2022

The onboarding series has been updated. For the latest version, visit

The information presented in this blog is no longer current.


Hands-On Video Tutorials - Part II


philip.mugglestone just updated his developer onboarding video tutorial series for the SAP Cloud Platform. In this blog, you will find the videos embedded with some additional information and resources. Following along in the patented zero-to-hero format, no prior knowledge required, you will be ready to start developing business applications on the platform with minimal effort and no time wasted.

You can watch the seven video tutorials in a little over one hour. What you learn is

  • How to develop a standalone application using SAP Business Application Studio and deploy to the SAP Cloud Foundry environment

  • How to work with destinations

  • How to use Cloud Foundry User authentication and authorisation (UAA)

  • How to use SAP HANA for persistence

  • How to leverage the Cloud Application Programming (CAP) model

  • How to make use of XSJS compatibility to deploy your SAP HANA XS classic model applications as-is to SAP HANA XS Advanced model and Cloud Foundry.


Ready? Let's jump!


To bookmark the playlist on YouTube, go to

Because we know your time is precious, we have included code snippets so you can easily and merrily code along. For the GitHub repository with sample code, go to


Standalone App


In this video tutorial, we work with a sample Node.js application from a sample Github repository using SAP Business Application Studio. We first run the app locally to validate everything works. Next, we deploy the app to the Cloud Foundry environment.

https://youtu.be/LTUcSLYDDaI?list=PLkzo92owKnVw3l4fqcLoQalyFi9K4-UdY

Steps


Connect to the SAP Business Application Studio, create a new dev space and add the MTA Tools extension.

Clone the GitHub repository with sample code from github.com/saphanaacademy/scpapps.

We can run the sample Node.js app locally in a terminal window and deploy it to the platform using the cf push command.


From the SAP Cloud Platform Cockpit, we can manage the app and access the log files, the equivalent of the commands
cf a
cf app myappnode
cf logs myappnode --recent
cf d myappnode -r



App with Destination Service


In this video tutorial, we develop an app for the Cloud Foundry environment that makes use of a destination service.

For documentation, see

https://youtu.be/XoKqaHmAg0E?list=PLkzo92owKnVw3l4fqcLoQalyFi9K4-UdY

Steps


First create a destination. We use the OData Test service https://services.odata.org/V2/Northwind/Northwind.svc


Next, create an instance of the Destination service and bind it the myappdest sample application.


A service key has been created as part of the binding process.


Which will be used as environment variables for the connection.


With the Business Application Studio we can also simulate the service access (binding) and run it locally. This will greatly improve the development experience and productivity as we do not have to deploy our app each time to validate our code.



App with Authentication


In this video tutorial, we develop a multi-target app (MTA) that requires end user authentication.

https://youtu.be/8qAabSHI-Ac?list=PLkzo92owKnVw3l4fqcLoQalyFi9K4-UdY

First, we create a local service instance and bind it to the destination while working in local development mode and test the authentication is successful. Once validated, we can build the MTA and deploy the app to the platform.



Both the router (front-end) and server (back-end) have been deployed with the service instance created.



To remove both applications and the services, use command
cf undeploy myappuaa --delete-services -f


App with HANA


In this video tutorial, we continue our development journey and create a multi-target app (MTA) that includes data persistence in SAP HANA.



First, create a new Cloud Foundry service for your environment, choosing service plan hdi-shared and bind the service to the local application.




As before, we need to update the .env file to default-env.json and wrap the environment in JSON format.


The relevant design-time artifacts are sales.hdbtable and sales.hdbtabledata with the sales.csv file.


The server.js file contains the actual SQL code that get's executed.


We run the application with the 'npm i' command to install the HDI Deployer and 'npm run start' to start the deployment (-- -- exit to exit when done).
cd myapphana\db
npm i
npm run start -- --exit

The console output shows the deployment process.

 


As before, to build the application right-click on the package.json file to build the MTA and subsequently from the  MTA_archives folder, deploy MTA Archive.


CAP App


In this video tutorial, we use the SAP Cloud Application Programming model (CAP) to develop applications, including data persistence in SAP HANA.

https://youtu.be/6mOKNABXyec?list=PLkzo92owKnVw3l4fqcLoQalyFi9K4-UdY

For information about CAP, go to

After creating a new dev space in the Business Application Studio using SAP Cloud Business Application template.

From the terminal, create the app structure and run the 'watch' command to activate CDS.
cds init myappcap
cds watch

We create the application by using code snippets from the github.com/saphanaacademy/scpapps repository to

  • db/schema.cds

  • srv/cat-service.cds

  • srv/cat-service.js


By default, persistence uses a sql-lite database. To use SAP HANA, first enable and then deploy after connection the studio to the Cloud Foundry environment.
cds add hana
cds deploy --to hana

To run the application locally, install the dependencies and run
npm i
cds run

To deploy the application, execute
cds build
cd gen/srv
cf push --random-route


App with XSJS Compatibility Layer


In this video tutorial, we learn how to develop a multi-target (MTA) app that accesses data persistence in SAP HANA via the XSJS compatibility layer, to continue using SAP HANA XS classic model artifacts including XSODATA with XS Advanced.

https://youtu.be/y0yRA2Qc6AQ?list=PLkzo92owKnVw3l4fqcLoQalyFi9K4-UdY

For the documentation, go to

[0:00] - introduction XSJS compatibility layer

[1:35] - clone repository from github.com/saphanaacademy/scpapps.git

[2:30] - package.json of srv includes xsjs dependency
{
"dependencies": {
"@sap/xsenv": "^2",
"@sap/xsjs": "^6"
},

[2:40] - server.js contains xsjs bootstrap code with options
const xsjs = require('@sap/xsjs');
const xsenv = require('@sap/xsenv');

var options = {
anonymous: false,
xsApplicationUser: true,
auditLog: { logToConsole: true },
redirectUrl: '/srv/index.xsjs'
};

[3:00] - runs like xsjs application
const port = process.env.PORT || 5001;
xsjs(options).listen(port);
console.info('Listening on http://localhost:' + port);

[3:30] - original .xsjs and .xsodata files are located in the lib directory.


[4:20] - build and deploy project

[5:00] - Go to SAP Cloud Platform cockpit > Subaccount > Security: Role Collection Trust. Note a new role collection has been created. Assign this role collection to your the e-mail address for the trust configuration SAP ID Service (or any other identify provider.

[5:40] - test application

[5:55] - validate OData service calls ($metadata, etc.)


[7:30] - more information in readme.md



Share and Connect 


Questions? Post as comment.

Useful? Give a like and share on social media. Thanks!

If you would like to receive updates, connect with me on

Best,

Denys van Kempen

4 Comments
ErvinSzolke
Product and Topic Expert
Product and Topic Expert
Great Blog, denys.kempen , Thanks for sharing !
Jidnyasa
Explorer
0 Kudos
I have clone this repository, but in myappxsjs when I am trying to install "@sap/xsjs" dependency it is giving following error
user: srv $ npm i
npm ERR! code 1
npm ERR! path /home/user/projects/SDS/srv/node_modules/@sap/xsjs/node_modules/@sap/fibers
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.0
npm ERR! gyp info using node@14.17.6 | linux | x64
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
npm ERR! gyp ERR! find Python checking if "python3" can be used
npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking if "python" can be used
npm ERR! gyp ERR! find Python - executable path is "/usr/bin/python"
npm ERR! gyp ERR! find Python - version is "2.7.16"
npm ERR! gyp ERR! find Python - version is 2.7.16 - should be >=3.6.0
npm ERR! gyp ERR! find Python - THIS VERSION OF PYTHON IS NOT SUPPORTED
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python You need to install the latest version of Python.
npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm ERR! gyp ERR! find Python you can try one of the following options:
npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
npm ERR! gyp ERR! find Python (accepted by both node-gyp and npm)
npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
npm ERR! gyp ERR! find Python npm config set python "/path/to/pythonexecutable"
npm ERR! gyp ERR! find Python For more information consult the documentation at:
npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
npm ERR! gyp ERR! stack at PythonFinder.fail (/home/user/.node_modules_global/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:330:47)
npm ERR! gyp ERR! stack at PythonFinder.runChecks (/home/user/.node_modules_global/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:159:21)
npm ERR! gyp ERR! stack at PythonFinder.<anonymous> (/home/user/.node_modules_global/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:266:16)
npm ERR! gyp ERR! stack at PythonFinder.execFileCallback (/home/user/.node_modules_global/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:297:7)
npm ERR! gyp ERR! stack at ChildProcess.exithandler (child_process.js:381:7)
npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:400:28)
npm ERR! gyp ERR! stack at maybeClose (internal/child_process.js:1055:16)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
npm ERR! gyp ERR! System Linux 5.4.0-6-cloud-amd64
npm ERR! gyp ERR! command "/opt/nodejs/node-v14.17.6-linux-x64/bin/node" "/home/user/.node_modules_global/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/user/projects/SDS/srv/node_modules/@sap/xsjs/node_modules/@sap/fibers
npm ERR! gyp ERR! node -v v14.17.6
npm ERR! gyp ERR! node-gyp -v v8.4.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2021-11-29T05_35_37_717Z-debug.log<br>
dvankempen
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi Jidnyasa,

Comment or question?

In case this is a support request:

  • The log mentions the issue > Python version not supported,

  • How to solve it > Node-gyp should be able to find and use Python. If not, find Python you can try one of the following option (...) 

  • Where to find this documented https://github.com/nodejs/node-gyp#installation


It does not get any better, for a log file that is.

Solves the issue?

 
dvankempen
Product and Topic Expert
Product and Topic Expert
0 Kudos
UPDATE: May 2022

The onboarding series has been updated. For the latest version, visit

The information presented in this blog is no longer current.