Skip to Content
Technical Articles
Author's profile photo Venugopal Chembrakalathil

Referenced Subflow – Modularize your workflows

Overview

SAP Business Technology Platform Workflow Management has workflow capability, enable customers to automate processes. Complex workflow applications require modularization of workflows to enable reuse and better maintenance. Referenced Subflow simplify workflow models and make it more intuitive to both developers and process owners.

SAP Business Technology Platform Workflow management has released Referenced Subflow feature. You can include a workflow as a referenced subflow from another workflow. The parent workflow waits until the referenced subflow has completed the execution.

Referenced Subflow

A workflow can be consumed as referenced subflow from a parent workflow. In the below screen shot a parent workflow (Investment Approval)  is using the referenced workflow artifact and using a child workflow (Cost Center Owner Approval). The same workflow is also used in Group Head Approval step.

Add Workflow as Referenced Subflow

In the Referenced Subflow properties, add workflow definition Id of the child / referenced workflow.

Enabling principal propagation will use the credentials of a user while invoking the referenced subflow.

Workflow Context Mapping

A referenced subflow requires context mapping to exchange workflow context as input and output.

Input Mapping

Workflow context from the parent workflow is mapped to the child workflow. This is used as the start payload of the child workflow. You can include multiple workflow context elements as input mapping.

Source context path – Parent workflow context path.

Target Context Path – .Workflow context from Referenced Subflow.

In this scenario both parent and child workflow are using the same JSON elements as workflow context. It is possible to have different elements as source and target context path.

Output Mapping

Referenced Subflow or Child workflow context is mapped back to the parent workflow as response.

Source context path – Workflow context from Referenced Subflow.

Target Context Path – Parent workflow context path.

In the above screen shot, decision from approver is mapped to parent workflow. Comments are appended to the existing comments in parent workflow context element.

At the end of the Referenced Subflow execution, workflow context is mapped to the parent. The parent workflow context element is overwritten.

Monitor Workflows

While executing a workflow, parent workflow is starting the Subflow  or child workflow. Workflow monitoring enable you to navigate between parent and child workflow including the root workflow in multi level referenced subflow use case. The “Show Subflow Instances”  action enable navigation from parent workflow instance to all child workflow instances.

 

All child workflow instances have a link to navigate back to immediate parent workflow instance or the root parent workflow instance.

Workflow Management has added a new feature to execute workflows in parallel by using referenced workflow. Please go through my blog Execute workflow tasks in parallel using SAP Workflow Management | SAP Blogs.

It is possible to define boundary events to a referenced subflow. Please go through my blog Boundary events in Referenced Subflow | SAP Blogs

Refer SAP  Workflow Service help for more details.

Assigned Tags

      14 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Vladimír Balko
      Vladimír Balko

      Hello Venugopal Chembrakalathil 

      thank you for the great news. This feature will make design of more complicated workflows much easier.

      How will that be shown in monitoring of instances? Like two separate instances or instance of main wf and somehow inside will be that referenced one?

      Author's profile photo Venugopal Chembrakalathil
      Venugopal Chembrakalathil
      Blog Post Author

      Hi Balko,

      As of now the parent and referenced subflow are displayed as two instances. But we are planning to enhance Monitor Workflow app in Q1. You can search using  business key and see all instances together.

      Author's profile photo Mike Doyle
      Mike Doyle

      Thanks for sharing, this is a much needed feature

      Author's profile photo Kajal .
      Kajal .

      Hey @Venugopal Chembrakalathil

      Could you please help me on how to place these two workflows? Do all the parent and child workflows need to be in the same folder?

       

      Author's profile photo Venugopal Chembrakalathil
      Venugopal Chembrakalathil
      Blog Post Author

      Hi Kajal,

      The workflows need not be in the same folder or same project. The parent is referring the workflow definition ID. Please make sure you have deployed the parent and the child workflows.

       

      Author's profile photo Keerthana Jayathran
      Keerthana Jayathran

      Hi Venugopal Chembrakalathil,

      I have created a workflow in another workspace and I want to use it in my parent workflow.But when I deploy it it's showing referenced subflow definition ID not found.

      Author's profile photo Venugopal Chembrakalathil
      Venugopal Chembrakalathil
      Blog Post Author

      Please make sure you have assigned the Workflow Definition ID of the child workflow in the parent workflow. I assume you got an error during runtime.

      Author's profile photo Keerthana Jayathran
      Keerthana Jayathran

      Thank you for your response sir.l did wrong while mapping. I have another doubt too ,when we do data mapping what if we are passing more data in parent than child ,what will we give in target context path.

      Thank you

      Author's profile photo Venugopal Chembrakalathil
      Venugopal Chembrakalathil
      Blog Post Author

      The mapping uses a source and target node. All attributes or child nodes under source node is mapped to the target node.

      Author's profile photo Rohit Vashishtha
      Rohit Vashishtha

      Thank you for the wonderful blog.

      I have a query regarding the sub-flows.

      I have a parent workflow in which I have called another workflow (child).

      The definitions of both the workflows are present in the Monitor Workflows > Workflow Definitions and I am able to run the child workflow independently too.

      But, during the execution of my parent workflow I am getting an error saying that the 'Referenced subflow definition with ID <> not found'. I have re-checked the definition Id multiple times and its correctly mentioned in the parent workflow. The mappings are also fine.

      Is there any other configuration that I need to perform to rectify this issue?

      Please help me.

      Thanks,

      RV

       

      Author's profile photo Venugopal Chembrakalathil
      Venugopal Chembrakalathil
      Blog Post Author

      Hi Rohit,

      You dont need to perform any additional configuration. Please compare the workflow definition Id of the child workflow and  is correctly added in the parent workflow.

      if you are facing this issue to an already existing workflow instance, please create a new one and check. Workflow definitions are versioned and the instance showing error might be referring to an older version.

      thanks.

      Venugopal

      Author's profile photo Rakesh Singh
      Rakesh Singh

      Hi Venugopal Chembrakalathil,

      I have created a workflow and a sub workflow .In my case there are two item at run time( having different approvers for each item ).I follow your document parallel under Loop Configuration and is working fine and sending two task .

      But in sub workflow, I could not able to configure approver of each line item . Request you for your kind help .Thanks

      My approvers are in json file at the time of instantiating the main workflow .

      "SupData": {
      "SeconApprover1": "rak19@gmail.com",
      "SeconApprover2": "rak20@gmail.com"

      ++++++++++++++++++++++++++++

      {
      "buyerData": {
      "firstName": "Harsh",
      "lastName": "Patel",
      "Requester_mail_id": "rak19@gmail.com",
      "first_approver": "rak19@gmail.com",
      "address": "Gujarat" },
      "SupData": {
      "SeconApprover1": "rak19@gmail.com",
      "SeconApprover2": "rak20@gmail.com"
      }

       

      }

       

       

      Author's profile photo Sebastiano Marchesini
      Sebastiano Marchesini

      Hello Venugopal Chembrakalathil  ,

      I have created a subflow to avoid repeating the same multiple steps, but I would like to pass all the context to the subflow instead of field by field, as the context could be dynamic.

      Is there a best practice for doing this? Alternatively, my idea is to create a service script beforehand and assign "${context.temp} = ${context}" inside the workflow, inside of the subflow I will do "${context} = ${context.temp}" and when I exit the subflow, I would doing the invers.

      What do you think?

      Best regards,

       

      Author's profile photo Sebastiano Marchesini
      Sebastiano Marchesini

      It's not possibile to modify the context.
      My alternative idea is not working.
      I just pass all the attribute one by one