HANA XS development with the SPS07 Web IDE (focus on debugging)
Intro
With the upcoming release of HANA SPS07 all developers will be enabled to use a new lightweight development environment which has significantly improved to the prior version. Supporting the development of this tool I had the chance to get my hands on a preliminary version. So this is not an official announcement of anything. If you are looking for the official announcement, please watch the activities of our Product Management (Thomas Jung).
In this Post I am now going to highlight some differences to the former Web IDE and look at outstanding features of the new tool.
Setup and installation
In SP6 there have been two different web tools. The ‘Editor’ had some features which have been missing in the ‘IDE’ , and the other way around. So we decided to take the best out of both of them and come up with one integrated, new UI. Nevertheless we did not forget to develop new features as well.
You will see these four tools now:
- IDE/Editor
- DB schema browser (aka Catalog)
- Security
- Trace analysis
Installation
In it’s SPS06 version the Web IDE came as non-automated content and you needed to set it up on your own. As we changed the delivery model to automated content you do not need to install the tool explicitly anymore. It is installed by default. If you are already running SPS07 or above, you can access it at:
http://<hostname>:80<InstNo>/sap/hana/xs/ide/
Setup
For security reasons we introduced some new roles. According to your development scenario the administrator needs to assign some of them to the development user. The role ‘sap.hana.xs.ide.roles::Developer’ is a super user roles, as it contains all the others. So if you have got this one, you do not need any of the others at all.
This is a more details description of the new roles:
Role name | Description |
---|---|
sap.hana.xs.ide.roles::Developer | This is the super user role. It contains all the other roles and provides access to all sections. |
sap.hana.xs.ide.roles::EditorDeveloper | This role provides access to the IDE/editor section. |
sap.hana.xs.ide.roles::CatalogDeveloper | This role provides access to the catalog section. |
sap.hana.xs.ide.roles::SecurityAdmin | This role provides access to the security section. |
sap.hana.xs.ide.roles::TraceViewer | This role provides access to the trace section. |
In addition the debugger role enables the developer to debug XS server side JavaScript source code. Any developer will be grateful to be able to do so 😉
- sap.hana.xs.debugger::Debugger
You can enable the developer mode and xsjs debugging in the system in the Studio or via SQL
Using the Studio you can enable the debugging via
- Go to the ‘Administration perspective’.
- Double click your system.
- Change to the tab ‘Configuration’
- Create a new section named ‘debugger’
- Provide a property for this section
- name: ‘enabled’
- value: ‘true’
The developer mode is enabled (in the same place) via
- Create a property below the ‘httpserver’ section
- name: ‘developer_mode’
- value: ‘true’
Taking it all together, the easiest thing to do all this is to run these SQL statements (also attached):
-- enable xsjs debugging and developer mode
alter system alter configuration ('xsengine.ini','SYSTEM')set ('debugger','enabled')='true' with reconfigure;
alter system alter configuration ('xsengine.ini','SYSTEM') set ('httpserver','developer_mode')='true' with reconfigure;
-- create a development user and assign required roles
CREATE USER <REPLACE_ME> password topSecret;
CALL GRANT_ACTIVATED_ROLE('sap.hana.xs.debugger::Debugger','<REPLACE_ME>');
CALL GRANT_ACTIVATED_ROLE('sap.hana.xs.ide.roles::Developer','<REPLACE_ME>');
CALL GRANT_ACTIVATED_ROLE('sap.hana.xs.ide.roles::CatalogDeveloper','<REPLACE_ME>');
CALL GRANT_ACTIVATED_ROLE('sap.hana.xs.ide.roles::EditorDeveloper','<REPLACE_ME>');
CALL GRANT_ACTIVATED_ROLE('sap.hana.xs.ide.roles::SecurityAdmin','<REPLACE_ME>');
CALL GRANT_ACTIVATED_ROLE('sap.hana.xs.ide.roles::TraceViewer','<REPLACE_ME>');
Development workbench
If you enter the workbench at it’s base URL ( http://<hostname>:80<InstNo>/sap/hana/xs/ide/ ), you will see this:
You can navigate to the tool of your choice via the central entry screen or access them directly at:
Tool | Access URL |
---|---|
IDE/Editor | /sap/hana/xs/ide/editor/ |
Catalog | /sap/hana/xs/ide/catalog/ |
Security | /sap/hana/xs/ide/security/ |
Traces | /sap/hana/xs/ide/trace/ |
IDE/Editor
The Editor is the most powerful tool here. You will find ‘a lightweight, browser based IDE to create and edit XS development objects’.
I like the enhanced, out of the box reliably working XSJS debugger the most. Nevertheless code completion, syntax highlighting and all those handy keyboard shortcuts (let me know if you miss some) make this a really productive IDE. This holds especially true as you do not need to keep any local installation in sync with some server version anymore. Furthermore checking in and out code over and over is part of the past now.
So start thinking about what to do with all that gained time 🙂
Miscellaneous features
Let’s have a look at the features in a more formal way.
This is what you can access via the buttons tool bar:
- Use a template (see section below).
- Format the code.
- Open Code in a separate Window.
- Save / Save all.
- Search (see below).
- Setting (Appearance and inactive object handling).
- Shortcut to FAQs and keyboard shortcuts.
Coding
As the new IDE leverages the ace JavaScript code editor, it still comes with a lot of handy features:
- Syntax highlighting
- Code folding
- Code formatting
- Keyboard shortcuts
- Code checks (client and server side)
- One tab / separate window per open file
Code completion
Looking at code completion there are two different kinds. The local code completion (accessible via <Ctrl>+<Space>) provides access to
- local variables
- local methods
- keywords (like this, undefined, NaN, ….)
- snippets
- no more need to type e.g. the complete ‘for loop’ syntax yourself
This one comes handy when you want to code very fast and/or want to be sure not to introduce typos in your code.
And there also is another one. The XS backend API code completion (accessible via typing ‘$.’, followed by <Ctrl>+<M>). It gives you access to all the XS objects (including sub objects) being provided:
- import
- web
- request
- response
- session
- trace
- db
- net
So watch out you’re not asked to return your second monitor as the XS JavaScript API has not to be open all the time anymore 😉
Inactive save and execution
Using the settings button you are now able to save code in an inactive state and execute it. Doing so you will be the only one to see (‘Enable inactive save’ switch) and/or execute (‘Enable inactive object execution’ checkbox) code. This is a quite useful feature in a distributed development environment, in which you should try out things before releasing them to others.
Templates
If you already developed XS applications you might have a good collection of templates for recurring tasks – available at your local machine. You can (still) drag them from your desktop and drop them in the drop zone of the web IDE (which is enabled via selecting a package).
To furthermore ease your life, we included the most important templates into the IDE itself. There are more to come and we also started working on a feature to create and use self defined templates. For the time being, let’s look at the already available templates.
Some templates can be accessed when creating a new applications (via node ‘Content’ -> right click->’Create application’ ):
- HANA XS Hello World
- SAP UI5 Hello World
- Simple Mobile Application
- Blank Application
- Trace Viewer Demo
Others can be integrated into existing code (first button in the menu bar). Depending on the open file type, you will see some of the following:
- XSJS file
type (.xsjs)
- Default request/reply pattern (see screenshot)
- HTML file (.html)
- Empty SAP UI5 frame
- SAP UI5 Goldreflection Shell
- SAP Mobile Frame
- JavaScript file (.js)
- SAP UI5 JavaScript View
- SAP UI5 JavaScript Controller
Search
If you are working in a big project you may know something was written …somewhere… but how to search for this before SPS07 without interrupting your workflow? We now provide access to the search engine of HANA via the IDE! You can either search the repository for a file (via the toolbar button ‘Search’), or you search for code snippets (by selecting a container object – content or package folder) in the navigation area followed by selecting ‘Search Text’.
Lifecycle management
You have got full access to the repository and are able to manage all these different life-cycle management aspects of your code in place:
- Create and delete packages
.
- Create and export delivery units.
- Assign and unassign packages to/from delivery units.
- Create files.
- Create applications (using templates if you like).
- MultiFile Drop Zone:
- You already have got some files on your Desktop and want to deploy them?
- Just select the target package in the IDE and ‘drag and drop’ these files using your mouse from the Desktop into the IDE’s ‘drop zone’!
- Version control for files (‘Right click’ -> ‘Versions’):
Debugging
Getting to the point of having a running debugging session for XS server side JavaScript code has been a quite challenging task up to now.
The server side component (using ‘Web Sockets’, a feature you can be looking forward to) now comes together with the ‘client component’. So protocol compatibility became much easier to achieve – without the need for up-/downgrading anything on your local machine.
Before deep diving into the debug part I would like to point out two important facts in this context (these are the same ones as in the setup chapter):
Developer mode
Enabling the developer mode by changing the servers configuration gives you much better error messages than ‘500 – internal server error’. The latter one is acceptable for a productive environment where you might not want to show the internals of your implementation. It is nevertheless making things complex during development and you do not even receive an advantage for that drawback. So let’s make HANA more chatty by executing this SQL statement:
alter system alter configuration ('xsengine.ini','SYSTEM') set ('httpserver','developer_mode')='true' with reconfigure;
Another way is setting the parameter ‘developer_mode’ in the httpserver section of your xsengine.ini file via the Studio (see the setup section for details).
Debugger enablement
The server side component for debugging XSJS code is not enabled by default. If you see something like:
16:06:29 >> WebSocket connection for debugging closed.
16:06:33 >> WebSocket connection is not ready for debugging.
in the Web IDE, you can be sure it is not enabled.
To change this, you can either create a section ‘debugger’, holding a parameter ‘enabled’ with value ‘true’ in your xsengine.ini file (maybe check the setup section):
or you execute this SQL statement:
alter system alter configuration ('xsengine.ini','SYSTEM')set ('debugger','enabled')='true' with reconfigure;
How to use the Debugger
Once you enabled debugging, the only thing you need to do for a running debugger session is to set some breakpoints and to finally run the server side Java Script code.
- Open the server side JavaScript (XSJS) file you want to debug.
- Click into the line number column of the statement you want to stop at.
- Set as many breakpoints as you want.
- As a result you will see a red arrow in that column for everyone of them.
- See the screenshot to the right.
The next thing you want to do is to call that file via one of these methods
- Click the green arrow in the button toolbar.
- Push the ‘F8’ key.
- Call another file, which calls this one (e.g. a client side JavaScript file).
Once the script is executed and your marked statement is reached, you will see another, blue arrow inside the red, bigger one (screenshot below).
Right to the source code there is the debugging area, showing you all the current runtime values of existing variables. You can deep dive into any existing sub elements:
Using the buttons on the top of this window:
you can ‘Resume’, ‘Step In, Over and Out’ (of the current script execution).
So you can control whether to make the script run to the end or the next breakpoint, step over a function, go into the body of a function or leave the current function body. Follow the blue arrow – it will always show you which will be the next statement to be executed.
While all this gives you a pretty good overview of what is happening, we still did not look at the most powerful feature:
You can write your own statements being executed immediately on the server. This way you can change variables and hereby the runtime behavior of the server side JavaScript file.
This feature is available via the evaluate expressions button:
If the according package is configured to run in ‘info’ trace level mode or below, the above statement will log ‘great’ immediately. You may come up with more meaningful loggings 😉
Catalog
The catalog section serves as a very good entry if you need to check things in the database. There is a SQL console, which you can use to send SQL statements to the engine and an outstanding feature of this SQL console is the code-completion:
If you start typing ‘SELECT * FROM <SchemaPrefix>’ and hit ‘<Ctrl>+<Space>’, you will see a list of all available objects, starting with that particular prefix.
After selecting an object, containing other objects (like a schema), you simply go on with typing and/or hit ‘<Ctrl>+<Space>’ again to see available sub-objects.
Other than that you can create sequences and generate insert or select statements.
Creating a sequence:
Browsing a table:
Security
The security area provides a lightweight access for basic user management tasks. You can create roles, assign those to users and create users themselves:
New role dialog:
New user dialog:
Traces
The trace files are sorted by master process now, allowing you to easily find what you are looking for. Most likely this will be the latest file below the xsengine node.
The most important feature right here is setting the desired trace level for your package:
Conclusion
While I think the HANA XS Web IDE has not already reached it’s full potential in some areas, you have a powerful tool available now.
I am looking forward to see a lot of new innovative XS apps and hope the Web IDE can help you here.
Stay tuned for more
Hi Kai,
Good to see that now both IDE and Editor have same fetaures.
Thanks for sharing new details regarding SPS7
Regards,
Vivek
Hi Kai,
Looking forward to these great improvements! A couple which sound great include Multi-File uploads and 'versioning'
Cheers, Paul
Hi Kai,
thanks for the helpful post.
Anyway, I am not able to enable the debugging correctly.
I tried both, setting the paramters via the config file in the Studio as well as using the SQL statements.
But still I get:
Error in WebSocket Connection to backend.
WebSocket connection for debugging closed.
when I open the WEB IDE.
Any idea?
Thanks and best regards,
Tom
Hi Tom,
maybe you do not have the necessary authorizations?
You said you tried setting the parameters.
It pretty much looks like they have not been set.
Did you check this? How does it look like? Which revision are you running?
Best regards
kc
Hi Tom, hi Kai,
has this issue been resolved? I am getting the same error. I granted all relevant roles to my user and enabled debugger and developer_mode.
One role I could not grant, however, was "sap.hana.xs.debugger::Debugger". It simply does not exist on my system. Do I have to perform any additional steps to create it?
Best regards,
Tim
Hi Tim,
which HANA revision are you using?
Cheers
kc
Hi kc
I am on Rev 73.
Best regards,
Tim
Hi Tim,
no, the issue still exists. I did not investigate further out of time reasons. We now moved from 70 to 72 and 73 and we have the same issue in all systems. I have all mentioned roles and all the settings are set. Maybe it has something to do with HCP where the system is hosted instead of a on premise one.
Best, Tom
Hi Tom
the web IDE should run out of the box in the HCP landscape.
Please open a ticket for this.
Best regards
kc
Hi, Tom,
Is this issue resolved? I also met this issue this week and fixed. I think you can take look at two points.
1. Assign sap.hana.xs.debugger::Debugger role and sap.hana.xs.ide.roles::Developer to your user.
2. Disable your proxy setting in browser, use direct access. In my case, my remote HANA server is located at 10.*.*.*, after proxy is disable, I can do debugger remotely.
Hope this is helpful.
Hi Liang,
no, the issue still exists.
I tried to disable the proxy in my browser, but then I get problems connecting to the Web IDE at all. When I disable the proxy completely, I cannot reach the editor at all. When I just enter the IP of the XS system to the list of excluded hosts, The behaviour is the same as without having the entry. I got the IP from HANA Studio when opening the properties of the XS system and go to the tab "Hosts used to connect". It also is a 10.* IP.
I again checked for the roles and the server settings. All is in place.
A general question: As soon as I change a setting in HANA Studio i.e. the debug from false to true, do I have to restart the server to get the changes be applied?
Thanks, Tom
Hi, Tom,
Please look at my proxy setting. You can try this.
Hi Liang,
thanks for your continued effort to help.
This cannot work for me being connected to the SAP global network and accessing a prod account on HCP.
I created a ticket for this issue and will post the solution here as soon as I get it.
Best, Tom
Hi Kai,
Thanks for the Blog. I am trying to access the Web IDE as mentioned.
I get the error msgs when I try to set config ini file through SQL commands as follows:
SQLs that I am running with SYSTEM user:
-- SHOW FRIENDLY ERROR MESSAGES ON DEV SERVER
ALTER SYSTEM ALTER CONFIGURATION ('xsengine.ini', 'SYSTEM') SET ('httpserver', 'developer_mode') = 'true' WITH RECONFIGURE;
-- ENABLE XS DEBUGGING ON DEV SERVER
ALTER SYSTEM ALTER CONFIGURATION ('xsengine.ini', 'SYSTEM') SET ('debugger', 'enabled') = 'true' WITH RECONFIGURE;
Error messages:
Could not execute 'ALTER SYSTEM ALTER CONFIGURATION ('xsengine.ini', 'SYSTEM') SET ('httpserver', 'developer_mode') = ...' in 16.413 seconds .
[129]: transaction rolled back by an internal error: exception 70000000: ste::Exception type FileSystem message /usr/sap/TR1/SYS/global/hdb/custom/config/xsengine.ini additionalInfo ; Reason: WriteError
Could not execute 'ALTER SYSTEM ALTER CONFIGURATION ('xsengine.ini', 'SYSTEM') SET ('debugger', 'enabled') = 'true' ...' in 16.404 seconds .
[129]: transaction rolled back by an internal error: exception 70000000: ste::Exception type FileSystem message /usr/sap/TR1/SYS/global/hdb/custom/config/xsengine.ini additionalInfo ; Reason: WriteError
what could be the reason. Any pointers on this would be helpful.
Regards
Lokesh
Hi,
I have never seen this error message before.
There may be a lot of reasons and I do not think I can help you w/o looking at the system myself.
Nevertheless: What looks pretty suspicious to me is:
1) This statement usually runs in ms - certainly not 16s
2) WriteError sounds like to hard disk is lacking space
You should try the following:
1) Is there any alert in the system monitoring tab? If so: Solve it.
2) Try the GUI way.
3) Check if SYSTEM user has the appropriate roles.
Best regards
kc
Hi Kai and Lokesh,
I am facing the same error message:
Could not execute 'alter system alter configuration ('xsengine.ini','SYSTEM') set ...' in 16.250 seconds .
[129]: transaction rolled back by an internal error: exception 70000000: ste::Exception type FileSystem message /usr/sap/BTH/SYS/global/hdb/custom/config/xsengine.ini additionalInfo ; Reason: WriteError
I also recognized, that changed parameters will not be saved when I change something within the HANA Administration Overview (Configuration).
Same problem happens when I try it with the SYSTEM user.
Any new idea?
Thanks and best regards,
Johannes
Hi Johannes,
are you sure have enough authorization rights to do the change?
Is there any debug or log message showing up?
Did you check the trace files for this?
Which revision are you running? Box or Cloud?
Best regards
kc
Hi Kai,
I am pretty sure that I have enough authorizations:
Before I couldn't change something in the Administration - Configuration (Error: not authorized), now I can change or add anything but it will not be saved. We also tried to execute the SQL Command as SYSTEM User.
There is no further debug or log message, just the Error Message.
I haven't checked the trace files (don't know how...).
We run Revision 1.00.74.00.390550 - Box System
****
I guess it's an authorization problem with in the file system or smth...
Thank you for your help,
Best Regards,
Johannes
Hi Johannes,
I would like to help you here. Nevertheless it is really hard to do so without system access. The error you describe could be anything:
- full filesystem
- too many handles on OS level
- changed authorizations on OS file level
- ...
I do not think it is related to HANA authorizations (at least not if you did not change anything default). You can see the statement running smooth on a revision 81 at:
SAP Mobile Documents
The only things I can recommend therefore are of a very general nature, but may lead to a solution:
- restart HANA
- restart the OS
- install the latest HANA revision (or at least a more current one in the SP7 codeline)
If all this all does not help, I would recommend to open a ticket, so our support people can access and check the system.
Best regards
kc
Hi Kai,
Thank you for your support !
We sent a message to our support and they fixed it within a view minutes.
The reason for the problem was a full disk.
Best Regards,
Johannes
Hi Johannes,
happy to help - seems like that shot into the dark, wasn't too bad at all
Best regards
kc
Hi Mueller,
Actually in our system , we have set both the debugger and developer mode to true from the system user but still we are facing this issue
WebSocket connection for debugging closed.
Error while loading navigation tree:
<html><head><title>Application Server Error</title></head><body> <H2>500 Connection timed out
And the content is loading for long time and not showing any packages. Any solution..?
Thanks,
Sathish S
Hi Sathish,
Could you please send me details to logon to your system so that I could have a look?
Also, which browser are you using?
Kind regards,
Abhay
Superb post !
Thanks for sharing your knowledge.
Hello Kai,
I've done all the necessary configurations.In HANA server added parameters for debugging,assigned roles.But in settings when I try to add session id then I do not get any drop-down for session id.I cannot even key in any value.
Thanks
Swati
Hi Swati,
I tried with the login information that you provided and I do see the sessions.
Maybe you could give it another try. It is a good idea to logout and login again for the alter statements to take effect.
Kind regards,
Abhay
Hi,
thanks for this blog, I find it very helpfull and clarifying. I can't, however, debug in my HANA XS trial system (v1.8.6) I just created yesterday following this help site: SAP HANA Cloud Platform
The point is that yesterday just after instance creation I was able to set break-points with the Web IDE Editor in the application that I previously created using Eclipse, even when I was not able to run it because I got a 404 error (not found) on trying. However, today I can't even set breakpoints in the Web IDE Editor because as soon as I open it I get the "Error in WebSocket Connection to backend." error, and every time I try to set a breakpoint in the code I get message "WebSocket connection is not ready for debugging.". I tried to assign to my user the debugger role as explained here using the SQL console in Eclipse, but this returns error below (already mentioned before in this blog comments):
SAP DBTech JDBC: [10001]: user-defined error: [10001] "HCP"."HCP_GRANT_ROLE_TO_USER": line 17 col 12 (at pos 1164): [10001] (range 3) user-defined error exception: sap.hana.xs.debugger::Debugger role is not created, active or part of package described in view HCP.HCP_DEV_METADATA.
When I try to execute the sentence below in the console:
ALTER SYSTEM ALTER CONFIGURATION ('xsengine.ini', 'SYSTEM') SET ('httpserver', 'developer_mode') = 'true' WITH RECONFIGURE;
I also get error:
Could not execute 'ALTER SYSTEM ALTER CONFIGURATION ('xsengine.ini', 'SYSTEM') SET ('httpserver', 'developer_mode') = ...'
SAP DBTech JDBC: [258]: insufficient privilege: Not authorized
So, it seems the user you get when you set up a HANA XS instance on the HCP trial environment has almost no authorizations.
I don't have access either to Security nor Traces in https://s10hanaxs.hanatrial.ondemand.com/sap/hana/xs/ide/
How can I get permission to debug in the HANA XS instance of my trial HCP account?
Thank you!
Hi Dionisio,
unfortunately I also do not have admin rights in this system.
You should ask the support/admin of this system landscape.
Hope this helps,
kc
Hi! Today debug is working, so it seems the issue was finally solved 🙂
The point is that I am still not able to run the application example created step by step following the tutorial and still get a 404 (not found) error. However, I created another simple example application from template (so not manually step by step creating files) as a subpackage of the previous one, and this I can run without problems.
So I don't know why do I get this 404 error.
I see that my manual application and the created from template one both have .xsaccess file (the first is in "hello" package and the other in "examples" subpackage inside "hello") and both have similar content but, in the WebWorbench, I see the first one with all characters in black, whereas the second one colors key workds in purple and value words in blue, so somehow the Workbench recognizes something different between both files.
Now I see the problem probably is that I manualy named file .xsacces instead of .xsaccess
Hello Dionisio,
You are right.
The correct file name is .xsaccess
It would not work with .xsacces (without the additional 's')
Kind regards,
Abhay
Can we get the debug feature working with HCP and the trial MDC database?
Hi,
I know this thread is very old but just trying to know if all of you had any luck with your problem.
I have the same problem with my debugger. I've set the debugger, developer_mode to true and assigned all the necessary roles ( Developer, Debugger ) to SYSTEM user and still can't get the debugger mode to work for my XSJS. It gives "WebSocket connection is not ready for debugging." What else is missing. I've been trying to find a solution for this problem for the last 4 days and couldn't find one. I tried every possible way and yet, can't get it working.
I am using HANA Express Edition.
Hi Kalyan,
did you find any solution for this error? we are getting same error while applying break point in XSJS. Â We are also on HANA Express Edition.
we have followed mentioned steps to enabled debugger.
Thanks,
Mahesh
did you find any solution for this?
Hello All,