Skip to Content
Author's profile photo Siddhant Bhatankar

Creating a Simple BRM Ruleset in 30 Easy Steps using NWDS 7.3 (Flow Ruleset with a Decision Table)

Hello Everyone,

This document illustrates how to create a simple BRM (Flow) Ruleset using NWDS 7.3 in 30 easy steps, consisting of static values and conditions in a Decision Table and exposing the Rulseset as a reusable Web-Service.

For now, we will create a local project.

For practice purpose, we will create a BRM which will decide an Approver for an Employee for a specified Cost of Trip he/she has made.

Please follow these steps and refer to the screenshots:

1. Create DC:

/wp-content/uploads/2013/10/1_289786.jpg

2. Select DC Type (Rules Composer):

/wp-content/uploads/2013/10/1_289786.jpg

3.  Name your DC and Click on ‘Finish’:

/wp-content/uploads/2013/10/1_289786.jpg

Your Created DC should look like this in your Workspace:

/wp-content/uploads/2013/10/1_289786.jpg

4.  Creating a New Flow Ruleset (Right click on ‘Rules Modelling’):

/wp-content/uploads/2013/10/1_289786.jpg

Name your Ruleset:

/wp-content/uploads/2013/10/1_289786.jpg

The created Ruleset will appear in the Project:

/wp-content/uploads/2013/10/1_289786.jpg

5.  Now, we will have to create custom XSD elements that can be used in the BRM rule. Right click on the ‘wsdl’ folder within ‘src’ in the project:

/wp-content/uploads/2013/10/1_289786.jpg

6. Name the New XML Schema and click on ‘Finish’:

/wp-content/uploads/2013/10/1_289786.jpg

The blank XML Schema should look like this:

/wp-content/uploads/2013/10/1_289786.jpg

7. Now, we will create 2 Simple types (elements) in the XML Schema Definition which will be used going ahead. Right-click in the ‘Types’ area and select the data type. Here, we will create 2 Data elements, one for the trip cost and one for the corresponding approver:

/wp-content/uploads/2013/10/1_289786.jpg

8.  So, the created Schema should look like this:

/wp-content/uploads/2013/10/1_289786.jpg

9.  Now, to use this created schema in the project, we need to add it in the project resources. Open the properties of the project resources of the project to add the custom datatypes(XSD) elements:

/wp-content/uploads/2013/10/1_289786.jpg

10.  Click on the ‘aliases’ tab and select ‘add’ as highlighted:

/wp-content/uploads/2013/10/1_289786.jpg  

/wp-content/uploads/2013/10/1_289786.jpg

11.  Select the created XSD elements:

/wp-content/uploads/2013/10/1_289786.jpg

The added aliases should look like this:

/wp-content/uploads/2013/10/1_289786.jpg

Now, the XSD elements are ready to use.

12. Create a new Decision Table and Name it:

/wp-content/uploads/2013/10/1_289786.jpg

/wp-content/uploads/2013/10/1_289786.jpg

13. Select the conditions to add as shown:

/wp-content/uploads/2013/10/1_289786.jpg

14.  Add the elements by clicking the downward arrow and check ’Table has horizontal condition’:

/wp-content/uploads/2013/10/1_289786.jpg

15.  Select the Action as shown:

/wp-content/uploads/2013/10/1_289786.jpg

/wp-content/uploads/2013/10/1_289786.jpg

The created decision table will look like this:

/wp-content/uploads/2013/10/1_289786.jpg

16.  To edit values in the conditions, double click on the existing value and enter the new value:

/wp-content/uploads/2013/10/1_289786.jpg

17.  To add values in the conditions:

/wp-content/uploads/2013/10/1_289786.jpg

18. Enter the desired value in the dialog box and click on OK:

/wp-content/uploads/2013/10/1_289786.jpg

Now the table will look like this:

/wp-content/uploads/2013/10/1_289786.jpg

19.  Similarly, you can edit the values in the action entries by double-clicking on the existing values. After making all the entries to the table, it should look like this:

/wp-content/uploads/2013/10/1_289786.jpg

Your decision table is ready.

20.  Now, we have to make a Flow for the created ruleset:

/wp-content/uploads/2013/10/1_289786.jpg

Name the Flow:

/wp-content/uploads/2013/10/1_289786.jpg

21. The created flow will look like this:

/wp-content/uploads/2013/10/1_289786.jpg

22.  Now, as we want the input to flow through our created decision table, we will have to add the decision table in this flow:

Drag and drop the decision table activity from the palette onto the flow editor and connect the flow:

/wp-content/uploads/2013/10/1_289786.jpg

/wp-content/uploads/2013/10/1_289786.jpg

23.  Now, we have to assign the created decision table to the decision table activity in the flow:

/wp-content/uploads/2013/10/1_289786.jpg

24.  Select ‘Browse’ from the ‘Decision table’ dropdown:

/wp-content/uploads/2013/10/1_289786.jpg

/wp-content/uploads/2013/10/1_289786.jpg

Now the flow should look like this:

/wp-content/uploads/2013/10/1_289786.jpg

This step completes the creation of the BRM Ruleset.

25.  Further, we need to expose this BRM as a web-service so that it can be used across applications.

To do this, follow the following steps:

/wp-content/uploads/2013/10/1_289786.jpg

26.  Name the Web Service:

/wp-content/uploads/2013/10/1_289786.jpg

27.  The details in step 26 are going to be the details of the web service. Please keep a note of this.

28.  The Web service will be:

http://<servername>:<portnumber>/TripApproverRuleset/TripApproverRulesetPort?wsdl

29.  Check the options as shown below in the following dialog box:

/wp-content/uploads/2013/10/1_289786.jpg

30.  The XML structure of the web service will follow in the next dialog box:

/wp-content/uploads/2013/10/1_289786.jpg

Click on finish. The BRM web service is now created.

Your BRM is now ready to use.

This BRM web service can be used as any other web service which can provide certain outputs for decision-making purposes. Most commonly used as integrated in BPM Business Processes.

Hope this document helps. Please provide inputs if I have missed out on anything.

Regards,

Siddhant

Assigned Tags

      23 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      I will try this for sure...:)

      Author's profile photo Shreyas Pandya
      Shreyas Pandya

      Perfect example of a detailed and explanatory blog.

      Good job Siddhant.

      Regards,

      Shreyas Pandya

      Author's profile photo Siddhant Bhatankar
      Siddhant Bhatankar
      Blog Post Author

      Thanks Shreyas.

      Author's profile photo Former Member
      Former Member

      Very usefull.

      Good Job Siddhant.

      Author's profile photo Biju M
      Biju M

      Nice Blog. I have a query :

      Can decision table be exposed as a web service ? I have a requirement where business users want to edit the decision table.

      Author's profile photo Siddhant Bhatankar
      Siddhant Bhatankar
      Blog Post Author

      Hi,

      The decision table cannot be exposed as a web-service. The ruleset is exposed as a web-service, through which the access passes to the rule flow. When the flow executes, the decision table is checked.

      For your requirement as stated above, please refer to this doc I authored: http://scn.sap.com/docs/DOC-51351

      Hope it helps. Cheers. šŸ™‚

      Author's profile photo Arun Soni
      Arun Soni

      Very useful information.

      For the query  - "The Decision Table to be exposed as a web service".

      It is necessary to understand that it is not the Decision Table which is the direct point of execution, it is always the Ruleset which gets executed through a Rules Composer DC when called via a Rule Engine API giving a JNDI reference.


      For Editing the Decision Table, one can directly log in to server with the following link -


      http://<hostname>:<portNo>/rulesmanager


      The user can then access and edit the entries in the decision table directly or can also export and import an excel file with the same template which should then be saved and activated.

      Now you have the updated data in Decision Table which can be used for business processing.


      Note : User has to have BRMS Access Roles in order to edit any Decision Table.



      Thanks,

      Arun

      Author's profile photo Former Member
      Former Member

      Hi Siddhant,

      Thanks for the blog. We followed the same steps as in the blog and created a BRM webservice.

      But there is one issue, need your advice :

      After creating the webservice, when we test it in the WSNavigator -  we are able to view the output elements also in the Request and its aksing us to enter the input for the output elements.

      For Ex: Input is Name and Age

      Output is Designation (which comes from decision table based on Name and Age)

      We created 3 elements - Name,Age,Designation

      But while trying to execute the webservice in WSNavigator - it asks us to enter the input for Designation too.

      Is there a workaround or different approach that needs to be followed to have different structures in Request and Response ?

      Regards,

      Arpitha

      Author's profile photo Siddhant Bhatankar
      Siddhant Bhatankar
      Blog Post Author

      Yes it does display the output parameters while testing the WS in Navigator. But they are not mandatory. Just leave them blank.
      As for the workaround for different structures for input and output parameters, when you are creating the Web-service for the Ruleset, the wizard asks you to define the input and output parameters. You can select your structures there.

      Author's profile photo Former Member
      Former Member

      But if we uncheck the output parameters from the wizard, it doesnot reflect even in the output box.

      This BRM is used for maintaining visibility and mandatory values for UI, there are around 300+ output fields.

      Also, when we are consuming this BRM webservice in Webdynpro Java - we might have to initialise the output elements before executing the webservice.

      Please correct me if I am wrong.

      Author's profile photo Siddhant Bhatankar
      Siddhant Bhatankar
      Blog Post Author

      If that is the case, may be you can leave it that way. Keep the cardinality of the parameters as 0..1 in the XSD.

      When you are consuming the BRM WS in WDJ, I don't think you will necessarily need to initialize the output parameters as well.

      Author's profile photo Former Member
      Former Member

      Thanks Siddhant. I am trying the option of maintaining cardinality of the parameters as 0..1.

      I will consume this changed WSDL in WDJ and update.

      Author's profile photo Former Member
      Former Member

      Hi Siddhant,

      I followed your blog and created a BRM ruleset for picking up the approver name based on an Order number.I generated the wsdl for the ruleset and imported the same in an automatic activity in a BPM.

      When trying to execute the BPM,it stops at the automated activity step.The BRM is not getting called from the BPM.When I imported the wsdl in soap ui and tried testing the same,it does not give the output there as well.

      Are there any conditions to be written in the rule for the decision table to be executed.Currently I am using this :

       

      If

      Boolean.TRUE

      Equals Boolean.TRUE

       

      +

      Then 

      Evaluate-DecisionTable:: POApprover

      Please could you let me know if I am missing something here and if there are possibilities to debug the BPM in a better way.

      Thanks and Regards,

      Induja

      Author's profile photo Siddhant Bhatankar
      Siddhant Bhatankar
      Blog Post Author

      In the input mapping of the automated activity where you are calling the BRM, just put some definite value for all the input parameters (in your case, the order number is input and approver id is output). So, in the input mapping, put some value (like "-") for approver id too. Do not keep it null.

      Author's profile photo Former Member
      Former Member

      Hi Siddhant,

      I have entered a constant value in the expression editor for the particular field,I could not find any specific function for maintaining constants.Please correct me if I am wrong.

      Also,I noticed that there are connectivity issues with the Service registry.I took the wsdl file generated from the BRM,saved it in local and then uploaded the same wsdl in the BPM.Could this be the reason for error in the BPM.Kindly share your thoughts on this.

      Thanks and Regards,

      Induja

      Author's profile photo Siddhant Bhatankar
      Siddhant Bhatankar
      Blog Post Author

      There are no functions for maintaining constant values. Simply enter them in " " .

      Also, saving the WSDL file locally is not a problem. It should work. Just note that when you save the WSDL file URL in the browser, the exact URL for the BRM will be only till '?wsdl'. Delete the rest which follows (till WS Policy=....). Open this url in the browser and then save the wsdl file.

      Author's profile photo Former Member
      Former Member

      Hi Siddhant,

      Thanks for your reply.

      I was trying to create the BRM in our sandbox server where it was not getting called at all,probably there is some authorization or configuration issue there.

      However,I tried the same steps and created a BRM in the Client system for a POC and it worked.I used the same BRM in a BPM as well and the basic flow works fine.Thanks for your inputs.

      Thanks and Regards,

      Induja

      Author's profile photo Former Member
      Former Member

      Hi Siddhant

      Nice blog, finally i can finish a BRM test.

      But i have a problem, when i execute the WSDL in WSNavigator or test in a Java application, the input data returns me like a output data... it should be returns me the "ManagerX" text?

      Thanks for your help.

      Author's profile photo Siddhant Bhatankar
      Siddhant Bhatankar
      Blog Post Author

      While testing it in WSNavigator or any Java Application, make sure you enter something in the Output Parameters as well. Do not leave it blank. Put some value like '-'.
      As the default cardinality is 1..1 while executing, it also requires some value in output mapping.

      While testing it in WSNavigator, try putting some value like '-'.

      Author's profile photo Former Member
      Former Member

      Hi Siddhant

      Thanks for respond so quickly.

      That is not my problem, but i could solve, i see that in the Rules Flow i have two flows, one is a defect one name it 'MainFlow' and the second that we create name it 'Trip Approval', so the Decision Table i put in the flow we created as the blog says, but i think that the flow take the main flow as defect, my solution was include the Desicion Table in the MainFlow as equals like in the TripAproval. I Deploy and the WS work whit a little problem... but only for numbers less or equal to 10000... i think that the BETWEEN sentence is not recognized or i am wrong...? 

      Ouu and i'm sorry for my deprecated english...

      Thanks.

      Author's profile photo Siddhant Bhatankar
      Siddhant Bhatankar
      Blog Post Author

      Hi William,

      In the blog, I did not create any separate flow of execution. I renamed the 'MainFlow' to 'TripApproval'. šŸ™‚

      And yes, you are right, by default, the execution is throught the MainFlow. So it is always advisable to work with MainFlow itself.

      Regards,

      Sid

      Author's profile photo Jixin Wang
      Jixin Wang

      ignore the 7th step, and change the xml element type of TripCost from string to int at the 8th step. Otherwise when you test the wsdl, you will see that the output is the same as the input. After changing string to int, you will get right result.

      Author's profile photo Gagandeep Batra
      Gagandeep Batra

      Hi,

      I am facing following error while deploying this scenario, Can you please help me

      Description:
      1. Could not deploy SCA application.
      -> while trying to invoke the method commonj.sdo.Property.getType() of a null object loaded from local variableĀ  's'

      Regards
      Gagan