Create a CDS Entity in SAP BTP, Expose the Entity as an OData Service to Outside world, Deploy to HANA DB and CF as an application and Create a chatbot by consuming the API in SAP CAI (Part 1)
I am writing this blog post on creating a CDS Entity in SAP BTP, Expose the Entity as an OData Service to Outside world, Deploy to HANA DB and cloud foundry as an application, generate the API and Create a chatbot by consuming that API in SAP CAI chatbot.
Little Back Ground:
Sounds interesting. Well I am pretty new to all these. I have created SAP CAI chatbots in the past from SAP HANA XSA workbench on HANA backend tables, Created an XSODATA service and exposed that service to an outside world and then called that API via a webhook call from in SAP CAI chatbot, integrated with SAP Fiori Portal and Facebook messenger also.
But over a period of time the development IDEs got changed from HANA XSA workbench to sap webide to –> now SAP Business Application studio. Even the underlying modelling also changed from packages to HDI Containers to CDS Entities.
Even SAP NEO cloud platform trial is stopped and CF is only enabled, available and now SAP Cloud platform cloud foundry is called SAP Business Technology platform,
Hence SAP partnered with all these cloud data center provider vendors and hosting SAP workloads on all these cloud service providers/vendors and rebranded it to SAP Business Technology Platform.
We will go from the start to the end. Though it was an easy business case there were good number of issues I faced to make it run.
SAP BTP login Screen :
Once you log in with your user name and password you can see that I have created a subaccount and created a dev space. Under dev space I will create a HANA DB instance and deployed application with in that dev space.
But I will post the snapshots which I created and how it looks in BTP when you create those.
Instanced and Subscriptions.
Instances I created and Deployed.
So now your BTP environment is ready
Now lets us go to SAP Business Application Studio :
1st you need to create a dev space and once that dev space created we can create a Full stack application inside the dev space.
The dev space which we created in SAP BTP is different and the dev space which we created SAP BAS is different.
SAP BAS dev is an area in which we you can create applications either using SAP UI 5 Fiori, Node, JAVA languages.
Please understand these as well as in below : –
We need to configure entitlements with shared units or else the deployment will fail.
Please see the below 2 snapshots
Look at the SAP HANA schema and HDI container entitlement configured.
We need to create a plan. I was trying to create a service and deploy the HANA backend models without creating a Quota Plan and every time I was getting a failure message saying I do not have enough memory defined on my dev space the application which I am trying to deploy. After a lot of research I understand that I need to create a quota plan and assign that quota plan to my dev space.
Plan1 which I had created and assigned that plan to my dev space.
Please see the quota plan assignment which I had done for the dev space created.
That’s it. The cloud environment is ready and the applications which you will create on SAP BAS will be deployed successfully on SAP BTP under the dev space which we created above.
Now I was looking for a Business case to build and I was reading lot of blog posts.
I want to give the credit to this blog written by Pavan Krishna Mulpur, @pkrishna and below the blog comments highlighted by Showkath Ali Naseem , @showkath.naseem
I followed this blog and created the scenario using SAP Cloud application Programming model. This is the best business case I found and decided to perform it.
Now Customers those who are still using SAP WEB IDE as their application development they must be thinking what is Cloud application Programming now ?
Those customers need not worry on CAP so soon. We Still can create backend entities or models in SAP WEB IDE and we can still expose those models and of course we are exposing these models using a NODE JS module or Fiori Module or a JAVA module in web ide as well.
But when we move to SAP BTP CF and use SAP provided HANA DB as a service and SAP Business application studio as your IDE for application development SAP is suggesting to create backend entities using CAP and deploy your service using CAP.
Having said that we still have flexibility to create our backend models same as web ide and load data into those tables using SAP SDI flowgraphs and can expose those entities using node js module etc.
But SAP is promoting CAP model for sure.
What is CAP? I do not want to explain again here . Those who are not aware of CAP must go through the excellent blog by : – Daniel Hutzel , @daniel.hutzel
SAP BAS MTAR file to deploy application
U can see the developer tutorial here on how to deploy.
( You can follow tutorials from Thomas Jung and his Team)
Before deploying the entities as a service and creating an O DATA service please ensure below commands are successfully executed.
CDS watch : to see CDS entities were successfully created
NPM INSTALL : to Install node manager packages in the DEV space of Business Application Studio.
Once deploy and the deployment is successful you should see something like this in you dev space.
Now when I click on test1-srv you will see the service and data in it. When you click Sales it will generate sales service and when we click on Purchases Service it will generate Purchase Service.
Please ensure that HANA DB instance is up and running.
Please find below snaps one by one.
Now we had exposed our backend entities which are deployed as Table in HANA HDI containers to the outside world or internet.
Now we can consume these serviced to SAP CAI.
Hope you are with me till now. Let us jump into SAP CAI now.
Which I will explain in Part 2.
Part 2 Link