Technology Blog Posts by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Venugopal
Product and Topic Expert
Product and Topic Expert
2,466

Overview

SAP Build portfolio provides rich set of capabilities to build cloud native applications in SAP Business Technology Platform. Customers and Partners could develop extension scenarios as part of their clean core strategy using SAP Build. It enables fusion development using low-code/pro-code tools and services, developers or line of business experts with different skills set could collaboratively work to build cloud native solutions.

 A full stack application consists of UIs, Workflows, Business logic and Persistency. Of course integration and consumption of APIs, publishing events ,consuming events from multiple applications are common requirements while building a full stack application. SAP Build Process Automation is a low-code solution to model and execute workflows in Business Technology Platform. The low-code editor enable process experts or developers to model workflows based on various use cases. Consuming data models, APIs and events from various applications like S/4 HANA , leads to complex data models and flow logic in workflow models .This leads to many preprocessing steps, complex mapping logics and writing java scripts within the workflow, which are essentially not part of the core process own by the process owners. This makes the workflow models less intuitive for a process owner, future modifications and maintenance of workflow models become more time consuming and error prone.

This blog explains how to build workflow solutions by consuming simplified APIs, Events with business semantics and lightweight data models so that a process expert or developer could build workflows by focusing on the core process logic and keep the rest outside the workflow model. SAP Build portfolio offers services and frameworks to solve the above problem and build robust workflow solutions together with SAP Build Process Automation.  SAP Cloud Application programming Model (CAP),part of SAP Build portfolio providing rich set of capabilities, best practises to define domain models and services, consume and provision APIs out of the box, publish and consume business Events. 

SAP Cloud Application Programing Model (CAP)

CAP is a framework of tools, languages and libraries, enabling developers to focus on domain, service modeling in a language agnostic way by using Core Data Services(CDS) .It provides best practises, integration to other services  enabling developers to focus more on application logic without implementing low level recurring tasks. CAP abstracts many low level technical aspects like authentication, multitenancy, transaction management, service binding, messaging , networking ,audit logging etc enable developers to focus on their domain models and core application logic. This reduce time, effort and naturally reduce the total cost of development. 

CAP -  Build Cloud Native Applications

CAP enable developers to build modularised cloud native solutions and micro services without writing boilerplate code. Some of the key aspects of CAP are

  • Focus on domain and service modeling, providing out of box generic implementations such as CRUD operations. 
  • CDS as the backbone, provides language agnostic way of designing domain models ,services, queries and expressions.
  • Out of the box integration to various BTP services, reduces code and effort.
  • Standard features like Authorization, Messaging, Input validation, Localisation, Audit logging, Multi Tenancy, Extensibility etc are provided out of the box.
  • Ouf of the box integration with Fiori Elements using annotations and supports other UI technologies like SAP UI5, React etc.
  • Supports various Protocols to consume APIs from different applications and expose APIs as OData/REST.
  • Publishing events and consuming events from other  services / business applications.
  • Choice of development environments like Business Application Studio, Visual Studio Code and IntelliJ.
  • Apart from SAP HANA Cloud, supports PostgreSQL to persists data models.
  • Standard plugins for integration with other BTP services like Document Management, Alert Notification Service , Audit Logging etc and plugins contributed by community.
  • Supports java / node.js to implement custom logic such as actions / functions / event handlers or input validations etc.
  • Consuming packages/libraries from NPM / Maven using declarative dependency .
  • Deployment to Cloud Foundry and Kyma.
  • CI/CD pipeline to automate build, test and deployment.

SAP Build Process Automation

 Build Process Automation enable modeling workflows,tasks and automations using low-code development environment. It provides an integrated development environment for developers and process experts to model workflows, decisions and consume APIs from various line of business applications. It is the successor product of SAP Workflow Management and provides better integrations to Decision/Business Rules, Robotic Process Automation. It is possible to consume REST/OData APIs from different line of business applications  as Actions by configuring destinations to the respective end points.

How to leverage CAP while building Workflow solutions in BTP

The following  sections explains the advantages of using CAP while building Workflow Solution and benefit from the out of the box capabilities CAP provides as part of building cloud native solutions. The below solution diagram shows how CAP can be used together with Process Automation while building a workflow solution in SAP BTP. The workflow models and user interfaces are accessing the CAP services as OData / REST APIs and events. The CAP layer provides a semantic layer of APIs and Events to workflows and UIs. This leverage the out of the box capabilities and best practises of CAP and simplify the workflow development.

SBPA-CAP Integration.png

Domain Models and Services

Every application uses  domain models based on various data types and requires services to provide access to these models based on various constraints. In a workflow solution, the workflow context is based on a json schema and all the activities read or update the context. The data models which are accessed from remote applications or updates from human tasks or APIs are all part of the workflow context. Depending on the requirements, the domain models requires local persistence or they are accessed from remote applications. Either way, the workflows need this in the context while executing workflow steps and post completion for analytical and auditing reasons.

Keeping the workflow context simple and lightweight  has obvious advantages. For eg: keeping the basic data of a purchase order or sales order as key attributes in the process context and access the data models later when it is required. It helps the workflow developer to focus on process logic without consuming complex data models or not performing complex mappings or without writing scripts to manipulate the context. User interfaces used in approval tasks can load the data models based on fine granular authorizations out side the workflow context by using the key attributes available in the workflow context. This will also help those scenarios requires fine granular authorization to access business data .Input validations are performed out of the box based on annotations defined in the data models in CAP. It will also overcome any limitations in the max size of the workflow context.

workflow-CAP.png

Create data models in CAP, choose the right persistency solution between HANA and PostgreSQL. Keep the process context light weight by populating only the key attributes of the data model to the process context and access CAP models using CAP services as and when it is required. Approval UIs can access the CAP data models using services. The data models are accessible post completion of the workflow and it can be accessed from other analytical and support applications based on fine granular authorizations.

Security

Authorization concepts in CAP CDS  helps workflow applications to define very fine granular authorization on domain models and services. The workflow context is accessible using a global role or an instance role but global role override the instance role and make it accessible to all. Applications requiring fine granular authorizations based on user groups or more fine granular approach based on specific attributes are possible using CDS authorization.

CDS enable developers to provide access control at entity and service level. There are different annotations for eg:

@readonly/@InsertOnly - at an entity level and applicable for all authenticated users.

@Requires - access control based on user or user groups defined at entity or service level.

@Restrict - access control based on users or user group on all operations based on specific conditions. This can be defined using a generic way like  { grant:<events>, to:<roles>, where:<filter-condition> }.

The 'grant' accepts all CRUD operations, Actions and Functions. The 'to' property enable specific roles to perform the operation. The 'where' enable additional filters based on one or more attributes.

Publishing and Consuming Events

Business applications are emitting events based on various transactions. As an example, SAP S/4 HANA provision business events, which applications can subscribe and consume. In a side-by-side extensibility scenario, these events can be consumed and extend processes in BTP. But often there are some preprocessing steps required before triggering a workflow or consuming them in a workflow. As an example, an approval required only if the Sales Order is of certain type and above certain value. Or changes in a Business Partner should only require one active workflow instance irrespective of number of changes to the same Business Partner object etc. In all these cases the provider system publishing events and the consumer needs to evaluate the conditions before triggering an approval workflow. Implementing all these logic in a workflow model add additional complexity and bring more technical implementation than the actual process flow logic.

Subscribing business events from applications like S/4 HANA using CAP and do the necessary preprocessing steps, add additional business semantics and expose them as a business event to Process Automation  or use the Process Automation REST API to start the workflow. The workflow developer able to consume an Event  with required context and able to build the flow logic without performing additional preprocessing steps.

Provisioning events based on the data models also enable other applications to subscribe those events. CAP enable provisioning of events based on transactional changes or custom events. This will enable applications to subscribe events not directly from the workflow instance but from the underlying CAP data models. Using events based on CRUD operations on the data models, workflows can be started from CAP using custom logic using node.js or java. 

Enriching Process Visibility with CAP Events

Process Visibility is a capability in Process Automation to provide real time visibility into workflows. Process Automation provision workflow events and consumed from process visibility. Process visibility events can be further enriched using events based on CAP domain models using the out of the box integration CAP provides with Event Mesh. for eg: when a PO created or Modified, CAP can trigger an event with required context information  including the PO number and Process Visibility could consume the event.

Consuming Services from other Applications

All business applications expose APIs to access their data models by other applications. They use different protocols like REST ,OData, BAPI, SOAP etc and different representations like json or xml. Often the responses while reading an object or the request body while posting an object contains  complex nested structures. This require additional validations, transformations of data types , initializing or adding default attributes and exception management  after executing the HTTP operations. A workflow logic implementation only requires a subset of the data model but need to implement additional logic as scripts to validate, transform the data etc before posting them the transactional system.

Consuming APIs from business applications in CAP and implement the required validation,  transformation or business logic and expose a simplified interface to Process Automation enable workflow developers to focus more into the flow logic than do the data transformation or validation logic within the workflow model.

User Interfaces

Workflow solutions require user interfaces to start , approve and for other operational purposes. These user interface consume REST APIs provided by Process Automation. But these user interfaces also require access to the underlying data models with fine granular authorizations to make sure the users have the required authorization to view or modify the data. 

CAP provides out of the box support to build SAP Fiori Elements by using annotations in the services. This include out of the box support for Draft ,enable business users to work in multiple sessions without loosing the data they entered in the UIs.

Process Automation approval tasks only support SAP UI5. So it is only possible to use Fiori Elements for workflow start UIs or any other UIs for operational purposes by consuming CAP data models.

Integration with other BTP Services

Document Management

SAP Document Management service provides SDM plugin for java and node.js. Developers can extend their domain models with attachments as child entity using composition. For eg: A purchasing document or sales document entity can have multiple attachments. The documents are accessible in Fiori elements without additional coding and authorized users can perform CRUD operations.

Managing documents together with the domain model, keep the workflow model clean but have relationship to the documents through the domain model attached to the workflow context. This keep the documents part of the domain model and accessible from approval UIs or other applications without having additional implementations in the workflow logic.

Alert Notification Service

Alert Notification Plugin provides notification capabilities through different channels. Alert Notification Plugin in CAP provides out of the box integration and enable business users to consume notifications through their Work Zone portal. For eg: After creating a purchase requisition or sale order, a notification can be created with  purchase requisition ID or sales order ID as part of post processing.  

Audit Logging

The Audit Logging plugin provides out of the box support for logging personal data related operations by annotating the data model and attributes. These annotations enable automatically logging personal data related operations.

Integration to Audit Logging, relieve the Workflow developer from managing personal data and data privacy related aspects in a workflow model, but able to focus on workflow modelling by accessing the respective data models through CAP.

Other key CAP capabilities 

Localization(i18N), Multitenancy, Extensibility etc are some of the key capabilities customers / partners could leverage while building cloud native solutions. These capabilities supported out of the box in CAP and enable application developers to focus on application logic. 

Summary

Cloud Application Programming model provides a rich set of capabilities to simplify application development without writing low level code and  out of the box integration to many platform services. CAP can be used as a semantic layer to access the data models and events with business context from various applications. This provides a simplified access to the domain models , events  and enable the  Workflow developer or Process experts to build the core process flow logic.

 

 

 

 

1 Comment