Expense Statement Demo with BRM
In my previous blog Easy process implementation with SAP NetWeaver BPM, I described how easy it was to model and implement a process with SAP NetWeaver BPM which is included in the SAP Composition Environment 7.1 EHP1. At that time I also wanted to use a business rule, created with BRM, within my Expense Demo process. Unfortunately I did not succeed in that. With the help from Arti (SAP Product Management BRM) we found out that this issue was due to the download version I was using.
I used build id: 200809132152, downloaded in October 2008. Now with the current download (January 2009) I have build id: 200811082206. Even the SAP NetWeaver Developer Studio got an update, more on this build ID and how to find out can be found in my forum question: Integration of BRM within BPM does not work.
These updates made my BRM life much easier as I have my demo process now running as expected. Here’s a recap of what I did to implement the rule in my Expense Demo.
I started off with the same process as used in December, the only difference is that a mapping step is added right after the ‘Enter Expense’ step.
In short: the entered expense is validated on amount height. When it is under 25 – automatic approval is applicable. When above, the manager has to approve or reject.
To create a rule, you first have to create a rule set:
At ‘Return type’ you need to state the context that you want to use in the rule set. Good integration realized by SAP: you can reuse the context from the Web Dynpro applications. I reused the same context as I used for the process project, the one from the first step: ‘Enter Expense’.
The ‘Parameter’ arg1 is also based on this same context. And at ‘Result’ you specify the arg1 parameter.
Take care as you can not change this Signature once it has been created. Bit strange though.
The ruleset is finished and now you can create your rule.
When you click on the plus sign under the If statement you get a default condition. Each part can be changed according to your wishes by clicking on it. First it turns yellow and then you get a popup where you can specify the argument.
Here I select the ExpenseAmount field from the context as I want this field to be validated.
Next step is to define what needs to be done when the If statement is applicable. In my demo I want to set the Approved field to True.
Click on the plus under Then and specify the method.
When you’re finished it will look like this:
Back in the process you need to specify that you want to use the rule. This is handled in the mapping step ‘Validate Expense’. Make sure that the mapping line from DO_Context to DO_Context is selected (orange line) and select the Expression editor button. In the popup search for your rule under Rules and Functions. Double click on it and it will appear on the left side of the popup. Make sure that the context is placed between brackets.
For the gates from the gateway the proper conditions need to be specified.
For ‘Auto approval’: DO_Context/Approved=true.
And for ‘Manager approval’: DO_Context/Approved=false.
Now build, deploy and run your process.
Hope you have as much fun as I had in using SAP NetWeaver BPM with BRM. Next step for me is to integrate a real backend system in the scenario and to model the applications with the Visual Composer – but that will be for a next time.
I have created a ‘tutorial’ movie on this, hope it is useful to you, despite the blurriness.