Technical Articles
Working with Project Hierarchy in SAP Cloud Platform Business Rules
There are often use cases in SaaS scenarios and otherwise, where providers want to publish a base version of the standard rule templates and then consumers can extend it based on their needs and requirements. There are also cases where there could be common business policies across globe but then there are mandatory policies based on regions like employee onboarding precheck rules or product delivery charges based on taxes which depends on regions. With Project Hierarchy, you can now create base projects and several sub projects extending this base project. As part of project hierarchy, you can also expose data objects and rules that could be used for rule modelling in sub projects.
It is recommended to release the digital content with reusable vocabulary and rules as the base project in the API Business Hub. The base project should be included in a separate project, which maintains the customer specific rules. Industry or region based vocabulary extensions can be created as an intermediate project between the base project and customer specific local project and it should be delivered via SAP API Business Hub.
Let us understand Project Hierarchy in bit more detail.
When I say project hierarchy, I mean 3 things:
- you can extend the data objects in base project
- you can expose data objects and rules in base project
- you can create new project that extends any available versioned project.
Now let us dig deeper into these and see how we can achieve project hierarchy from Manage Rules Application. Here I will explain things in 2 parts. (a) what needs to be done in base project to make it extension ready, and (b) what all could be done in sub-project to take advantage of project hierarchy capabilities.
Building Base Project for Extension
Extending Data Object
- You can set the data object property of Extensible to true. This means that you can extend this data object in sub project.
- As part of extending the data object, you can:
- Add new attributes
- Add new associations
- Override any existing annotation.
Note: you cannot delete or update anything in the data objects or its attributes defined in base project from its sub-project
- Data object can be extended only once which means let say there is there is a data object Order that is marked as extensible in base project, then you cannot mark the same in any subsequent sub-projects
Exposing Vocabulary
- In order to consume business rules models in sub-project, they must be exposed in the base project. You can only extend data objects and rules. This you can do by selecting the rules or data objects (active or inactive) from the project.
Creating Version
- Only versioned project can be extended. As the last step, you need to create a tagged version or revision of the project that you want to use as base or template for extension. You can do that via release version option in project
Extending the Base Project
You will see a new UI label with name Included in the manage rules application. Content under there are used while working with project hierarchies like included data objects, included rules etc.
Creating Project with Hierarchy
- There is no special way how you create a project with hierarchies. All you need is create the business rules project and set the Included Projects property to specify the list base projects.
- Yes, you can extend from multiple base projects
- Any change in the base project will automatically be reflected in the sub-project
- Only 2-level of hierarchies are supported. It means that one project can be extended to 2 levels. Let us say, you have projectA. You can create a projectAA which extends projectA and projectAAA which further extends projectAA. Not beyond that. So, itโs like:
- supported: projectA (base) –> projectAA –> projectAAA (2 level)
- not supported: projectA (base) –> projectAA –> projectAAA –> projectAAAA (3 level)
- As soon as you choose the base project, all the data objects and rules exposed in base project will be made available in sub-project for modelling.
- To view them, you will see Included Data Objects or Included Rules at respective tabs in Manage Project Application
Extending Data Object
- This is the most salient feature of this entire concept. The beauty is that as you extend the data object, you are not only entitled to use the new attributes of the extended data object but also the attributes from the base data object- which essentially means that if you have a data object: say DOx in base project with 2 attributes and you create a new data object: say DOxy in sub-project (that extends DOx). Now, in this DOxy you create 3 new attributes so when you use DOxy you will have 5 attributes (2 from DOx and 3 from DOxy)
- To extend the data object, you need to
- Create the data object in the sub-project as usual
- Using API, you need to update the data object JSON to include the data object ID from the base project which you want to extend. Currently this feature is not available in tool and therefore we need to use API. For this:
- export the project in zip format
- extract the project file
- Add this Extension element (which has the data object ID from the base project) in the Data Object that you want to extend:
"Extension": {
"ObjectId": "a320c58f9db84e16a0f7aa72ac9eefeb"
}
- Zip the project file again and import it back from the tool
- You can also do the same via Authoring API for Data Object:
PUT: /v1/projects/{id}/dataobjects/{objectId}
Modelling Options in Extended Project
- Once you have extended data object, you can see all the attributes (both from base and extended) in the extended data object. They will appear while modelling expression or rules
Invoking Business Rules from Hierarchical Project
- Another important aspect is no-interface-change. This means the same rule service in both the base and extended project will yield different results.
- There is no change in the API to author and invoke the rules in extended project. It is available in API Business Hub
Project hierarchy is one of the major enhancements in business rules modelling. Use it in your existing scenarios to create design time templates and give it for extension to your consumers.
That was indeed a detailed explanation Archana !!!! Thank you ๐
First of all many thanks for your time and for sharing such a wonderful blog post.
One thing I should say, you are a great teacher!!
-Thanks, Som
Thank you Somnath. I am very humbled. Do let me know if you have any questions on Business Rules.