MathVariable Element

Within the <Math> element, calculations can be evaluated using MathVariables. MathVariables are variables that are used in the Math section of business rule configuration and use the <MathVariable> tag.  A MathVariable name is assigned as the value of the attribute VARIABLENAME.  After you name the MathVariable, you will identify what type of MathVariable you want to create.  There are various types of MathVariables available to configure processing.  MathVariables can be used to retrieve a field value, create arrays, structure if-then structures, perform calculations with operators or call functions.  Each of the math types has its own set of attributes, elements and possible values, which are listed below.  All MathVariables must have a data type declared using the DATATYPE attribute.

The <MathVariable> tag can use a LOG="Yes" attribute, which will log results to AsActivityMath. When using logging, remember that the system performs all logging at the end of transaction processing. Therefore, only the ending value of a MathVariable is logged. Although the configuration allows the LOG attribute on any use of a variable in the configuration, the intermediate values are not logged, even if LOG="Yes" occurs multiple times for the same variable. In such a case, to avoid confusion it is best to specify the LOG attribute only for the last use of the variable. Another method is to create a "Log Section" at the bottom of the configuration that specifies all math variables to be logged.

There are also <MathLoop>and <MathIF> elements, which are available to perform loops and if conditions, respectively.  Both must have a data type declared as well.

Available DATATYPE Options

  • ACTIVITY
  • BIGTEXT
  • BOOLEAN
  • CURRENCY
  • DATE
  • DECIMAL
  • INTEGER
  • TEXT
  • MAP
  • OBJECT
  • XML (Works with TYPE=”VALUE” and “FIELD”)

DATATYPE of either decimal or integer may not be blank, and a DEFAULT attribute must be defined.

If you will be dealing with integers that are larger than 2147483648 in math configuration then the DECIMAL data type must be used.

MathVariables may be used to pass values into spawn configuration.  Math statements are processed sequentially from top to bottom in the configuration.

 

Element/Tag Attribute Definition Element/Attribute Value and Description

<MathVariable>

TYPE

 

FIELD: Element Values

• [Entity]:[MathVariable]:EffectiveDate

• [Entity]:[MathVariable]::MoneyType

• [Entity]:[MathVariable]:TypeCode

These configurations above allows access to the table column values for the GUID referenced in MathVariable

• [Entity]:[MathVariable]: Balance

This configuration calculates total amount left at Financial Entry level for the GUID referenced in the MathVariable

• [Entity]: Balance

This configuration calculates the total Balance Amount left at Policy level

XML Example

<MathVariables>
<!-- Calculate Days from Last Bank Draft -->
<MathVariable VARIABLENAME="LastActiveBankDraftEffectiveDate" TYPE="VALUE" 
DATATYPE="DATE"></MathVariable>
<MathVariable VARIABLENAME="BankDraftEndDate" TYPE="FIELD" 
DATATYPE="DATE">Activity:EffectiveDate</MathVariable>
<MathVariable VARIABLENAME="LastActiveBankDraftEffectiveDate" TYPE="SQL" DATATYPE="DATE">
<SqlServer>SELECT TOP 1 AsActivity.EffectiveDate FROM AsActivity 
JOIN AsTransaction ON AsTransaction.TransactionGUID = AsActivity.TransactionGUID 
AND AsTransaction.TransactionName = 'BankDraft' 
WHERE AsActivity.PolicyGUID = '[Policy:PolicyGUID]' 
AND AsActivity.StatusCode IN ('01','13','14') 
AND AsActivity.TypeCode IN ('01','04') 
ORDER BY AsActivity.EffectiveDate DESC
</SqlServer>
<Oracle>SELECT EffectiveDate FROM (SELECT AsActivity.EffectiveDate FROM AsActivity 
JOIN AsTransaction ON AsTransaction.TransactionGUID = AsActivity.TransactionGUID 
AND AsTransaction.TransactionName = 'BankDraft' 
WHERE AsActivity.PolicyGUID = '[Policy:PolicyGUID]' 
AND AsActivity.StatusCode IN ('01','13','14') 
AND AsActivity.TypeCode IN ('01','04') 
ORDER BY AsActivity.EffectiveDate DESC) WHERE ROWNUM = 1
</Oracle>
<DB2>SELECT AsActivity.EffectiveDate FROM AsActivity 
JOIN AsTransaction ON AsTransaction.TransactionGUID = AsActivity.TransactionGUID 
AND AsTransaction.TransactionName = 'BankDraft' 
WHERE AsActivity.PolicyGUID = '[Policy:PolicyGUID]' 
AND AsActivity.StatusCode IN ( '01' , '13' , '14' ) 
AND AsActivity.TypeCode IN ( '01' , '04' ) 
ORDER BY AsActivity.EffectiveDate DESC FETCH FIRST 1 ROWS ONLY
</DB2>
</MathVariable>
<MathVariable VARIABLENAME="TestLastActiveBankDraft" TYPE="FUNCTION" 
DATATYPE="BOOLEAN">IsEmpty(LastActiveBankDraftEffectiveDate)</MathVariable>
<MathIF IF="TestLastActiveBankDraft = false">
<MathVariable VARIABLENAME="DaysFromLastBankDraft" TYPE="FUNCTION" 
DATATYPE="INTEGER">DaysDiffOf(LastActiveBankDraftEffectiveDate,BankDraftEndDate)</MathVariable>
</MathIF>
<MathVariable VARIABLENAME="CommentToSpawn" TYPE="FIELD" 
DATATYPE="BIGTEXT">Activity:AnnualStatementComment</MathVariable>
<MathVariable VARIABLENAME="XmlValueMV" TYPE="VALUE" DATATYPE="XML"/>
<MathVariable VARIABLENAME="XmlFieldlMV" TYPE="FIELD" DATATYPE="XML">Activity:XMLData</MathVariable>
<MathVariable VARIABLENAME="CorrectionDateMV" TYPE="MULTIFIELD" INDEX="1" DATATYPE="DATE">CorrectionDate</MathVariable>
   <MathVariable VARIABLENAME="[MathVariable]" TYPE="FIELD" DATATYPE="XXX">Entity:[MathVariable]:[ColumnName]</MathVariable>
   <MathVariable VARIABLENAME="[MathVariable]" TYPE="FIELD" DATATYPE="DECIMAL">Entity: Balance</MathVariable>
<MathVariable VARIABLENAME="PolicyNotify" TYPE="PROCESS" NAMESPACE="com.oi.osc" OBJECT="MathPlugin" DATATYPE="OBJECT">
</MathVariables>

Object

The MathVariable of type OBJECT can be used to update all the dynamic and non-system fixed fields.

 

TYPE=Object
Element Definition Attribute Element/Attribute Value and Description
<MathVariable>      
    TYPE

Value: OBJECT

Note: It is not necessary that the OBJECT attribute is used within an OBJECTLOOP when the Object name is 'COMMDETAIL'

    OBJECTNAME

Value: AsCodeCreateObjectType

It is used to identify the object name.

MathVariable/Static/ActivityField. (Currently available value is "COMMDETAIL")

    SOURCEARRAY Note: It is not required when the object name is COMMDETAIL.
    OPERATION

Value: CREATE

It is used to create a OBJECT type of MathVariable. This is currently supported only for OBJECTNAME='COMMDETAIL'.

Please note that,in case of using a loop to set the OBJECT,then the OBJECT creation needs to be within the Loop and not outside the Loop.

     

Value: SETVALUE

It is used to specify the operation as setting value to the Fields of the OBJECT.

OBJECTNAME is not required for this operation.

The MathVariable name should be same as the MathVariable of type OBJECT for which the fields are being set.

    DATATYPE

This should be set to OBJECT when the operation is CREATE.

For OPERATION = SETVALUE the data type will be the data type of the field that is being assigned the value.

    FIELDNAME This is field of the OBJECT for which the value is being set using SETVALUE operation.This is valid only with SETVALUE operation.

Object Array

A Transaction Math of type "OBJECTARRAY" rule can be used to hold an array of o objects. The array supports three operations:

  • CREATE - Creates an OBJECTARRAY
  • APPEND - Appends to an existing ARRAY with an OBJECT
  • INSERT - Inserts into an existing array at a specified INDEX
  • INDEX - Specifies the index during the INSERT operation and it is ignored if used with other operations. MathVariable and static numbers are allowed for this operation.

 

TYPE=ObjectArray
Element Definition Attribute Element/Attribute Value and Description
<MathVariable>    

 

    TYPE

Value: OBJECTARRAY

Contains an array of OBJECTS

    OPERATION

Value: CREATE

It is a variable whose value is the length of a newly created array. A new array with the length equal to the element value .

When CREATE operation is used, the value of the MathVariable cannot be blank and must be an integer (or a MathVariable containing an integer).

This value allows the system to predetermine the size of the array to build and reserve memory for it.

Note: This value should be instantiated as zero (0) if the size of the array is not yet known.

     

Value: APPEND

A variable of type OBJECT(all objects of an array should be of the same kind) whose value is appended to array SOURCEARRAY.

Results in new array equal to array indicated by SOURCEARRAY attribute with an additional OBJECT appended.

Note: If the SOURCEARRAY attribute is specified, the name must be the same as the name of the specified VARIABLENAME. The append operation will insert the math object at the end of the array.

     

Value: INSERT

A variable of type OBJECT whose value is placed in the array at a specific location/index.

The object is inserted into the array using insert operation. If the specified index does not exist (e.g. the array is too short), it will throw an error " Array Index Out of Bounds".

     

Value: LENGTH

Returns the LENGTH of the OBJECT array specified in the SOURCEARRAY attribute.

    SOURCEARRAY It is the MathVariable name of the source array. This is used when the operation is APPEND/INSERT/LENGTH
    INDEX It is used to specify the INDEX when the OPERATION is INSERT
    DATATYPE

Value: OBJECT

It specifies the data type.

XML Schema

Transaction Math to Create Object Array and Commission Object

<MathVariable VARIABLENAME="CurrencyTextMV" TYPE="VALUE" DATATYPE="TEXT"> INR </MathVariable>
 

<!-- Comment AggregateCOmmissionCurrencyMV is a Money field defined in CommissionDetailScreen BR -->

<MathVariable VARIABLENAME="AggregateCommissionCurrencyMV" TYPE="FUNCTION" DATATYPE="CURRENCY">ToCurrency(AggregateCommissionAmountMV,CurrencyTextMV)</MathVariable>

 

<MathVariable VARIABLENAME="CommissionObjectArrayMV" TYPE="OBJECTARRAY" OPERATION="CREATE" DATATYPE="OBJECT">0</MathVariable>
<MathVariable VARIABLENAME="CommissionObject" TYPE="OBJECT" OBJECTNAME="CommissionDetailMV" OPERATION="CREATE" DATATYPE="OBJECT"></MathVariable>
<MathVariable VARIABLENAME="CommissionObject" TYPE="OBJECT" OPERATION="SETVALUE" FIELDNAME="EffectiveDate" DATATYPE="DATE">SystemDateMV</MathVariable>
<MathVariable VARIABLENAME="CommissionObject" TYPE="OBJECT" OPERATION="SETVALUE" FIELDNAME="TypeCode" DATATYPE="TEXT">COmmissionTypeCodeMV</MathVariable>
<MathVariable VARIABLENAME="CommissionObject" TYPE="OBJECT" OPERATION="SETVALUE" FIELDNAME="EntityType" DATATYPE="TEXT">POLICY</MathVariable>
<MathVariable VARIABLENAME="CommissionObject" TYPE="OBJECT" OPERATION="SETVALUE" FIELDNAME="EntityGUID" DATATYPE="TEXT">Policy:PolicyGUID</MathVariable>
<MathVariable VARIABLENAME="CommissionObject" TYPE="OBJECT" OPERATION="SETVALUE" FIELDNAME="SourceComponentTypeCode" DATATYPE="TEXT">BASEPRM</MathVariable>
<MathVariable VARIABLENAME="CommissionObject" TYPE="OBJECT" OPERATION="SETVALUE" FIELDNAME="Amount" DATATYPE="DECIMAL">CommissionAmountUSDMV</MathVariable>

 

<!-- Comment Please note that the amount and currency for the fixed fields under AsCommissionDetails table is set separately while the dynamic field AggregateCommission" uses a datatype of Currency -->

<MathVariable VARIABLENAME="CommissionObject" TYPE="OBJECT" OPERATION="SETVALUE" FIELDNAME="CurrencyCode" DATATYPE="TEXT">CurrencyCodeMV</MathVariable>
<MathVariable VARIABLENAME="CommissionObject" TYPE="OBJECT" OPERATION="SETVALUE" FIELDNAME="StatusCode" DATATYPE="TEXT">StatusMV</MathVariable>
<MathVariable VARIABLENAME="CommissionObject" TYPE="OBJECT" OPERATION="SETVALUE" FIELDNAME="ClientGUID" DATATYPE="TEXT">ClientGUIDMV</MathVariable>
<MathVariable VARIABLENAME="CommissionObject" TYPE="OBJECT" OPERATION="SETVALUE" FIELDNAME="AggregateCommission" DATATYPE="CURRENCY">AggregateCommissionCurrencyMV</MathVariable>
<MathVariable VARIABLENAME="CommissionObjectArrayMV" TYPE="OBJECTARRAY" OPERATION="APPEND" SOURCEARRAY="CommissionObjectArray" DATATYPE="OBJECT">CommissionObject</MathVariable>