Custom-Defined Macro Input Parameters
When creating a macro, you can define how many and what kind of arguments are passed into the macro. Specifying the argument set (also known as the signature) for a macro is optional, but specifying it can make the macro easier to use and prevent usage errors.
The argument set is specified as part of the macro name when you create a macro with the Create Macro MaxL statement. In the following macro name, the argument set is enclosed in parentheses:
@SUMRANGE(single, group)
The macro signature indicates that this macro requires two arguments: single, which represents one input parameter, and group, which represents a list of input parameters. These macro arguments do not represent a specific data type (such as a boolean, double, or string); instead, they only indicate how many arguments are accepted by the macro.
Specify arguments in a comma-delimited list as part of the macro name. Arguments can be specified using the following keywords:
Table 3-35 Keywords Used in Arguments
Argument | Description |
---|---|
SINGLE | A single argument |
GROUP | A list of arguments. Any argument following GROUP is ignored. |
OPTIONAL | A single argument that is not required |
OPTIONAL_GROUP | A list of arguments that is not required. Any argument following OPTIONAL_GROUP is ignored. |
ANY | No checking of arguments. Any argument following ANY is ignored. |
In the macro, the following sets of arguments are valid:
@SUMRANGE(Profit, @CHILDREN(East))
@SUMRANGE(Profit, "New York", "New Jersey", Connecticut)
@SUMRANGE(Sales, @DESCENDANTS(Product))
The following table shows examples of how the macro processor interprets arguments for macros with different signatures given different input parameters. The definition of the example macro is:
create macro SUM3(argument1, argument2, argument3) as '(@@1 + @@2 + @@3)';
Table 3-36 Example Macro Inputs and Results
Macro with Signature of SUM3(signature) | Result when given input of SUM3(X,Y) | Result when given input of SUM3(X,Y,Z) | Result when given input of SUM3(X,Y,Z,T) |
---|---|---|---|
SUM3(SINGLE, SINGLE, SINGLE) |
Error (wrong number of arguments) |
X+Y+Z |
Error (wrong number of arguments) |
SUM3(SINGLE, SINGLE, GROUP) |
Error (wrong number of arguments) |
X+Y+Z |
X+Y+@LIST(Z,T) |
SUM3(SINGLE, SINGLE, OPTIONAL_GROUP) |
X+Y+@_NULL |
X+Y+Z |
X+Y+@LIST(Z,T) |
SUM3(SINGLE, SINGLE, OPTIONAL) |
X+Y+@_NULL |
X+Y+Z |
Error (wrong number of arguments) |
SUM3(SINGLE, SINGLE, ANY) |
X+Y+@_NULL |
X+Y+Z |
X+Y+Z |
SUM3(SINGLE, ANY) |
X+Y+ |
X+Y+Z |
X+Y+Z |
SUM3(SINGLE, GROUP) |
X+Y+ |
X+@LIST(Y,Z)+ |
X+@LIST(Y,Z,T)+ |
SUM3(ANY) |
X+Y+ |
X+Y+Z |
X+Y+Z |
Arguments in the Essbase calculator language can represent any of the following data types:
Table 3-37 Data Types of Arguments
Data Type | Description |
---|---|
Number | A single, double precision, floating point type number, which can have a special value, #MISSING, or an array of these numbers |
Boolean | A single three-valued variable with the possible values, TRUE, FALSE, and #MISSING, or an array of these variables |
Member | A single database outline member, cross-member combination, or an array of members |
String | A string variable type, or an array of these strings |
When developing macros, you should consider the types of data that can be passed into macros to avoid errors in calculation.