New SAP Cloud Application Programming Model Sample for Many-to-Many Relationships and Fiori Annotations
If you are looking for something fun yet educational this holiday season to play around with, might I suggest this new SAP Cloud Application Programming Model sample that was just released:
I was recently looking around for a fun yet decently complex sample data model to reuse in an CAP example. I stubbled across SWAP – the Star Wars API. It had the interesting level of complexity I was looking for. It’s filled with many-to-many bi-directional relationships. Yet the data model is easy to understand on the surface. There are Star Wars films that contain planets, characters, starships, etc. I also thought it make a good example of complex Fiori based maintenance. Going in I wasn’t exactly sure how the many-to-many relationships would work with Fiori Draft and deep editing; but it turns out the functionality worked out nicely.
Although the Star Wars API had been abandoned, this also provided a good challenge. I kept the original project’s data files as JSON and wrote converter scripts using CAP CQL to convert the data into the new version of the data model.
Overall I think this sample provides examples of a lot of deeper and more complex topics in the SAP Cloud Application Programming Model and Fiori area; but does so with some data that is a bit of fun to play around with.
The original project was a data set and data model based in Python that exposed data from the Star Wars movies sourced originally from the community wiki: Wookiepedia. It encompasses data about the People, Films, Species, Starships, Vehicles and Planets from Star Wars.
The projects described above have fallen out of maintenance but still offered the opportunity for a fun yet challenging learning experience from a non-trivial data model. The many bi-directional, many-to-many relationships with the data provides a good basis for an SAP Cloud Application Programming Model and Fiori Draft UI sample.
I’ve used the new openAPI functionality in CAP to generate both the Swagger UI test framework but also entity diagrams for the data model.
- SAP Cloud Application Programming November 2020 (4.4.6) or higher
- I developed and tested locally using Node.js 12.x
- Swagger UI for Express
Download and Installation
The original data model and data source files are in in the oldPython\resources folder.
You can use
npm run build to perform the cds build and should be ran before deployment to HANA or whenever you make changes to the data model.
You can run
npm run hana to deploy the content to your HANA database. Just be sure from the terminal that you are logged into the cf/xs cli and targeting the Account/Org/Space where you want the content to live. By default this command will create an HDI Container instance named starwars.
You can run the command
npm run load. This command will read the original JSON data files from the source project and load them into your HANA database using Cloud Application Programming Model CQL. The loading script is convertData.js
npm start or
cds run will start the service running locally. It will open the standard CAP test page where you expolore the OData Services or the Fiori UI.
From the Cloud Application Programming Model preview (which opens locally when using
npm start or
cds run), you can access the Swagger UI test tool (with entity diagrams), test the OData services or metadata calls directly in the browser, or access the Fiori preview UI for each of the main entities.