Disclaimer:This document relates to Beta functionality available on SAP HANA Cloud Platform trial landscape.
SAP HANA Web-based Development Workbench is something that you as a TRIAL user of SAP HANA Cloud Platform probably already know. It provides you with easy access to the source code of your XS applications. You may run your XS applications from there, and now you may also debug them. In this blog, you will see how easy it is to debug your XSJS code in SAP HANA Web-based Development Workbench. You may find the official documentation at Debugging Server-Side JavaScript with SAP HANA Web-based Development Workbench.
Scenario
In the example below we will use SAP HANA Web-based Development Workbench to create a "Hello World" application. Then we will debug its XSJS code.
- Open SAP HANA Web-based Development Workbench from your Trial Instance
- Create a sample "Hello World" XS application
- Run the "Hello World" XS application
- Grant debug privileges to the database (starting with DEV) user
- Debug the "Hello World" XS application
Prerequisites
- You have an account on SAP HANA Cloud trial landscape. See Signing Up for a Developer Account
Procedure
Step 1: Open SAP HANA Web-based Development Workbench from your Trial Instance
Step 2: Create a sample "Hello World" XS application
We will use the sample "Hello World" XS application in our SAP HANA Web-based Development Workbench debug example
Step 3: Run the "Hello World" XS application
Step 4: Grant debug privileges to the database (DEV) user
When we use SAP HANA Web-based Development Workbench on Trial (Trial Instance) it is opened with credentials of our DEVxxx user (technical user - you cannot login with it). When we open an XS application our SCN user credentials are used (for example p123456). In the picture below you may see that SAP HANA Web-based Development Workbench on Trial is using my (1)DEVxxx user, and the sample "Hello World" XS application is using my (2)SCN user.
Tip: You may copy the DEVxxx user ID in two ways:
- In Google Chrome open the context menu over DEVxxx user ID, and choose "Inspect Element" action
- In SQL console (open it via: "More" button -> "Catalog" action -> "SQL" button) execute:
SELECT CURRENT_USER FROM DUMMY
To enable your DEVxxx user to debug your SCN user (or another SCN users) sessions, the SCN user must grant debug privileges to the DEVxxx user. This is done opening the following URL:
- https://<your XS application host>/sap/hana/xs/debugger/
- In my case: https://s3hanaxs.hanatrial.ondemand.com/sap/hana/xs/debugger/
Step 5: Debug the "Hello World" XS application
- First you need to know the XS session ID you want to debug. You may get the xsSessionId cookie value using your favorite browser's "Developer Tools". In my case it is Google Chrome - in that browser, press the F12 keyboard key to open "Developer Tools".
- Next we need to start a debug session and set a breakpoint
- To stop on our breakpoint, we need to reload the file that we debug (i.e. logic.xsjs). In the picture below, you may see that reload of logic.xsjs is blocked (2) by our breakpoint
- And finally we have our debug session running
Summary
Congratulations! You have made your first debug session on SAP HANA Cloud Platform. Now you have added a powerful debug tool in your SAP HANA XS development arsenal.
Contributor
Dobrinka Stefanova
References
8 Easy Steps to Develop an XS application on the SAP HANA Cloud Platform
Click and Try Sample XS Applications on the SAP HANA Cloud Platform
Using Predictive Analysis Library (PAL) in SAP HANA Cloud Platform