Mathematic operators

The following operators are available: plus, minus, timespan, times, divide, abs, div, mod, squareroot, sigma, round.

Addition

XML tag:

plus

Operands:

at least two values

Synopsis:

<plus>
<value 1>
<value 2>
<value n>
</plus>

Operands:

Numerical data types (LONG, DOUBLE, TIMESPAN, FACTORYTIMESPAN, FREQUENCY, PERCENTAGE)

Result:

Value

Result type:

Operand data type with identical data type.
DOUBLE for mixed numerical data types that, in this case, are automatically converted to DOUBLE.

Description:

Adds the values specified in the XML element

Calculation (PPM3)

Result

Sum of all operands

Error

If at least one operand equals NULL or at least one operand is of a non-numerical data type

Calculation (PPM4)

Result

NULL if at least one operand equals NULL, otherwise sum of all operands.

Error

Only if the data type is non-numerical

Example:

-

Subtraction

XML tag:

minus

Operands:

exactly two values

Synopsis:

<minus>
<value 1>
<value 2>
</minus>

Operands:

Numerical data types (LONG, DOUBLE, TIMESPAN, FACTORYTIMESPAN, FREQUENCY, PERCENTAGE)

Result:

Value (difference)

Result type:

Operand data type with identical data type.
DOUBLE for mixed numerical data types that, in this case, are automatically converted to DOUBLE.

Description:

Subtracts value 2 from value 1

Calculation (PPM3)

Result

Result of subtracting operand 2 from operand 1

Error

If at least one operand equals NULL or at least one operand is of a non-numerical data type

Calculation (PPM4)

Result

NULL if at least one operand is equal to NULL, otherwise result of subtracting operand 2 from operand 1

Error

Only if the data type is non-numerical

Example:

-

Time span

XML tag:

timespan

Operands:

Exactly two values (points in time)

Synopsis:

<timespan>
<time 1>
<time 2>
</timespan>

Operands:

TIME (TIMESTAMP, DATE)

Result:

Value (time span)

Result type:

TIMESPAN or
FACTORYTIMESPAN when using a factory calendar

Description:

Calculates the time difference between time 1 and time 2. If the difference is negative, the value 0 is returned.
To use the factory calendar to calculate the time difference, give the optional type XML element the value FACTORYCALENDAR.
Default value: NORMAL

 

Calculation (PPM3)

Result

Time span between operand 1 and operand 2 (operand 1 minus operand 2)

Error

If at least one operand equals NULL or at least one is of an invalid data type

Calculation (PPM4)

Result

NULL if at least one operand is equal to NULL, otherwise time span between operand 1 and operand 2 (operand 1 minus operand 2)

Error

Only if data type is invalid

Example:

<timespan type="FACTORYCALENDAR"
directoryname="custom/client/factorycal"
attributename="AT_FC_XYZ">
<max>
<attribute name="AT_GOODS_RECEIPT_DATE"
nodetype="OT_FUNC"
objectname="SAP.MM_WE_ANLEG"/>
</max>
<min>
<attribute name="AT_END_TIME"
nodetype="OT_FUNC"
objectname="SAP.MM_BANF_ANLEG"/>
</min>
</timespan>

If you are using a factory calendar you can also calculate negative time spans by specifying the optional XML attribute negfactorytimespan="TRUE".
Default value: FALSE

You can also perform time span calculations based on external factory calendars by specifying a factory calendar XML file. In the optional directoryname XML attribute, specify the directory containing the factory calendar to be used. The attributename attribute is used to specify the name of the attribute type containing the name of the factory calendar file to be used. The attribute type must be specified for the corresponding object or process instance. The two XML attributes must always be specified together.

Multiplication

XML tag:

times

Operands:

at least two values

Synopsis:

<times>
<value 1>
<value 2>
<value n>
</times>

Operands:

Numerical data types (LONG, DOUBLE, TIMESPAN, FACTORYTIMESPAN, FREQUENCY, PERCENTAGE)

Result:

Value (product)

Result type:

Operand data type with identical data type.
DOUBLE for mixed numerical data types that, in this case, are automatically converted to DOUBLE.

Description:

Multiplies the values specified in the XML element.

Calculation (PPM3)

Result

Result of multiplying operands 1 to n

Error

If at least one operand equals NULL or at least one operand is of a non-numerical data type

Calculation (PPM4)

Result

NULL if at least one operand is equal to NULL, otherwise result of multiplying all operands

Error

Only if the data type is non-numerical

Example:

-

Division

XML tag:

divide

Operands:

exactly two values

Synopsis:

<divide>
<value 1>
<value 2>
</divide>

Operands:

Numerical data types (LONG, DOUBLE, TIMESPAN, FACTORYTIMESPAN, FREQUENCY, PERCENTAGE)

Result:

Value (quotient)

Result type:

Always DOUBLE

Description:

Divides value 1 by value 2.

Calculation (PPM3)

Result

Result of dividing operand 1 by operand 2

Error

If at least one operand equals NULL or at least one operand is of an invalid data type, or operand 2 = 0

Calculation (PPM4)

Result

NULL if at least one operand is equal to NULL, otherwise result of dividing operand 1 by operand 2

Error

If at least one operand is of an invalid data type or operand 2 = 0

Example:

-

Amount

XML tag:

abs

Operands:

exactly one value

Synopsis:

<abs>
<value 1>
</abs>

Operands:

Numerical data types (LONG, DOUBLE, TIMESPAN, FACTORYTIMESPAN, FREQUENCY, PERCENTAGE)

Result:

Value (absolute value)

Result type:

Operand data type

Description:

Returns the amount of a value.

Calculation (PPM3)

Result

Absolute operand value

Error

If an operand equals NULL or is of a non-numerical data type

Calculation (PPM4)

Result

NULL if operand equals NULL, otherwise absolute operand value

Error

Only if the data type is non-numerical

Example:

-

Integer division

XML tag:

div

Operands:

exactly two integer values

Synopsis:

<div>
<value 1>
<value 2>
</div>

Operands:

LONG

Result:

Integer value of division

Result type:

LONG

Description:

Returns the integer value for how often value 2 is contained in value 1. Remainders are ignored. For proper fractions, 0 is returned.

Calculation (PPM4 only)

Result

NULL if at least one operand is equal to NULL, otherwise integer result of dividing operand 1 by operand 2

Error

If at least one operand is of an invalid data type (not LONG) or operand 2 = 0

Example:

<div>
<max>
<attribute name="AT_COST"
nodetype="FUNCTION"/>
</max>
<constant>
<dataitem>
5
<datatype name="LONG">
Long
</datatype>
</dataitem>
</constant>
</div>

Modulo

XML tag:

mod

Operands:

exactly two integer values

Synopsis:

<mod>
<value 1>
<value 2>
</mod>

Operands:

LONG

Result:

Integer remainder

Result type:

LONG

Description:

Returns the remainder of an integer division of value 1 by value 2. For proper fractions, the value of the first operand is returned. If value 1 = value 2, 0 is returned.

Calculation (PPM4 only)

Result

NULL if at least one operand is equal to NULL, otherwise remainder of integer division of operand 1 by operand 2

Error

If at least one operand is of an invalid data type (not LONG) or operand 2 = 0

Example:

<mod>
<filteredattribute name="AT_COST"
nodetype="FUNCTION"/>
<constant>
<dataitem>
3
<datatype name="LONG">Long</datatype>
</dataitem>
</constant>
</mod>

Square root

XML tag:

squareroot

Operands:

exactly one value

Synopsis:

<squareroot>
<value 1>
</squareroot >

Operands:

Numerical data types (LONG, DOUBLE, TIMESPAN, FACTORYTIMESPAN, FREQUENCY, PERCENTAGE, and user-defined types, e.g., COST)

Result:

Square root

Result type:

DOUBLE data type

Description:

Calculates the square root of the value entered.

Calculation (PPM4 only)

Result

NULL if the operand equals NULL, otherwise the square root of the numeric operand

Error

If the operand has an invalid data type (not numerical) or if the value of the operand is less than 0

Example:

-

Six Sigma value

The Six Sigma value is a quality management measure (Six Sigma method). The measure value indicates the degree to which the process is error-free.

XML tag:

sigma

Operands:

exactly one value

Synopsis:

<sigma>
<value 1>
</sigma>

Operands:

Numerical data types (LONG, DOUBLE, TIMESPAN, FACTORYTIMESPAN, FREQUENCY, PERCENTAGE, and user-defined types, e.g., COST)

Result:

Six Sigma value

Result type:

DOUBLE data type

Description:

Calculates the Six Sigma value using the following formula:

Sigma (x) = p quantile (x) +1.5

In PPM, the percentile (p quantile) is calculated using the method developed by P. Griffiths and I.D. Hill: Applied Statistics Algorithms.

Calculation (PPM4 only)

Result

NULL if the operand equals NULL;
0 if the operand is <= 0; +1000 if the operand is <= 1, otherwise the Six Sigma value of the operand

Error

If operand has an invalid data type (not numerical)

Example:

-

Round

XML tag:

round

Operands:

A single value of the TIMESPAN type

Synopsis:

<round>
<value>
</round>

Operands:

TIMESPAN

Result:

Rounded time span value

Result type:

TIMESPAN

XML attributes

scale (MINUTE|HOUR|DAY|WEEK|MONTH|YEAR)

roundingkind (ROUND|FLOOR|CEIL) "ROUND"

Description:

Returns the rounded value for time spans. Only values of the TIMESPAN data type can be rounded. The scale to be used for rounding must be specified.

The following rounding methods exist:

ROUND (decimal places < 5 rounded down, >= 5 rounded up)
CEIL (rounding up to the next whole number regardless of the value of the decimal place)
FLOOR (rounding down to the current whole number regardless of the value of the decimal place)
The default value is ROUND.

Calculation (PPM4 only)

Result

The rounded value in the specified scale.

Error

If operand is of an invalid data type or an invalid number of operands.

Example:

<round scale="MINUTE" roundingkind="CEIL">
<constant>
<dataitem value="4284.0">
1,19
<datatype name="TIMESPAN">
Time span
</datatype>
<scale name="HOUR" factor="3600.0">
Hours
</scale>
</dataitem>
</constant>
</round>

The time span value 1.19 hours is converted to 71.4 minutes as specified by the scale and is rounded up to 72 minutes (return value) in line with the specified rounding method.

Null value

XML tag:

nullvalue

Operands:

exactly two values

Synopsis:

<nullvalue>
<value 1>
<value 2>
</nullvalue>

Operands:

Any data type, both operands must be of the same data type.

Result:

Value of the first operand if it is not null, otherwise value of the second operand

Result type:

Operand data type

Description:

Replaces the possibly missing value of the first operator (value null) with the value of the second operator. If the first operand supplies a value, this value will be returned, otherwise the value of the second operand will be returned.
If both operators do not supply any value, null is returned as a value. This means that the second operator should always supply a value.

Calculation (PPM4 only)

Result

Value of the first operand if it is not null, otherwise value of the second operand.

Error

When operands have different data types

Example:

<nullvalue>

<subtext beginindex="3">

<filteredattribute name="AT_XYZ"Line break
nodetype="PROCESS"/>

</subtext>

<constant>

<dataitem>

ABC

<datatype name="TEXT">Text</datatype>

</dataitem>

</constant>

</nullvalue>

If the subtext operator does not return any value, the constant character string ABC is returned.