Advanced HFM Rules
HFM rules drive the business flow of an application. FM uses VB scripts for writing rules.
HFM supports some built in functions. FM comes with a rule editor which validates your code and saves it for future use.
In HFM while writing a rules remember all the 12 dimensions represent a view.
In the course of writing a rule we will need to either retrieve data contained in a cell (HS.GetCell) from the database or save a data in the database (HS.Expression).
HS is an acronym of Hyperion Systems.
A rule in HFM is a clubbing of subroutines. These subroutines are designed to meet a specific purpose.
Sub calculate and sub Dynamic are two expected sub routines in a HFM rule. I will be illustrating how it works.
Let’s have a discussion on the basics of writing a HFM rule.
1. Comment lines –an apostrophe in front of the chunk of code that needs to be commented out.
2. The LHS part can only use any member from Account,ICP and custom dimensions and the RHS of any expression can use members from any of the dimensions.
3. We refer to any dimensional member using the below syntax
Dim annotation # Member Name.
HFM defines annotation names for every dimensions
e.g Accounts A, custom dimensions C1-C4,Entity E, Intercompany Partner I,Period P,View W,Scenario S,Year Y and Period P.
E.g HS.Exp “A#NetCapital = A#CurrentAssets – A#CurrentLiabilities”
4. HFM uses period (.) to connect different dimensions for navigating to a data point.
5. Underscore ( _) signals the HFM calc manager that the expression will be continued in the next line.
6. Colon( :) combines two lines in the script.
7. Variants used in HFM rules can have the below data types.
Data Type
|
Description
|
Empty
|
Value is 0 for numeric variables or a zero-length string ("").
|
String
|
A variable-length string that can be up to approximately 2 billion characters in length.
|
Boolean
|
True or False.
|
Byte
|
Integer in the range 0 to 255.
|
Integer
|
Integer in the range -32,768 to 32,767.
|
Currency
|
A value from -922,337,203,685,477.5808 to 922,337,203,685,477.5807.
|
Long
|
An integer in the range -2,147,483,648 to 2,147,483,647.
|
Single
|
A single-precision, floating-point number
|
Double
|
A double-precision, floating-point number
|
Date (Time)
|
A number that represents a date between January 1, 100 to December 31, 9999.
|
Object
|
Contains an object.
|
Error
|
Contains an error number.
|
Null
|
Variant intentionally contains no valid data.
|
Examples to define varians for dimensions
var_Entity = HS.Entity.Member signifies 'current entity
Var_parent = HS.Parent.Member signifies 'parent of current entity
Var_scenario = HS.Scenario.Member signifies 'current scenario
Var_value = HS.Value.Member signifies 'current value
Var_year = HS.Year.Member signifies 'current year
nbrPov_period = HS.Period.Number signifies 'This is the number not the name
is_parent_cur = HS.Value.IsTransCur signifies 'are we at Parent Currency
is_parent_cur_adj = HS.Value.IsTransCurAdj signifies 'are we at Parent Currency Adjust
is_base_ent = HS.Entity.IsBase("", "") 'is this a base level entity
HFM supports default members for every dimensions designated as None(can be customized)
There are two types of variables fin HFM substitution and Execution varables.
The variables which change value depending upon the view point are termed as execution variables.
Note: While writing rules in calc manager keep the variable in braces {}.
The header section of a HFM rule defines Variants and constants which will be used later.The variants declared within a subroutine have local scope.
STRINGS
HFM uses ampersand operator & to concatenate two strings.
Mid,Len,Ucase,Lcase,Left,Right are some of the known String functions.
ARRAY
Syntax: Dim V_array(10)
V_array(0) = “Avik”
V_array(1) = “Sandy”
HFM also supports multidimensional arrays.
There are two types of subroutines in HFM
1. Sub Procedure – May or maynot return a value
2. Function Procedure – Must return a value
If any argument is passed on using call by Ref its value persist even after the control moves out of the Procedure or function but the variant passed using ByVal decays after the control moves out .
Conditional statements control in HFM
If statement executes a set of rules when a condition is met
Syntax:
If x=10 Then
Var= "A#ACC_010"
End If
Select CASE statement in HFM
Example:
Dim Var
Var = Hs.Entity.Member("")
Select Case Var
Case "India"
... Execute statement
Case "AUS"
... Execute statement
Case "Rus"
... Execute statement
End Select
Looping Statements in HFM:
Types of looping statemennts:
· For…Next
· For Each…Next
· Do…Loop
· While…Wend
· Do…Loop
Examples
For x = LBound(Arr) to UBound (Arr)
some rules
Next
For Each var In ArrayList
Codes ...
Next
Do Until x=10
x = x+1
If x<5 Then
Exit Do
End If
Loop
Do
Codes….
Loop Until x=10

No comments:
Post a Comment