SAP Builders Blog Posts
Learn from peers about their low-code journey and write your own blog posts to share your thoughts and experiences as you become an SAP Builder.
cancel
Showing results for 
Search instead for 
Did you mean: 
KamalKumar
Associate
Associate

With the Business Rules capability in SAP Workflow Management, you were able to build a custom SAPUI5 application by embedding the rule builder control (SAPUI5 SDK documentation) in your application. Blogs like Embed Business Rules SAPUI5 control in your custom applications and Author SAP Cloud Platform based business rules using Fiori Application helped you in achieving that. SAP Workflow Management is deprecated since August 15, 2023. Though you can continue to use the business rules in SAP Workflow Management until your contract expires, you would eventually want to migrate to SAP Build Process Automation, which is the successor.

This blog explains what changes you need to perform to your custom application so that it will continue to work even after importing the rule projects into the Manage Rules Project of SAP Build Process Automation.

Pre-requisites:

  1. You have an application deployed on the SAP BTP Cloud Foundry environment that consumes the SAP UI5 Rules control. Sample reference application : cf-rulesmanager.zip
  2. You have subscribed to the SAP Build Process Automation application as described in the help page.
    Screenshot 2024-03-13 at 1.06.02 PM.png
  3. You have created an instance of the SAP Build Process Automation service as described in the SAP help page.
    Screenshot 2024-03-13 at 1.06.57 PM.png
  4. Migrate Business Rules Projects to SAP Build Process Automation.

    Business Rules capability in SAP Workflow Management can be easily transitioned to SAP Build Process Automation. Simply export the rule project from the Manage Rules Project application in SAP Workflow Management and import the same in SAP Build Process Automation using Manage Rules Project application. Please note that the the Manage Rules Project application in SAP Build Process Automation supports only reusing existing Business Rules projects from SAP Workflow Management or Business rules service in Neo and not creating net new Business Rules Project. New rules projects can be modelled using the Decision capability of application development Lobby.

Modify the Custom Application to work with a service instance of SAP Build Process Automation

Perform the following modifications to the custom application to enable it to consume the SAP Build Process Automation service instance.

Remove dependency to the rules-service and add dependency to the SAP Build process Automation service instance

In the custom application (for example,cf-rulesmanager), the mta.yaml file looks like the following snippet:

 

ID: rulesmanager
_schema-version: '2.1'
parameters:
  deploy_mode: html5-repo
version: 0.0.1
modules:
  - name: rulesmanager_appRouter
    type: approuter.nodejs
    path: rulesmanager_appRouter
    parameters:
      disk-quota: 256M
      memory: 256M
    requires:
      - name: rulesmanager_html5_repo_runtime
      - name: bpmruleconsumer-uaa
      - name: wm_businessrules
  - name: rulesmanager_ui_deployer
    type: com.sap.html5.application-content
    path: rulesmanager_ui_deployer
    requires:
      - name: rulesmanager_html5_repo_host
    build-parameters:
      requires:
        - name: custom
          artifacts:
            - './*'
          target-path: resources/custom
  - name: custom
    type: html5
    path: custom
    build-parameters:
      builder: grunt
      supported-platforms: []
      build-result: dist
resources:
  - name: rulesmanager_html5_repo_runtime
    parameters:
      service-plan: app-runtime
      service: html5-apps-repo
    type: org.cloudfoundry.managed-service
  - name: bpmruleconsumer-uaa
    parameters:
      path: ./xs-security.json
      service-plan: application
      service: xsuaa
    type: org.cloudfoundry.existing-service
  - name: wm_businessrules
    type: org.cloudfoundry.existing-service
  - name: rulesmanager_html5_repo_host
    type: org.cloudfoundry.managed-service
    parameters:
      service: html5-apps-repo
      service-plan: app-host

 

Remove the dependencies to the rules-service wm_businessrules (line number 16, 47, 48) and replace it with your SAP Build Process Automation service instance (for example, spa-instance). After the changes, the mta.yaml should look like this:

 

ID: rulesmanager
_schema-version: '2.1'
parameters:
  deploy_mode: html5-repo
version: 0.0.1
modules:
  - name: rulesmanager_appRouter
    type: approuter.nodejs
    path: rulesmanager_appRouter
    parameters:
      disk-quota: 256M
      memory: 256M
    requires:
      - name: rulesmanager_html5_repo_runtime
      - name: bpmruleconsumer-uaa2
      - name: spa-instance
  - name: rulesmanager_ui_deployer
    type: com.sap.html5.application-content
    path: rulesmanager_ui_deployer
    requires:
      - name: rulesmanager_html5_repo_host
    build-parameters:
      requires:
        - name: custom
          artifacts:
            - './*'
          target-path: resources/custom
  - name: custom
    type: html5
    path: custom
    build-parameters:
      builder: grunt
      supported-platforms: []
      build-result: dist
resources:
  - name: rulesmanager_html5_repo_runtime
    parameters:
      service-plan: app-runtime
      service: html5-apps-repo
    type: org.cloudfoundry.managed-service
  - name: bpmruleconsumer-uaa2
    parameters:
      path: ./xs-security.json
      service-plan: application
      service: xsuaa
    type: org.cloudfoundry.existing-service
  - name: spa-instance
    type: org.cloudfoundry.existing-service
  - name: rulesmanager_html5_repo_host
    type: org.cloudfoundry.managed-service
    parameters:
      service: html5-apps-repo
      service-plan: app-host

 

Adapt the paths in the xs-app.json file to the new service instance

The xs-app.json file in your custom application (for example, cf_rulesmanager) looks like this with the routes configured to the business rules service.

 

{
    "welcomeFile": "/index.html",
    "authenticationMethod": "route",
    "logout": {
        "logoutEndpoint": "/do/logout"
    },
    "routes": [
        {
            "source": "^/bpmrulesrepository/(.*)$",
            "target": "$1",
            "service": "com.sap.bpm.rule",
            "endpoint": "rule_repository_url"
        },
        {
            "source": "^/bpmrulesruntime/(.*)$",
            "target": "rules-service/$1",
            "service": "com.sap.bpm.rule",
            "endpoint": "rule_runtime_url"
        },
        {
            "source": "^(.*)$",
            "target": "$1",
            "service": "html5-apps-repo-rt",
            "authenticationType": "xsuaa"
        }
    ]
}

 

Modify this file to adapt the routes as per the SAP Build Process automation (lines 8 and beyond) and the resulting file should look like this:

 

{
    "welcomeFile": "/index.html",
    "authenticationMethod": "route",
    "logout": {
        "logoutEndpoint": "/do/logout"
    },
    "routes": [
        {
            "source": "^/bpmrulesrepository/rules-service/rest/v1/(.*)$",
		    "target": "/public/rule/repository/rest/v1/$1",
            "service": "com.sap.spa.processautomation",
            "endpoint": "api"
        },
        {
            "source": "^/bpmrulesrepository/rules-service/rule_srv/(.*)$",
		    "target": "/internal/rule/repository/rule_srv/$1",
            "service": "com.sap.spa.processautomation",
            "endpoint": "api"
        },
        {
            "source": "^/bpmrulesrepository/rules-service/vocabulary_srv/(.*)$",
            "target": "/internal/rule/repository/vocabulary_srv/$1",
            "service": "com.sap.spa.processautomation",
            "endpoint": "api"
        },
        {
            "source": "^/bpmrulesruntime/v1/(.*)$",
            "target": "/internal/rule/runtime/v1/$1",
            "service": "com.sap.spa.processautomation",
            "endpoint": "api"
        },
        {
            "source": "^/bpmrulesruntime/rest/(.*)$",
            "target": "/public/rule/runtime/rest/$1",
            "service": "com.sap.spa.processautomation",
            "endpoint": "api"
        },
        {
            "source": "^(.*)$",
            "target": "$1",
            "service": "html5-apps-repo-rt",
            "authenticationType": "xsuaa"
        }
    ]
}

 

Build & Deploy the application

Right-click on the mta.yaml and click on Build MTA Project.

Once successful, right-click the mtar (for example, rulesmanage.mtar) file and deploy.

Screenshot 2024-03-19 at 1.57.43 PM.png

Access the application 

Once the deployment is succesfull, access your custom (example cf_rulesmanager) from the application URL that is available in the application's overview page in SAP BTP cockpit. 

Screenshot 2024-03-19 at 10.11.24 AM.png

 

https://<tenant>.hana.ondemand.com/sapdemorulescustom/index.html

 

Your application can now use SAP Build Process Automation service to connect to the business rules thatare available in the Manage Rules Project app.

Troubleshooting

If you face an issue that says "the redirect_url has an invalid domain", add the following configuration as part of the xsuaa instance "oauth2-configuration" where the url in the array is the url of your application and restart the application.

1.png

 

 

{
  "xsappname": "rulesmanager",
  "tenant-mode": "dedicated",
  "description": "Security profile of called application",
  "scopes": [
    {
      "name": "uaa.user",
      "description": "UAA"
    }
  ],
  "role-templates": [
    {
      "name": "Token_Exchange",
      "description": "UAA",
      "scope-references": [
        "uaa.user"
      ]
    }
  ],
  "oauth2-configuration": {
    "redirect-uris": [
      "https://*********-***-rulesmanager-approuter.cfapps.us10-001.hana.ondemand.com"]
    }
}

 

 

In this blog you learned about how you can migrate an app that consumes a decision table SAPUI5 control to SBPA service instance. All you need to do is:

(a) Remove dependency to the rules service

(b) Add dependency to the SBPA service instance

(c) Adapt the paths in the xs-app.json file

(c) Finally, build, deploy and access the application to manage the business rules.