You are on page 1of 17

http://learnhyperion.wordpress.

com

Hyperion 11.1.1.3 Rules


Student Guide - III

Provided By: BISP Created By: Rupam Majumdar


http://bispsolutions.wordpress.com SME - Hyperion
bisp.consulting@gmail.com Reviewed By: Amit Sharma
http://learnhyperion.wordpress.com BISP Team

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 1


http://learnhyperion.wordpress.com

Arrays
Arrays are variables that hold multiple values.
Each array value has an index number.
You write values, to or read values from, the array by referencing the
index number.

You can create these types of variables:


Standard variables, also called scalar variables, store a single value.
Array variables store a list of values.

Loops
Loops can reduce the size of your script. For example, instead of creating 20
lines of script to calculate 20 account values, you can create a loop that
repeats a single line of script 20 times, specifying a different account for each
iteration. Loops are sections of code that repeat execution for a specified
number of times or until a condition is met.

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 2


http://learnhyperion.wordpress.com

Arrays and Loops in Rules

We have learned that the HS.Exp function can write data to either a single
member of a subcube dimension or to all valid members of the dimension:
If we specify a dimension member on the destination (left) side of
HS.Exp, it writes data only to that member of the dimension.
If we omit the dimension from the destination (left) and source (right)
sides of HS.Exp or include it only on the source (right) side, it writes to
all valid members of the dimension.
But frequently you need a rule to act on a subset of dimension members. For
example, we might need a rule that writes values to all accounts that are
descendants of the Total Expenses account, but to no others. If there were 50
descendants of Total Expenses, you would need 50 HS.Exp statements.

Similarly, we must frequently limit the members of the Entity, Scenario, Year,
or Period dimension for which a rule executes. Using an If...Then or
Select...Case statement is convenient if there are a small number of members,
but it becomes problematic with many members. For example, we might need
a rule that executes only for entities that have Eur as their default currency. If
there were 25 entities with Eur as their default currency, you would need an
If...Then statement or a Select...Case statement with 25 conditions, which
would be difficult to write and maintain.

We can use loops and arrays to work with large subsets of members. We first
load the members into an array. We then use a loop to repeat the execution of
a rule for each member in the array.
 Frequently you need to write rules that execute for a subset of members
in a dimension.

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 3


http://learnhyperion.wordpress.com

In the example on the slide, the Overhead members of the Custom2 dimension
are stored in an array variable named aOver. A loop is used to perform a
calculation for each member in the array.

Creating Array Variables


You create array variables the same way that you create standard variables,
except you specify the number of items for the array in parentheses next to
the variable name. Array variables use a zero-based index; that is, the index
number for the first item is zero. As a result, array variables contain one more
item than the number specified in
parentheses. For the example on the slide, the aProducts variable would
contain items 0 to 5. You assign data to each element of the array by using an
index into the array. Similarly, the data can be retrieved from any element by
using an index into a particular array element.
This example sets the value of the ninth item in the aEntity array variable to
Europe:

aEntity(8)=Europe
This example retrieves the tenth item from aEntity and stores it in the
vCurrEntity variable:
vCurrEntity=aEntity(9)

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 4


http://learnhyperion.wordpress.com

Creating an array variable is similar to creating a scalar variable, but you


include parentheses with the number of items for the array.

Filling Arrays Using Member ListsYou can use the HS.List function to fill an
array variable with the members from a member list.

Syntax
HS.Dimension.List("Parent","Listname")

Parameter Description
Dimension A Dimension name
Parent Optional. The name of the top parent member for a system-defined
list.
Listname The name of a valid system list or a user-defined member list

Examples of HS.List:

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 5


http://learnhyperion.wordpress.com

Creating Loops
You can create several types of loops in VBScript.

For...Next
Repeats the execution of a block of statements a specific number of times. For
loops use a counter variable whose value is automatically increased or
decreased with each repetition of the loop. You specify the initial value for the
counter variable and the maximum value the counter can reach for the block
of code to be executed.

Syntax
For Counter = StartVal To EndVal
...
...
Next

Creating Loops
You can use these statements to create loops:
For...Next: Using a counter to run statements a specified number of
times.
For Each...Next: Repeating a group of statements for each object in a
collection.
Do...Loop: Looping while or until a condition is true.

Parameter Description
Counter A name for the counter variable
StartVal The initial value for counter variable.

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 6


http://learnhyperion.wordpress.com

EndVal The maximum value for counter variable.


Example
The following loop makes the computer beep 21 times. The For statement
specifies the counter variable name as x. It specifies 0 as the start value for x
and 21 as the end value.
The next statement increments the counter variable by 1 after each iteration.

For Each...Next
Repeats a block of statements for each element in an array. All statements
execute for each element in the array until there are no more elements. You
specify a variable that returns the index for the current element in the array.

Syntax
For Each Item in ArrayVariable
...
...
Next

Parameter
Item
A variable name for the counter variable.
ArrayVariable
The name of an array variable

Example
In the following script, Item is the counter variable and BeepCount is an array
variable.The computer beeps for as many items as there are in the BeepCount
array variable.

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 7


http://learnhyperion.wordpress.com

Do...Loop
Runs a block of statements an indefinite number of times. The statements are
repeated either while a condition is true or until a condition becomes true.
Repeating Statements While a Condition is True
You use the While keyword with a Do loop to run a block of statements while
a condition is true.
Syntax
Do While Condition
...
...
Loop
Parameters
Condition
An expression that evaluates to true or false

Example
In the following script, the statements inside the loop run while the value of
myNum is 10 or less.

Repeating Statements Until a Condition Becomes True


You use the Until keyword with a Do loop to run a block of statements until a
condition becomes true.

Syntax
Do Until Condition
...
...
Loop

Parameters
Condition
An expression that evaluates to true or false

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 8


http://learnhyperion.wordpress.com

Example
In the following script, the statements inside the loop execute until the value
of myNum reaches 11.

Assigning Values with Arrays and Loops


You can use arrays and loops to assign values to accounts in Financial
Management.
To assign values with arrays and loops:
1. Assign a system or user-defined member list to an array variable by using
the HS.Listfunction.
2. Create a loop that executes for each element in the array variable.
3. Use the loop counter variable to specify the index for the array variable.
Because the loop counter variable is incremented by one each time the loop
executes, each iteration of the loop retrieves a different member from the
array variable. You can insert the array variable in any location in your script
where an array member name is required.

With For...Next loops, you must specify a start number and an end number for
the counter variable. But often you do not know the number of items in the
array. You can use the Lbound function to retrieve the index number of the
first item in the array and the Ubound function to retrieve the index number
of the last item.
For Each...Next loops automatically repeat for each member in the array, so
the Lbound and Ubound functions are not needed.

The counter variable increments the index number of the array variable
to retrieve a different member from the array at each iteration of the
loop.
Use the Lbound and Ubound functions to retrieve the number of items
in the array.

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 9


http://learnhyperion.wordpress.com

Attributes in Loops

There may not be a system or user-defined member list that defines the
precise subset of members that you need to include in a loop. You can use
member attributes as additional criteria for selecting members for which
rules are executed

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 10


http://learnhyperion.wordpress.com

Retrieving and Writing Data

So far, you have used the Exp function to read and write account values.
Financial Management rules provide other functions for reading and writing
data to data intersections.

The Exp function retrieves data from a source account or accounts and writes
it to a destination account or accounts. However, sometimes you need to store
data to a variable instead of an account. For example, you might want to
retrieve the value for TotalHeadcount and store it in a variable, which you
then use for a series of calculations. The GetCell function enables you to
retrieve data from a specified data intersection or cell and store it in a
variable.

GetCell function: Retrieves data from a single data intersection or cell;


stores the data in a variable to use in a calculation or to assign to an
account.

SetDataWithPOV function: Writes data to a single data intersection or


cell; accumulates or replaces data.

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 11


http://learnhyperion.wordpress.com

GetCell Function

Retrieves data from a specified data intersection or cell and stores it in a


variable.

Syntax
HS.GetCell("POVExpression")

Parameter

POVExpression
A valid Point of View. You can include any dimension in the POV expression. If
you omit the Entity, Scenario, Year, or Period dimensions, the current Point of
View is used.

SetDataWithPOV Function
You may need to add to the existing values for an account rather than
overwrite them.
You can use the SetDataWithPOV option to write data to a specified data
intersection or cell. You can choose to overwrite the data for the cell or add to
the existing data. Writes data to a specified data intersection or cell.

Syntax
HS.SetDataWithPOV(POV,Data,Add)

Parameter
Parameter Description
POV A valid expression. You must include members for the
Account, custom, and ICP dimensions. No other dimensions
are valid.
Data The data value to set.
Add True to accumulate the data or False to replace the data.

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 12


http://learnhyperion.wordpress.com

Testing for No Data

If the source for HS.Exp is an account expression, HS.Exp detects if there is


no data and does not write to the destination.
If the source for HS.Exp is a constant, HS.Exp cannot detect if there is no
data and can potentially write zeros to the database.
You can use a conditional to test for no data or for zeros.

Use the GetCellNoData or GetCellRealData function to test for no data.

Syntax
HS.GetCell("POVExpression,Var")
Parameter
POVExpression
A valid Point of View. You can include any dimension in the POV expression.
Var
A variable that returns True if there is no data and False if there is real data
or derived data.

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 13


http://learnhyperion.wordpress.com

GetCellRealData Function
Gets the data contained in a cell and indicates if the cell contains real data.

Syntax
HS.GetCellRealData("POVExpression,Var")

Parameters
POVExpression
A valid Point of View. You can include any dimension in the POV expression.
Var
A variable that returns True if there is real data and False if there is no data or
derived data.

Example

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 14


http://learnhyperion.wordpress.com

Setting Accounts to No Input


Sub NoInput procedure:
Can be used for accounts where some data intersections must be
calculated and others must be input.
Does not recognize the current Point of View.
Allows use of loops and member lists.

Setting Parent Entities to Input


Sub Input procedure:
You can use it to enable data entry for parent entities.
Children contributions do not roll up to the parent's Entity Currency
member in the Value dimension.

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 15


http://learnhyperion.wordpress.com

Preventing Prior and Next from Crossing into Invalid Years


Rules can reference members in earlier and later periods.

The Prior and Next keywords can cross years but cannot distinguish
between interim years and first and last year.

In rules, you use the First, Last, Prior, and Next keywords to dynamically
select earlier and later periods and years. Year and Period are separate
dimensions. However, if the current period is the first period in a year, the
Prior function, used with the Period dimension, crosses to the last member of
the previous year. For example, if the current period is January, 1996, the
syntax P#Prior retrieves the value for December, 1995. Similarly, if the
current period is the last period in a year, the P#Next crosses to the next year.
The Prior and Next keywords, however, do not distinguish between interim
years and first and last years. Therefore, if a rule tries to retrieve data from a
year prior to the first year or after the last year, an error is returned. For
example, if the current year is the first year, the syntax Y#Prior returns an
error. Similarly, if the current year is the first year and the current period is
the first period, the syntax P#Prior returns an error.

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 16


http://learnhyperion.wordpress.com

BISP || HYPERION 11.1.1.3 Rules || Creator : Rupam Majumdar Page 17

You might also like