Building a Rule as an Object
The RuleExpressions subpackage contains several classes. Each of these classes represents the different parts of the analytic calculation engine rule grammar. These objects are created using the Create built-in function and the constructor for that class, then added to the RuleDefn object with the AddRuleExpression method.
The following example creates a cube that uses the Analytic Calculation Engine built-in function AT.
Function AT_Cube
/** AT Cube Rule **/
&Expected = "AT(GENERAL2, [GENERAL2:4], LOOKUPVALUES)";
&CubeName = "AT";
&FunCall = create PT_ANALYTICMODELDEFN:RuleExpressions:FunctionCall⇒
(&Constants.FuncCall_Type_Builtin, &Constants.FuncCall_Builtin_AT);
&Constant = create PT_ANALYTICMODELDEFN:RuleExpressions:Constant⇒
(&Constants.Constant_Type_Literal, "GENERAL2");
&FunCall.AddArgument(&Constant);
&MemberRefArgument = create PT_ANALYTICMODELDEFN:RuleExpressions:⇒
MemberReference("GENERAL2", "4");
&FunCall.AddArgument(&MemberRefArgument);
&CubeArgument = create PT_ANALYTICMODELDEFN:RuleExpressions:Cube("LOOKUPVALUES");
&FunCall.AddArgument(&CubeArgument);
&RuleDefn = create PT_ANALYTICMODELDEFN:RuleDefn("");
&CubeDefn = &Model.GetCube(&CubeName);
&RuleDefn.AddRuleExpression(&FunCall);
&RuleDefn.GenerateRule();
&CubeDefn.SetRule(&RuleDefn);
If ( Not (Exact(&RuleDefn.RuleString, &Expected))) Then
&Model.Save();
Error ("Rule Experession API Failed [Cube " | &CubeName | " Rule]");
End-If;
End-Function;