This fifth part in the series “How to write dynamic BPC Script Logic” has relatively few earth shattering jolts but the tension is building up below the surface as we continue our journey to uncharted territory.
XDIM_MEMBERSET with keyword BAS and more
In general, help documentation is fairly accurate when it comes to XDIM_MEMBERSET. However, there are more valid use cases than the help documentation describes. Below you can find some examples most of which are properly documented.
Scope selection can contain multiple members.
*XDIM_MEMBERSET P_ACCT = PL5111, PL5112, PL2111
XDIM_MEMBERSET can be combined with BAS to set the scope to base members of a hierarchy node.
*XDIM_MEMBERSET P_ACCT = BAS(PL5000)
Keyword BAS can digest multiple members to set the scope to base members of several hierarchy nodes.
*XDIM_MEMBERSET P_ACCT = BAS(PL5100, PL5200)
Keyword DEP can be used to select direct children of a hierarchy node.
*XDIM_MEMBERSET P_ACCT = DEP(PL5110)
Keyword ALL can be used to select all children of a hierarchy node.
*XDIM_MEMBERSET P_ACCT = ALL(PL5100)
Not equal to sign can be used to exclude a member.
*XDIM_MEMBERSET P_ACCT <> PL5111
Not equal to sign can be combined with BAS to exclude base members of a hierarchy node.
*XDIM_MEMBERSET P_ACCT <> BAS(PL5300)
The help documentation specifies that you cannot combine bas() with any other member set. This does not seem to be true as the following statement works.
*XDIM_MEMBERSET ACCOUNT = BAS(PL3000), PL5111
It is worth pointing out that any duplicate base members resulting from BAS will be automatically removed. The following statement exemplifies how this works. Let’s assume that PL3100 is a child of PL3000. In this case, retrieving base members of both PL3100 and PL3000 would result in overlapping sets. However, the system only lists a single occurrence of each account if you use a script like the one below.
*XDIM_MEMBERSET ACCOUNT = BAS(PL3000, PL3100)
There is one more thing I want to mention as it is not specified in the documentation. Keyword BAS also accepts base level members in addition to calculated members. The example below will return base level members belonging to the hierarchy node PL3000 plus the base level member PL5111.
*XDIM_MEMBERSET ACCOUNT = BAS(PL3000, PL5111)
In the above examples, you may also use variables instead of fixed member values and I recommend you do. Let’s see how we can use the SELECT statement to pick up base members of a given hierarchy node. This is not possible directly, but you can combine SELECT variables with XDIM_MEMBERSET, XDIM_ADDMEMBERSET, XDIM_FILTER and WHEN. The example below gives an idea how to use BAS with a SELECT variable. Here we set the scope for base members under the calculated member PL3000.
*SELECT(%ACCOUNTSRC%, ID, ACCOUNT, ID = PL3000)
*XDIM_MEMBERSET ACCOUNT = BAS(%ACCOUNTSRC%)
Update 2015-12-13: It is possible to select all base members of a given hierarchy node after all. Instead of SELECT we can resort to our good old friend XDIM_MEMBERSET. The following statement will do the job.
*XDIM_MEMBERSET ACCOUNT as %ACCOUNTSRC% = BAS(PL3000)
This is really great because we can pass this variable to standard programs such as *RUNALLOCATION or *RUN_PROGRAM CURR_CONVERSION.
In the sixth and final part of this series, we will see that the keyword IS has similar dynamic capabilities and then some. I will also show more examples of variable usage. Some of the things I am about to reveal are Wikileaks magnitude so stay tuned.