Skip to Content
Technical Articles

XSOdata Service development in SAP Cloud Platform Cockpit and exposing it for Consumption

Most of the time I come across a way of using on-premise(SAP Logon and other) software for building odata service and then using SAP Cloud Connector for integration of on-Premise with the application,lets learn something new and different.

With current trend of switching to cloud, SAP also has introduced new feature of developing service(XSOdata service) in SAP Cloud Platform Cockpit instead of using on-Premise,I will no longer need SAP Cloud Connector in order to integrate service with application.

Moreover,the best part is I can access it any time,any where just by providing credential while its not possible in on-Premise since it is not on the web.

Note :- The XSOdata service which will be developed in SAP Cloud Platform stops after every 12 hours(because I will be using trial version) I just need to restart it.If not done Database and service will be deleted after 20 days.

It is not that I need to do setup or configuration or coding again for restarting,I just need to click on “Start” button again.

Step 1 : Login to SAP Cloud Platform Cockpit and go to “Neo” environment.

 

 

 

Creating Database Instance and configuration

Step 2 : Go to “SAP HANA /SAP ASE”->Databases & Schemas

Step 3 : Click on “New” ,fill up the fields and setup password for database.

Note :- Enable the “DP Server” as well and name Database ID as “bookshopdbinstance”.

Step 4 : After clicking on “Create” SAP will do the setup for database creation I can check that on  “Events”.

Step 4(a) : Wait until “Tenant DB creation finished successfully (created and configured)” is shown.

Step 4(b) : “Tenant DB creation is done only once (during initial creation of database).

Note :- For first time creation of database it will take around 20 mins(depending on network bandwidth) for setting up but next time when I restart it will take less than a minute.

Step 4(c) : In the “Overview” section once setup is done by SAP it will shown as “Started”.

Step 4(d) : From the “Overview” I can start or stop the database.

Step 4(e) : At this stage(since it is initial setup) I need to do some assignment of roles by going to SAP HANA Cockpit(Administration Tools),after this only I will be able to access “SAP HANA Web-Based Development Workbench”(otherwise it will show 403 -Forbbiden).

Step 4(f) : Go to “SAP HANA Cockpit”.

Step 4(g) : Click on “Ok”.

Step 4(h) : Successful message will be displayed,click on “Continue”.

Step 4(i) : Go to “Manage Roles & Users”->”Users”->”SYSTEM”->”Granted Roles”.

Step 4(j) : Click on “+” to add roles which includes “CatalogDeveloper”,”Developer”,
“EditorDeveloper”.

Step 4(k) : Save the changes,this will complete the assignment of roles.

Note : Step 4(g) and Step 4(k) are only when I am accessing “SAP HANA Cockpit” first time after that it is not needed.

Step 4(l) : Go back to “Overview ,”now the error which is showing in Step 4(e) will be gone and I will be able to access “SAP HANA Web-Based Development Workbench”.

Note :- Enter ID as “SYSTEM” and Password(what you have set in Step 3) whenever it asks for credential for login in SAP HANA.

Step 5 : This completes our setup and assignment of roles for accessing our XSOdata service.I will be using “SAP HANA Web-Based Development Workbench” for creating our service.

Step 6 : Follow Step 4(c) to access “SAP HANA Web-Based Development Workbench”.In this I have 4 section,I will use “Editor” for coding our XSOdata service and “Catalog” as a way for visualizing table and setting up schema.

Step 7 : Go to “Catalog”(create a scehma),uncheck case sensitive option and name it as    “bookshopSchema“.

Note :- Use the same schema name in “Editor” while developing XSOdata service.Table inside the schema in “Catalog” will be created automatically as I develop in “Editor”.

Step 8 : Go to “Editor”(here I will build our XSOdata service).

Step 8(a) : Create a “Package” and name it as “bookshop_pkg“.

Step 8(b) : From the Package which I have created, select “Create Application” and select “Empty Application” in Template.

Note :- Package name will come by default.

Step 8(c) : This will auto generate 3 files (.xsaccess,.xsapp,index.html)

 

{
    "exposed": true,
    "authentication": [{
        "method": "Form"
    }],

    "mime_mapping": [{
        "extension": "jpg",
        "mimetype": "image/jpeg"
    }],
    "force_ssl": false,
    "enable_etags": true,
    "prevent_xsrf": false,
    "anonymous_connection": null,
    "cors": [{
        "enabled": true
    }],
    "cache_control": "no-cache, no-store",
    "default_file": "index.html"
}

Note : In “.xsaccess” file make some changes as shown above in Step 9(c).

Step 8(d):Create new file for developing table structure(“bookshoptable.hdbtable”).

table.schemaName = "bookshopSchema";
table.tableType = COLUMNSTORE;
table.columns = [
                { name = "BookId"; sqlType = VARCHAR; nullable = false; length = 7; },
                { name = "AuthorName"; sqlType = VARCHAR; nullable = false; length = 20; },
                { name = "PublisherName"; sqlType = VARCHAR; nullable = false; length = 35; },
                { name = "Price"; sqlType = VARCHAR; nullable = false; length = 35; }
                ];
table.primaryKey.pkcolumns = ["BookId"];

Step 8(e) : Create file for defining schema(“myschema.hdbschema“).

schema_name="bookshopSchema";

Step 8(f) : Create a XSOdata service file(“service.xsodata“).

service{
"bookshop_pkg::bookshoptable";
}

Step 8(g) : Activate “bookshoptable.hdbtable” file and “service.xsodata” if not activated(check the console).

Step 9 : I can get the service link for consumption by clicking on “service.xsodata” and running this file(by clicking on “Run” button).Check the link whether it is working or not.

Note :- Add “/bookshoptable” in the URL.

Step 10 : I can visualize the table in “Catalog”->”bookshopSchema”->”Tables”.

Note :- This table structure is created automatically based on what I have coded in “.hdbtable” file in “Editor”.

Step 11 : Enter some data in the table in “Catalog” (by clicking onTables->Table_Name-> “Open Content”).

Step 12 : Check the service link again I will get data which I have entered.

Step 13 : For consumption I will create destination in SAP Cloud Platform Cockpit and use that in our SAP UI5 application.

Note : Providing the URL which I get in Step 9(do not put (“/bookshop_pkg/service.xsodata/”),user id will be “SYSTEM” and password will be what I set in Step 3.

Note :- Check the connection.

Great !,XSOdata service is now successfully created, deployed, created destination and its ready for consumption.

Note :- For Consumption and performing CRUD operation follow this blog post “https://blogs.sap.com/2016/08/15/crud-operations-using-odata-model-xsodata-in-sap-ui5/“.

5 Comments
You must be Logged on to comment or reply to a post.
  • Thanks for the post Ashu Rai. This i believe is based on XS classic. Now with latest HANA version 2.0 we use XSA for create services etc via SAP webide. You can google for more details. Another quick way to create is using SAP Cloud application programming model which also i would recommend to read about. There are good number of tutorials also on the same.

    Nabheet

    • Hi Nabheet,

      Please go through the comment for clarification 🙂

      “Now with latest HANA version 2.0′

      Let me clear about your version issue ,the HANA version is 2.0 only its the SAP HANA platform edition which you are talking about. You can clear your doubt by following this steps in the blog you will get to know that as soon as you create a database in the container you will get platform container version number  starting with “1.00.” (it is not HANA version 1.0).Please follow the link to understand the version –

      https://blogs.sap.com/2020/03/13/at-your-service-sap-hana-2.0-an-introduction-2/.

      “This i believe is based on XS classic,we use XSA for create services etc via SAP webide.”

      Not all the application follow XSA approach there are certain trade of which the developer should keep in mind for going with XS Classic or XS Advance(XSA).Please read the guidlines provided by SAP

      https://help.sap.com/viewer/58d81eb4c9bc4899ba972c9fe7a1a115/2.0.02/en-US/b1333dbbfa9549ffa76850b5b5ca455a.html

      “Another quick way to create is using SAP Cloud application programming model which also i would recommend to read about. There are good number of tutorials also on the same”

      There are various ways to build the project it totally depends on the specifications,features, time constraint and cost provided by the end user.We should select the approach based on that.This blog is not for making sure that every application should be build by following this method only it is just suggesting a way in which developer can work on it if he/she not finding any solution or got stuck.

      Thanks & Regards,

      Ashutosh Rai

      • Thank you Ashu for the clarification my only intention of the comment was as follow

        • The post talks about an alternative to Create your service via XSOdata for testing your app quickly without the onpremise odata stuff. So i though of suggesting another way out SAP Cloud Application programming model also which is much quicker and can be deployed to CF on HANA database. That was all my intention considering the post😀
        • When i mentioned using XSA or full stack web ide all i meant was this js the recommended path if some one wants to learn, he shall also understand that apart from the XSC stuff. I agree it depend on case to case my only intention was the person should be aware.

         

        Thank you once again for the post and detailed comment🙏