Skip to Content
Technical Articles

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.


SWAPI – the Star Wars API. This sample is based upon the sample at which in turn was based upon The original source can be found at

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.

Data Model

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.



StarWarsFilm Service



StarWarsPeople Service



StarWarsPlanet Service



StarWarsSpecies Service



StarWarsStarship Service



StarWarsVechicle Service


Download and Installation

The original data model and data source files are in in the oldPython\resources folder.

The rest of the operations can be performed within the cap folder and there are scripts in the package.json file major operations.

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

The command 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.


CAP Preview Test Page


Fiori Preview List for Film Entity


Fiori Preview Overview Edit Mode for Film Entity



Star Wars and all associated names are copyright Lucasfilm ltd. All data in this sample has been freely collected from Wookiepedia under CC-BY-SA.

You must be Logged on to comment or reply to a post.
      • Hi Thomas its an honor to talk with you.

        I was asking for the scenario when you need to edit data and send a file (an image of the film for example) to your odata service. Does odata support this kind of services?


        Im reasearchin about CAP. It seems an easy way to expose entities as an odata service.


        Thanks again for your job.



        • No media processing in this sample, but another one does have some:

    • Actually in this case I was converting an existing data model defined in JSON schema from the original project.  I was lazy and wrote a script to convert the base model and i18n entries over from that.  For all the additional annotations, compositions and annotations I didn’t really use a methodology.  I just typed it all in by hand.

  • Hi Thomas,

    What naming convention are you following for the data model?  I notice that in most cases the entity names have a capitalised first letter, such as Starship, Vehicles and Planet, whereas in some cases the entity name starts with a lower case letter, such as directors, producers, eyeColors and skinColors.



  • Amazing job Thomas!

    I am trying this out in BAS in the trial account and was successfully able to clone it under my projects .  But now I ran into an issue when I run "npm run build" command. I am running it within the cap folder. This is the error. Am I missing a step?