Example 1: Delivery performance
The delivery performance measure compares the actual delivery date (end time of the SAP.WAUS function in a process instance) with a default value imported from the source system. If the actual delivery date is before the default value, the measure value is 0. The value 0 is interpreted as on-time delivery. Otherwise, the measure shows the deviation from the standard value. The default value is stored in the AT_CUSTDATE_WISH process instance attribute. Where the SAP.WAUS function occurs several times in the process instance, the earliest value is determined.
...
<!-Delivery performance -->
<calcattr name="AT_KI_WLFTREU" type="PROCESS">
<calculation>
<max>
<set>
<constant>
<dataitem value="0 SECOND">
<datatype name="TIMESPAN"/>
</dataitem>
</constant>
<timespan>
<max>
<attribute name="AT_CUSTDATE_WISH"
nodetype="PROCESS"/>
</max>
<min>
<attribute name="AT_END_TIME"
nodetype="OT_FUNC" objectname="SAP.WAUS"/>
</min>
</timespan>
</set>
</max>
</calculation>
</calcattr>
...
The measure is given the maximum (max) of a set of values (set) as its value. The set of values contains the element 0 (constant) and the time difference between the actual delivery date and the target delivery date (timespan). As the attribute XML element creates a set of values, appropriate operators must first of all be used to determine an attribute value for further calculation. When determining the attribute value for the SAP.WAUS function, using the min operator also determines the earliest actual delivery date. The set of values created using set is given 2 elements: {0, (Desired date - Delivery date)}. When determining the maximum of the set of values, a negative time span results in 0 being returned while a positive time span returns the difference between the end time of the SAP.AUS function and the AT_CUSTDATE_WISH process attribute in seconds (base unit for the timespan data type).
As this new attribute is a process instance attribute, it is calculated only once for each process instance. The following results of the calculation can occur:
The new process instance attribute is given the calculated positive time span in the unit Seconds. If the calculated time span is negative, the new process instance attribute is given the time span 0 seconds.
The new process instance attribute is not written at the process instance if the calculation fails for one or more of the following reasons and no default value is specified:
Example 2
At each function of a process instance, the AT_KI_COMPETENCE attribute should specify whether the values of the AT_COMPETENCE and AT_CREDIT_AMOUNT attributes for a function match. If they match, the attribute should have the value 1, otherwise the value should be 0.
<calcattr name="AT_KI_COMPETENCE" type="OT_FUNC">
<calculation>
<if>
<eq>
<min>
<attribute name="AT_COMPETENCE"
nodetype="OT_FUNC" objectname="this"/>
</min>
<max>
<attribute name="AT_CREDIT_AMOUNT"
nodetype="OT_FUNC" objectname="this"/>
</max>
</eq>
<then>
<constant>
<dataitem value="1">
<datatype name="DOUBLE"/>
</dataitem>
</constant>
</then>
<else>
<constant>
<dataitem value="0">
<datatype name="DOUBLE"/>
</dataitem>
</constant>
</else>
</if>
</calculation>
</calcattr>
Specifying the OT_FUNC node type and the lack of an object name leads to the calculated AT_KI_COMPETENCE attribute being written to all functions in the process instance. In the attribute calculation, specifying this as the object name results in every function accessing its own attributes. In this case, the embracing operators min and max return the value of the referenced attribute, as the object name this results in an attribute set containing only one element.
Example 3
By default, the earliest start time of a function in the process instance is used as the start time for a process instance:
<calcattr name="AT_START_TIME" type="PROCESS">
<calculation>
<min>
<attribute name="AT_START_TIME" nodetype="OT_FUNC"/>
</min>
</calculation>
</calcattr>
If only the start times of particular functions are to be used, these functions must be checked for a particular criterion. In the following example, the auxiliary AT_TEMP_TIME attribute is used to filter the "Rush order type" criterion (AT_AUFTRAGSART function attribute value). The actual start time for the process instance is then determined from the filtered start times of the functions.
<calcattr name="AT_TEMP_TIME" type="OT_FUNC">
<calculation>
<if>
<eq>
<filteredattribute name="AT_AUFTRAGSART" nodetype=
"OT_FUNC" objectname="this" filter="EARLY"/>
<constant>
<dataitem>
Rush order
<datatype name="TEXT"/>
</dataitem>
</constant>
</eq>
<then>
<filteredattribute name="AT_START_TIME" nodetype=
"OT_FUNC" objectname="this" filter="EARLY"/>
</then>
</if>
</calculation>
</calcattr>
<calcattr name="AT_START_TIME" type="PROCESS">
<depends attrname="AT_TEMP_TIME" nodetype="OT_FUNC">
<calculation>
<min>
<attribute name="AT_TEMP_TIME" nodetype="OT_FUNC"/>
</min>
</calculation>
</calcattr>
Example 4
The order group is to be saved as a function attribute in the AT_KI_AUFTR_GRUPPE attribute. The order group is given by the first two characters in the order number (AT_AUFTNR). For example, the order group 40 belongs to the order number 40268755.
The subtext operator extracts the string 40 from the string 40268755 for the AT_AUFTNR function attribute:
<calcattr name="AT_KI_AUFTR_GRUPPE" type="OT_FUNC">
<calculation>
<subtext beginindex="0" endindex="2">
<filteredattribute name="AT_AUFTNR" nodetype=
"OT_FUNC" objectname="this" filter="EARLY"/>
</subtext>
</calculation>
</calcattr>
XML attribute |
Description |
---|---|
beginindex |
Start index (inclusive, starting at 0) |
endindex |
end index (exclusive) |
If no end index is specified, the result string begins at the specified start index and ends at the end of the source string.
Warning
The subtext operator can only be used on attributes and constants of the TEXT data type. If you use it on a string that contains fewer characters than the number specified in beginindex or endindex, the operator returns the value NULL.
Example 5
The date 07.04.2003 is extracted from the time stamp 07.04.2003 17:30:58 and is written to all functions in the process instance as the value of the AT_CALEN_DAY attribute.
<calcattr name="AT_CALEN_DAY" type="OT_FUNC">
<calculation>
<createday>
<constant>
<dataitem value="07.04.2003 17:30:58">
<datatype name="TIME"/>
</dataitem>
</constant>
</createday>
</calculation>
</calcattr>
Example 6
A time span of one hour (3600 seconds in the base unit) is added to the time stamp 22.01.2002 14:55:21 and copied to all functions in the process instance as the time stamp value 22.01.2002 15:55:21 for the AT_ADD_TSP attribute.
<calcattr name="AT_ADD_TSP" type="OT_FUNC">
<calculation>
<addtimespan>
<!-- Time stamp -->
<constant>
<dataitem value="22.01.2002 14:55:21">
<datatype name="TIME"/>
</dataitem>
</constant>
<!— Time span 3600 seconds -->
<constant>
<dataitem value="3600">
<datatype name="TIMESPAN"/>
</dataitem>
</constant>
</addtimespan>
</calculation>
</calcattr>