-
Notifications
You must be signed in to change notification settings - Fork 1
4. Pre built Extensions
In the previous chapter, we explored how to customize a CAP-based SaaS application to meet the specific needs of an individual customer.
In this chapter, we will step into the shoes of an SAP Partner who is responsible for developing and sharing a pre-built verticalization package for reuse.
The task at hand is as follows:
-
Customer
t1
, who happens to be an SAP Partner, has already built a custom extension for their own use, as demonstrated in exercise 3. Now, they have decided to share and sell this extension as a reusable pre-built verticalization package for the incidents management app for other solar panel vendors. -
Another solar panel vendor, customer
t2
, is interested in the pre-built extension and decides to purchase it. By activating the pre-built extension, customert2
can leverage the customized functionality without having to invest additional efforts in building the same extensions from scratch.
Creating pre-built reusable extensions follows the same process as custom extensions. Since we have already created a custom extension in exercise 3 as a customer and SAP Partner t1
, we have a head start and can continue from there.
To share a pre-built extension, such as uploading it to a marketplace, we need to create a .tgz
archive, which we have already done.
In addition to the archive, we should include some publication details in our package.json
file. Here's what you need to do:
-
Switch to browser tab for project
t1x
-
Open the
package.json
file -
Fill in the version, description, and author fields as shown below:
{ "name": "@t1/incidents", "extends": "@capire/incidents", "version": "1.0.0", "description": "Verticalization package for incidents management application", "author": "[email protected]" }
Note: that these details are for demonstration purposes only, and CAP itself does not require this information.
-
Rebuild the extension archive:
cds build
This will generate the ./gen/extension.tgz
archive.
Now that we have generated the extension archive, the next step is to upload it to a marketplace. Since there is currently no standard marketplace offered by SAP BTP, we will simulate this step by copying the archive to a different location:
-
Run this command in the Terminal:
cp gen/extension.tgz ../shared-ext.tgz
Once a pre-built extension package is purchased and downloaded by consumers, it can be activated in the customer's subscription. Although we don't have a standard marketplace for this session, we will simulate this process for customer t2
. However, before activating the extension, let's first see in steps 1 and 2 the non-extended version of the app for t2
.
-
Switch to the Launchpad for AD264 browser tab
-
Click on the [ Carol (t2) ] button. This will open a new browser tab showing the list of Incidents without the Components column.
-
Switch to the browser tab for the
incidents
project. -
Activate the pre-built extension for tenant
t2
by running the following command in the Terminal:cds push ../shared-ext.tgz --to http://localhost:4005 -u carol
-
Return to the application tab we opened before (if you can't find it, go via the Launchpad page again).
-
Refresh the page (e.g., using the
Cmd/Ctrl-R
shortcut). Voilà! Now the Components column is visible for customer/tenantt2
, directly in the production tenant. -
Go ahead, open the License details page on an entry, and [ Edit ] the data, enter some values, [ Save ] your changes, see them displayed in the details page, go back to the list and see your entered value in Component column of the first row.
You've now learned to easily create, share and reuse a pre-built extension package.
CAP Spotlights:
- Uniform Programming Model — we've seen that CAP offers a very consistent, uniform programming model: Adding individual custom extensions is done in very much the same way as building CAP applications in general. The same applies to creating pre-built extension packages. Just the steps to deploy differ.
- Extend, Reuse & Compose — CAP intrinsically supports sharing and reusing pre-built application packages, be it base applications, extensions, or content packages. This allows consumers of those packages to flexibly compose own solutions instead of building everything from scratch.
In the following exercise 5 — Feature-Toggled Extensions, you will see how SaaS application providers themselves can provide similar pre-built extensions and enable or disable them for individual tenants using the technique of feature toggles.