转自:http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
General
Values of elements or attributes of the XML message (the payload ) are technically speaking a string. Therefore, all standard functions that operate on field values expect string arguments and return a string value. Nevertheless, the transferred value can of course have a different semantic data type, namely, the one that you specified when you defined the schema for the payload for the field. Standard functions exhibit the following standard behavior:
● Depending on the standard function, data type conversions are used to ensure that the values are transferred in a format suitable for the function (using a cast ). If the value cannot be interpreted, the mapping runtime triggers a Java exception.
● If-clauses evaluate conditions that return Boolean values. Standard functions that return Boolean values return the string true or false . Standard functions that expect Boolean values interpret the values “1” and “true” (not case-sensitive) as true and all other values as false .
See also: Runtime Behavior
Overview of Functions
Data-flow objects for standard functions are structured as follows:
● Most data-flow objects have two or three inbound channels on the left-hand side, and one outbound channel on the right-hand side.
● If -functions are shaped as rhombuses or triangles.
● There are also conversion functions with one inbound and outbound channel and functions that return a value without any input.
● Standard functions that require additional specifications are indicated with a star ( ). To call the dialog for Function Properties , double click the data-flow object.
The following figure provides an overview of all the different forms of data-flow objects:
To illustrate how the individual functions are used, the input boxes in the figure above have the variables X , Y , Z or I , and the result variable is either R or O . All standard functions in the tables below are described using these input and output variables. In the data-flow editor, other data-flow objects that are connected to the functions using the connecting boxes either return the input values or receive the result of the operation. You can combine the functions in any way you require (provided that the values transferred to a function can be interpreted).
Function Category: Arithmetic
You can only enter numerical values for this category (this includes values with digits after the decimal point). If the value cannot be interpreted as a digit, then the system triggers a Java exception. In the default setting, all calculations are executed with the precision of the Java data type float . The format of the result value depends on the result:
● If the result is a value with digits after the decimal point, these remain unchanged.
● Exception: If a zero follows the decimal point, then this is cut off. This means that the result of the calculation 4.2 – 0.2 is 4 and not 4.0 .
Also note that Java values of type float are converted to the second system before the calculation. The result is calculated there and then this result is converted back to decimal format. The conversion may result in positions after the decimal point that are periodically repeated and then automatically cut off. In the decimal system, this can result in inaccurate results (example: 2.11 + 22.11 = 24.220001). If the number of positions after the decimal point is to be restricted to two, for example, in the case of values for a currency, you can format the values after the calculation by using the standard function FormatNum .
If the particular usage case requires more detailed results, you can also select the decimal system as the basis for the calculations. The Java class BigDecimal is used for internal purposes. For more details see SAP Note 958486.
Function Name |
Function |
add |
R = X + Y |
subtract |
R = X - Y |
equalsA |
R = true , if value X equals value Y , otherwise R = false . The values are interpreted numerically, therefore the value 1.5 is the same as 1.50 . |
abs |
O = Absolute value of I |
sqrt |
R is the square root of X |
sqr |
R is the square of X |
sign |
R = |