Skip to Content
Technical Articles
Author's profile photo Sergio Guerrero

HXE – OData Service v4 from NodeJs

Happy 2019 everyone. I hope your year has started on the right path. Mine is starting slow but I feel it will be a good one. I have many goals I would like to accomplish, and this blog is one of them. I am sharing this blog also as I prepare for the SIT Guadalajara – thanks Jhon for your continuous promotion of the event. Also, read the Spanish version of the same blog or another one from my HANA Express edition blog series


Before I get into the details, I would like to also thank Thomas/Rich for the openSAP course on update Q1/2019. I am currently taking the course and when I heard Rich/Thomas about the odata v4 on a node module, it really caught my attention, so I decided to investigate further.

I started by downloading the HANA express edition ( – on my prev. blog series ( , I had H2SP3 rev 31… now, I have rev 35.. yes there are some nice enhancements since rev 31 – thank you thank you. Even for the small exercise I did here, I can tell there are nice improvements behind the scenes as I am able to build modules faster than before. (I still have the same settings on my vm from before – 24GB RAM, 4 Core, etc)


The Business Application module template à this is a new wizard added and very easy to follow. See the steps below to showcase the odata v4 service on a ndoejs module.


Then, provide a name for your project

(select enable uaa  service)


Notice there are a few package.json files… at different levels

Root package.json


Svc – package.json à notice the express dependency and this is how the odata service is served using the express module.



db package.json



Inside the db module, there is the entry point for our cds data models. In my example I am using the default model provide and also added a new entity and a new view. In the opensap course, Thomas shows how to import other cds models using the import statement. This is very helpful as an application grows larger and models cannot be all in the same file.



The db module also has a folder called gen which holds the generated files when the cds models are built  (similar to metadata)


Now, if you want to see what’s in the svc module – logically, the entry point to our service from a url point of view (http/https).

The svc module also has a cds file that defines the service itself as shown below.

Things to notice here are:

  • The using keyword in case we need to expose our CDS models – from our db module.
  • The additional entity created in this service also works as an entity from the database and it follows the same rules and syntax.


Starting from the default configuration, I wanted to run my service and see what all this noise on odata v4 via the nodejs module was all about –


Until I got an error due to the wave-uaa didn’t exist (default name).

So, I went back to the mta.yaml file where these dependencies are created by default and noticed the wave-uaa name listed.


So I opened to the admin cockpit using the default admin account:

xsa_admin à service market place à create instance of service and called it the same name as the service in my mta.yaml


Then I went back to the app as xsa_Dev account


Re-ran the service and then I saw the successful message and clicking on the link opened the service entry point with the definition shown below




If you click on $metadata (navigates to https://hxehost:51045/catalog/$metadata) you may see the odata version – very excited to finally see v4 and the advantages it has over v4 on XS classic.

Similarly, clicking on BookInfo, it will retrieve the data on that end point.



If you click on book info you will see the following


Let’s see how many records are there, (there should be 0) since only structures are created. So let’s go to the DB explorer and add some data



select an hdi container – – ok


and select the Tables from the db container


Select a table and see its definition


Once opening the data view, we can add some records with the plus sign.. and entering data (2) and finally save the data with the save icon.


Then in the catalog service bookinfo


Finally go back to the browser and let’s run some queries.. the first one is to see the number of records coming from the end point


And the raw data


Some other odata query just to test it out… and let me also tell you that the payload is even smaller than odata v2… there seems to be less overhead on the payload.


Now, lets extend our service and let’s add a new entity and view.. then we can rebuild ( * make sure you build CDS from the project to generate the metadata files that get deployed to the gen folder )


Also, notice the association in my entity.



Now let’s populate some sample data… (and introduce some error to see the capabilities from the tool)


*hover over the red message and see the error “illegal date value” since I used month 13 (typo). Then I fixed it and saved it so back in the svc and re-run it.


dang it, I thought the CDS entities and view were going to be shown now, so what went wrong? I went back to the odata video on week 2 and it seems like I needed to list the entity or view with the using keyword and project it on the service as shown here


Re-building and starting the svc module gives me what I expected. Now I can see the table and the alias view.


Looking at it from the browser displays the 2 end points


And if we want to see the data in the other end point (the view output including the association defined on my data model cds file)


This is pretty cool. It seems like on my next writing I will need to see how I can consume these B@d@ss models on an app. In case you want to see the code, check out the github repo here –


Any feedback and other things you would like to see are welcome – please let me know and I hope I can continue sharing some knowledge on the latest CDS / odata v4 and app dev on HANA XSA. Happy dev!




Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Pierre Dominique
      Pierre Dominique

      Hi Sergio,

      I'd also like to develop my OData services using Node.js instead of Java (or ABAP). However as long as SAPUI5 / Fiori Elements don't fully support OData V4 this is kind of pointless in my opinion. I really hope the new Application Programming Model will push the UI5 / FE teams to finally support OData V4!




      Author's profile photo Sergio Guerrero
      Sergio Guerrero
      Blog Post Author

      hi Pierre... the odata v4 example i showed is indeed on nodejs runtime and using HANA CDS (not ABAP/Java) as far as the fiori elements supporting the new application programming model, not all of them are supported, only a few... however, it does seem going in the right direction. thanks for your comment!

      Author's profile photo Jhon Jairo Teran Salazar
      Jhon Jairo Teran Salazar

      Hello Sergio,

      Thanks for sharing, it's amazing to see how easy is make odata v4 services with node js,I would have liked to attend this course but unfortunately I couldn't for time matter.

      I look forward to see next blogs with updates about HANA Development course.

      Best regards.

      Jhon Jairo.


      Author's profile photo Sergio Guerrero
      Sergio Guerrero
      Blog Post Author

      I couldn't agree more with you JJ - the easiness of spinning an odata v4 service is very simple... you may see a few errors here and there but it does look very simple. I even noticed how much faster app re-start and module builds were happening as those compared to rev 31. I am pleased so far with what I have seen on rev 35. The course is still going on.. currently on week 2 of 3. You could stil enroll and get the learning materials. If there is something you would like to see, let me know and i can try to get something demo'd - otherwise, I can present it on the SIT Guadalajara. Thank you for your comment.

      Author's profile photo Nabheet Madan
      Nabheet Madan

      Thanks for the great blog as always. I hope you are following DJ Adams twitch series we are developing the similar application using local nodejs/ @sap/cds npm pacakge and then later using CF cli to delpoy the app. I will say if you are not following then a must attend as it goes into the background of many things:)


      Author's profile photo Sergio Guerrero
      Sergio Guerrero
      Blog Post Author

      yes I follow him  🙂  thanks for your comment - as i mentioned on my tweet - I am honored to have met him at SAP Tech ed last year and thankful for his knowledge sharing with the community. Looking forward to learning more from him and other SAP mentors

      Author's profile photo Renjith E P
      Renjith E P

      Hello Sergio,

      Thanks for the wonderful explanation of exposing cds entities via odata v4 with node.js.

      In our project , we have exposed the data via odata, as you have explained in your blog. Now we are trying to implement user authentication on the odata part so that only authenticated calls would be able to fetch the data. Could you please provide me some insights/details on how to enable user authentication for exposed odata ?

      Author's profile photo Sergio Guerrero
      Sergio Guerrero
      Blog Post Author

      if you look at the screenshot with project details, there is a checkbox to enable the UAA service. That service is used for authentication from the consumer to the odata service