Skip to Content
Technical Articles
Author's profile photo Archana Shukla

Sequencing Rules Execution by Decision Orchestration in SAP Cloud Platform Business Rules

SAP Cloud Platform Business Rules enables you to define and orchestrate critical decisions and business policies in easy-to-use web-based tool. As the outcome of the business rules is used to implement dynamic decisions at runtime, it becomes important on how the outcome is evaluated. One of the most common use case during rule evaluation is rule chaining – which means consuming the output of the previous rule in next rule evaluation be it expression modelling in conditions or defining actions of the rule.

Decision Orchestration in business rules now supports sequencing of rule to evaluate the final output. Using this feature, you can define the order of execution in the context of making decisions. Decision Orchestration can be achieved in 2 ways: (a) you can use the output of one rule, as input or output to next rule and (b) you can create rule with reusable expression or formula and then call this rule while modelling other rules. This simplifies the rules modelling especially in cases where reusability is the key.

If you have such requirements in your project, then you are at the right place. In this blog I will explain in detail what are different ways of rule orchestration and how to build and use them in SAP Cloud Platform Business Rules.

» Important Note: This feature is supported only for cloud-based rules (which means rules deployed to SAP Cloud Platform) and ABAP-based rules (which mean rules deployed to S/4HANA)

Enabling Orchestration

  • In Ruleset, you will now see a new policy called “Orchestration” and if you add the rules to the ruleset under this policy then the order in which you add the rule will be the order of execution. For example, in below screenshot Additional Discount Rules will be executed first, followed by Discount Rules for Voucher Code and finally Global Promotion Rules
  • You can change the order of the rules through up and down arrows while configuring rules in ruleset




Modelling Orchestration Rules

  • If you are defining rules under Orchestration policy, then you can consume the output data object in evaluation for further rules.

Let me explain you with an example.

Consider the below rule Additional Discount Rule. In this rule, the output of this rule is collected in a data object called Seasonal Discount

Now let us consider another rule Global Promotion Rules, which is added after Additional Discount Rule in the ruleset.


things to note:

  • Output from the previous rule can be used for both condition evaluation and in action expression. For Example: Seasonal Discount in this case


  • As per the known limitation, currently you can only add rulesets with only either aggregation or orchestration policy. You cannot have mixed rulesets assigned to same rule-service. Deployment will fail.


  • There is also a new concept of intermediate variables with decision orchestration. For example: In above scenario, Seasonal Discount is not the final output instead it is used to store the execution results for the previous rules. You may choose to include the Seasonal Discount as final rule output by declaring them as vocabulary of the rule service and if not then you need to declare them as vocabulary of the rulesets.

In simple terms, vocabulary in rule service is available while executing or invoking rules while the vocabulary defined in the rulesets are intermediate and will be used during evaluation of the rules but not needed as input or the output of the rule service.


  • You will notice a new label called Priority in the ruleset. This is useful when you have multiple rulesets of Orchestration policy added to the same rule-service. As the order of execution is important in orchestration scenario, it is therefore important to decide which ruleset to execute first than other rulesets when one rule-service is associated with multiple rulesets.
    • Priority is used to determine the order. You can give any number from 1- 99
    • Lesser the priority – higher is the execution order.
      • For Example: If you have two rulesets. One with priority 50 and other with priority 30. Then ruleset with 30 priority will be executed first.
    • If the two ruleset have same priority then the order is random in each execution.
    • By default the priority is set to 50
    • For Aggregation policy, the priority does not have any relevance.


Understanding Orchestration Execution

  1. The result of the last rule execution prevails and would determine the final output.
    • In the above example, the final output is only Discount data object and not Seasonal Discount. In Orchestration policy, only the output returned from the last rule execution will determine the final output. Results of the previous rules will be treated as intermediate.
    • you can also define rules with different output data objects. Only the data object associated as output with last rule will be returned as the result.


  1. Order of the rule matters the most when you are consuming the output in the rule chaining. Output might differ if you change the execution order. Also, the rule execution might fail if the order is defined wrongly and one or more values used in condition or action expressions are not yet evaluated.


  1. There is no change in the execution API for orchestration rules. What will change is the output. In Aggregation policy, if you are executing two rules then output of both the rules are returned as an array but in Orchestration, only the output of the final rule is returned.


That completes the first part of using decision orchestration capabilities in sequencing rules. You learnt how you can model rulesets with orchestration policy, how to sequence the rule by consuming the output of previous rules in condition and/or action expressions, how to smartly design the rule with intermediate variables and finally how to read the output after execution the rules using APIs.

In the next part, I will show how you can model formula or reusable rules.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Ram Kumar
      Ram Kumar

      Hi Archana,

      Thanks for the great blog, it is working like a charm in SAP Cloud platform.

      But I tried a similar approach to deploy to HANA XSA but getting SQL Compilation error. It is expecting the intermediate data object to be included as Result vocabulary in Rule Service, though I included as Vocabulary in Rule Set.



      Author's profile photo Namrata S
      Namrata S

      Hi Archana Shukla

      How do we do decision orchestration  for two decision tables . In case of rules which have a decision table as input , there are chances that we will have other inputs apart the one derieved from the previous rule . So what would be the input while executing the service




      Author's profile photo Karthikeyan Sathyanarayanamurthy
      Karthikeyan Sathyanarayanamurthy

      Hi Archana Shukla ,

      I am trying to add a 'AND' operation in my IF statement and it is not allowing me to do so. Not sure on how we achieve this or this is not available in Business Rules as of now ?



      Author's profile photo Archana Shukla
      Archana Shukla
      Blog Post Author

      That should be possible. can you add a screenshot to show what exactly you doing.

      Author's profile photo Karthikeyan Sathyanarayanamurthy
      Karthikeyan Sathyanarayanamurthy

      Hi Archana,


      I have figured this out and it did work. But I am actually stuck with one of the operation 'LOOP'. I get an input as part of an Array(Multiple Rows) and I need to give the output as an array based on certain rules for each row. I couldn't find Loop in the Expressions - Is there any other way to achieve this ?




      Author's profile photo R. Markai
      R. Markai



      I'm using Orchestration rules where the output of one rule is used as input for another rule. If the output is just one value , then I can use it as input for the next rule.

      The issue I have now is that the output of the first rule is a list table ( more values) and I want that as input for my next rule, but it doesn’t work.

      The objecttype of the input rule (Vocabulary) is also a table. Any suggestions how I can make this work?


      Author's profile photo Archana Shukla
      Archana Shukla
      Blog Post Author

      It should work, can you let me know exactly what you are trying to do with the table output that you get? If the output is table, then you need to use table functions or aggregation functions to access the values.

      Author's profile photo R. Markai
      R. Markai

      Hi Archana,


      Thanks for you're respons. See  example what i want to achieve.

      Ruleset with 3 rules and policy “Orchestration”


      First Rule:  output is the “casetype (structure)”


      Second rule: input= “Casetype first rule (structure)” and output= PE_V (table)


      Third rule: Input= “PE_V (Table output second rule)”  and output= “PE_1 (Table )”


      Ruleservice . Input: Aansluitype ( structure)  and result: PE1Lijsttabel (Table rule 3)


      I get no results back.





      Author's profile photo Sasi Varnan Sundarakandasamy
      Sasi Varnan Sundarakandasamy


      Table output can be used in subsequent rule in the ruleset. Only select and aggregate functions can be performed on table data objects. If you are looking for using each row of a table dataobject, you can try using FOR EACH function to loop through each record.


      Sasi Varnan