This is my first blog in the SDN.
I would like to share my experience in exploring the integration of BRM’s Rules Composer in BPM’s Process Composer with EHP1 Netweaver CE 7.1. After following the example tutorial “SAP Netveaver BPM – End to End Process Implementation Example“, i’d decided to add a simple rule to the example process in the tutorial with rule composer 🙂
1) Completed the above example tutorial.
2) Make sure that the latest BRMS.sca file is deployed to avoid the BRM bug, as explained in details in the blog BRM application deployment issue with SDN CE 7.1.1 Preview Version
The tutorial is about building a process flow that will let a User_A to enter the name and age in a Web Dynpro UI form (as a UWL task in the portal), then the data entered will be sent to the User_B (also as a UWL task in the portal). I will add a simple rule to this process, ie, if the entered age by User_A is greater than 30, then it will return a comment as “old” and then send the task to the User_B, else if it’s below 30, comment as “young” and send the task to User_C, depicted by the following diagram.
Figure 1: Process diagram in the process composer.
By the way, i will not show a “dried” step-by-step guide here. Also, i dont intend to insult those with age over 30 as “old” 🙂 I’m an olddie myself.
There are 2 ways of creating the rule with rule composer, ie, Java Class and XML. In this blog, i will share how to use the Java Class. Next blog, if there is, i will share how to use the XML file.
1) Create our new rule – if the age is more than 30, then set the “Comment” as “old”; if the age is below 30, set the “Comment” as “young”.
a) Create a java bean class NameAge.java with 3 attributes, ie, “Name”, “Age” and “Comment”, with getters and setters. NameAge.java can be placed in the Web Dynpro project “wd_ui_mna” as was created in the example tutorial. Exposed it as public part, as shown below.
Figure 2: Exposed NameAge.java as public part.
b) Create a new Rules Composer DC project and add the NameAge class as an Alias.
Figure 3: NameAge.java as an a Alias.
c) Create a new ruleset called “agerules” and add 2 new rules, one is called “YoungAge” and another is called “HighAge”. Build and deploy the DC.
Figure 4: “YoungAge” rule in “agerules” ruleset.
Figure 5: “HighAge” rule in “agerules” ruleset.
2) Integrate rule into Web dynpro – Web Dynpro UI will invoke the rule engine by passing the entered age by User_A, and based on defined rule, get the comment accordingly.
a) In the “wd_ui_mna” Web Dynpro DC project -> C_FillMyNameAge component, create an additional context attribute “Comment” of type String in the Component Controller and copy it to the Interface controller of the Local Component Interface. Lastly, map the “Comment” attribute to the View Context. This is the same step as what was shown in the example tutorial for “Name” and “Age”.
Figure 6: View context attribute “Comment”.
b) To invoke the above defined rules in rules engine, add the following codes in m_FillMyNameAge method in C_FillMyNameAge’s component controller (C_FillMyNameAge.java).
Figure 7: m_FillMyNameAge method in C_FillMyNameAge.java.
c) Create a new java class EngineInvoker.java as in this tutorial, page 22. But, change the RemoteHome to LocaHome in the getRuleEngine static method.
Note: More information on looking up rule engine can be found here.
Figure 8: getRuleEngine static method in the EngineInvoker.java.
d) Re-create the public part “API” C_FillMyNameAge and C_DisplayMyNameAge component. Build and deploy the “wd_ui_mna” Web Dynpro DC.
3) Create a new role and human activity for the User_C, to receive a UWL task, if the “Age” entered by User_A is more than 30.
a) Re-add the “wd_ui_mna” to the “dc_my_name_age” Process Composer DC Project in the “Required DC”, since the public part “API” has been changed.
Figure 9: Re-add the “API” of the “wd_ui_mna”.
b) Create a new role, human activity and Exclusive choice 0 gateway in the process composer as in the Figure 1.
c) Re-add the process context “DO_Context”. “DO_Context” will now have the additional attribute “Comment”. Re-map the “Output Mapping” of the first human activity “Fill Name Age” to reflect the changes.
Figure 10: Re-map the “Output Mapping” -> “TaskOutput” -> “UIResponse” for “Fill Name Age” activity.
d) Create a new task called “DisplayMyOldNameAge”, which has been assigned to User_C, as below. The step to create a User_C in the UME is described in the example tutorial. The task will have the UI from the “wm_ui_mna” WebDynpro DC (same as for User_B).
Figure 11: Role assigned to User_C.
Figure 12: UI assigned to the “DisplayMyOldNameAge” task.
e) Create a condition for the “Old” connection and set the “Young” connection as default, as following.
Figure 13: “Old” condition must matched the value “old” in the “Comment” of the context attribute.
f) Build and deploy the “cd_my_name_age” Process Composer DC.
4) Test the process flow – go to “Configuration Management” -> “Processes and Tasks” -> “Process Repository” and start the process.
Figure 14: User_A login to portal and enter name and age in a portal UWL task.
Figure 15: User_C login to portal and open the a received portal UWL task.
Did i mention that this is not going to be a “dried” guide? ohh, i was wrong 🙂