Oracle EPM - Gettin' Groovy with Member Selection
Felt inspired today to write a short post on one of my favorite methods to use in Groovy, the getEvaluatedMembers() method. Here's what Oracle has to say on the topic, per the Java Docs:
At first glance, this function may seen useless.... why bother using Groovy to evaluate your member sets if you can just do that in the BSO Calc Script itself through FIX statements? Well, this function becomes very helpful if you logic that needs to calculate dependent downstream members based off the one that actually modified, or if you want to do complex member operations outside the BSO script first so that the rule execution is clean. Lets look at what we need first...
To use this method, we need to have the cube and dimension defined. We do that like this:
One neat Groovy trick is to use "slashy quotes". Placing your string between / / characters in Groovy allows for you to use standard double-quotes in the strings themselves without worrying about escape characters. This is important if your member names have special characters/spaces and need to be wrapped in double quotes.
Once you have your connection set up, you can use the getEvaluatedMembers() method however you need it! The "member set expression" can be really anything... you can build out a standard BSO calc script member set, something like this:
Or, more interestingly, you can also use the Planning operators like you would in building a Form!
领英推è
And yes, as you can see above, subvars work perfectly in this method! And, you can use the [[PlanningFunctions]] operations in here as well!
One important thing to note is that the getEvaluatedMembers() method returns the members as a Java List (hence the square brackets printed in the log). This could be a good or bad thing depending on how you want to use the members. If you are going to do other Groovy operations on them, having them as a list is very helpful for iterating through them. However, if you want to just have it ready to go to put into a Calc Script, then you can wrap the method call in the cscParams() function, which will do all the formatting for you!
So, what are some use cases for this? Well, I have a few!
- Its a little more succinct for getting subvar values than doing the normal operation.application.getSubstitutionVariableValue().toString() approach for getting the value of a subvar (assuming that subvar is a member, of course).
- If you have a requirement where another member needs to be calculated downstream of what the user selected or modified, and that member can be determined through some member relationship, you can use this function to evaluate it. For example, we have a process can modify an operating location but we need to calculate the admin location, which is flagged with an attribute. We can use member sets to find the admin location based on the operating locations that were modified (see my post about the @INTERSECT function from before!)
- Building out dynamic member lists at runtime for Smart Pushes, Data Maps, or other systematic processes.
Anyways, just wanted to share some basic knowledge about one of my favorite, if simplistic, methods :)