Anda di halaman 1dari 5

I explained basic 3 parts of script logic in the last post. It was Scoping, Calculation and writing.

We will find out more advanced features for scoping In this post. 1. Scope using member property We found how to use *XDIM_MEMBERSET last time. *XDIM_MEMBERSET is for scoping based on the member ID. What if user wants to scope members based on a specific property value? For example, a user wants to filter Account dimension members those are Asset. To achieve this, we need to use ACCTYPE property which has the type value of account. AST is the value for ASSET account. (Note: Value is based on the APSHELL of BPC.) The command is *XDIM_FILTER. The usage is *XDIM_FILTER <DIMENSIONNAME> = [DIMENSIONName].Properties("Property name") = "Property value" So above example can be written as below. *XDIM_FILTER ACCOUNT = *account+.properties(ACCTYPE)=AST Let's say Account dimension has 3 members as below. ID ACCTYPE Extsales INC CASH AST TAXES EXP NETINCOME INC Then about *XDIM_FILTER_ACCOUNT will select CASH member only. Let's assume If you already used multiple *XDIM_MEMBERSET command and below are selected data from the fact tables. *XDIM_MEMBERSET TIME = 2011.JAN *XDIM_MEMBERSET CATEGORY = BUDGET <Result> EXTSALES , 2011.JAN, BUDGET, 9000 CASH , 2011.JAN, BUDGET, 3000 TAXES , 2011.JAN, BUDGET, 800 NETINCOME, 2011.JAN, BUDGET, 1500 Now if you add *XDIM_FILTER against ACCOUNT dimension.

*XDIM_MEMBERSET TIME = 2011.JAN *XDIM_MEMBERSET CATEGORY = BUDGET *XDIM_FILTER ACCOUNT = *account+.properties(ACCTYPE)=AST Only one record will be selected from above result because CASH is the only account member that has 'AST' value of ACCTYPE property. <Result> CASH , 2011.JAN, BUDGET, 3000

2. Scope using member value We just figured out how to scope the source data based on the property. Then someone might ask this question. "Can we scope based on the value? For example, can we select all data that an account value greater than 100? Of course, we can do it. The command is *XDIM_GETMEMBERSET. Unlike other command, it needs *ENDXDIM command to specify data. Here is the grammar of XDIM_GETMEMBERSET and an example.

*XDIM_GETMEMBERSET {dimension} [={member set}] [*APP={application}] //optional [*XDIM_MEMBERSET {dimension} [={member set}] //as many of these as needed [*QUERY_TYPE= 0 | 1 | 2] //optional *CRITERIA {expression} //required *ENDXDIM

*XDIM_GETMEMBERSET P_CC=[P_CC].[H1].[AAPJ].CHILDREN *APP=PLANNING *XDIM_MEMBERSET P_DataSrc=INPUT *CRITERIA [P_ACCT].[H1].[CE0001000]>1000 *ENDXDIM

It will get the data and those are..

a. Children member of AAPJ in the P_CC dimension. AND b. from the PLANNING application AND c. INPUT member of P_Datasrc dimension AND d. CE0001000 member's value of the P_ACCT dimension should be greater than 100000 Let's Assume Fact table has below records. CE0001000, 2011.JAN, ACTUAL, INPUT, KOREA , 2500 CE0002000, 2011.JAN, ACTUAL, INPUT, CHINA , 5000 CE0001000, 2011.JAN, ACTUAL, ADJ , CHINA , 3000 CE0002000, 2011.JAN, ACTUAL, INPUT, JAPAN , 1999 CE0003000, 2011.JAN, ACTUAL, INPUT, JAPAN , 2222 CE0001000, 2011.FEB, BUDGET, ADJ , KOREA , 345 CE0001000, 2011.FEB, BUDGET, INPUT, TURKEY, 1999 CE0003000, 2011.JAN, ACTUAL, INPUT, TURKEY, 1100 CE0001000, 2011.FEB, BUDGET, INPUT, CHINA , 1050 CE0001000, 2011.FEB, BUDGET, INPUT, JAPAN , 450 Which records will be selected? The answer is CE0001000, 2011.JAN, ACTUAL, INPUT, KOREA, 2500 CE0001000, 2011.FEB, BUDGET, INPUT, CHINA, 1050 Below records will not be selected even though P_ACCT is CE0001000 because its value is less than 1000 or Datasrc is not INPUT or it is not the child member of AAPJ (Asia Pacific) CE0001000, 2011.JAN, ACTUAL, ADJ , CHINA , 3000 (datasrc is not input) CE0001000, 2011.FEB, BUDGET, ADJ , KOREA , 345 (datasrc is not input) CE0001000, 2011.FEB, BUDGET, INPUT, TURKEY, 1999 (Turkey is not child member of AAPJ) CE0001000, 2011.FEB, BUDGET, INPUT, JAPAN , 450 (Value is less than 1000) Here are some important Notes for using this command. Note 1: This command works only for BPC MS. Note 2: if you don't specify each dimension's scope, it will be performed in the corresponding members of the pre-selected region which is defined with DIMMEMBERSET of previous line or Passed by Data Manager. Note 3: This command will generate MDX statement so it takes more time to execute. if your dataset has only base members, you can use *XDIM_GETINPUTSET. (please refer help file)

3. When user wants to add more members on top of current scoped data. Let's say a user wants to add USASales entity on top of predefined memberset. In that case user defines as below. *XDIM_ADDMEMBERSET Entity = USASales The main reason why we need this is a. Sometimes XDIMMEMBERSET doesn't work with some specific functions like BAS(parent). For example, IN BPC NW, *XDIM_MEMBERSET = BAS(US),CANADA will not work. Therefore, we should use *XDIM_MEMBERSET and *XDIM_ADDMEMBERSET. *Note: In BPC MS, BAS() will not work with XDIM_MEMBERSET. b. if user always wants to run a specific memberset whenever logic runs, should use *XDIM_ADDMEMBERSET

4. Dynamic Scope and saving it to a variable. Sometimes we need to save our scoped data into a script logic variable. But... what if your dimension members are updated frequently? As I know, almost every customer updates their dimension at least once a month. If customer changes their dimension members, what will happen in your script logic? You can use *Filter but sometimes it may not work all the time. Then we can use *SELECT and *MEMBERSET command as a dynamic scope tool. Like other script engine, Logic script also supports Variable to save some data. The Variable is defined using % symbol.Here are some examples, %MYTIME% , %CUR% etc. So how can we save some data into the variable and when it can be used? Usually, the variable can be filled using *SELECT command and *MEMBERSET command. Both of them is scope command but *SELECT will be faster because it will create SQL statement. Here is the grammar of both commands. *SELECT ({variable}, {What}, {From}, {Where}) *MEMBERSET({variable}, {member set in MDX format}) Let's see how to use *SELECT command.

*SELECT(%REPORTING_CURRENCIES%, ID, CURRENCY, *GROUP+ = 'REP') This command will get the 'member ID(what)' from the 'currency dimension(From)' that the GROUP property has the value 'REP' (where). Actually, it will create a SQL statement as below SELECT ID from mbrCurrency where [GROUP] = 'REP' After it executes above SQL command, all result will be saved into %REPORTING_CURRENCIES% variable. Here is an example of *MEMBERSET which will make same result but execute MDX statement instead of SQL. *MEMBERSET(%REPORTING_CURRENCIES%, filter,*CURRENCY+.members, *currency+.properties(GROUP)=REP)

The variable can be used anywhere in the logic, like in this example: *XDIM_MEMBER_SET CURRENCY=%REPORTING_CURRENCIES% Let's assume Currency dimension has below members. ID USD EUR KRW JPY GROUP REP REP

Then above statement will be converted as *XDIM_MEMBER_SET CURRENCY = USD,EUR

When you define and fill in data using *SELECT and *MEMBERSET, please remember this as 'MEMBERSET Variable' Note: MEMBERSET command is only supported by MS version.

Anda mungkin juga menyukai