Lesson 4 of 6
Standard functions
8 min
Listen to this lesson
Node functions shape queues. Standard functions transform values. In the Functions pane, Cloud Integration groups them into categories such as Arithmetic, Boolean, Constants, Conversions, Date, Node Functions, Statistic and Text, plus your own custom functions. They all work on strings: a payload value is text, so a function casts the input to what it needs and raises an exception if it can't interpret it.
| Category | Functions you'll use most | Contoso example |
|---|---|---|
| Boolean | if, ifWithoutElse, and, or, not, equals, notEquals | Map the ship-to only when the partner function is WE |
| Text | equalsS, substring, concat, trim, replaceString, toUpperCase, length, indexOf, startsWith | Build an N1 name from two IDoc fields |
| Arithmetic | add, subtract, multiply, divide, FormatNum, equalsA, less, greater, round | Line amount = quantity × unit price |
| Date | currentDate, DateTrans, DateBefore, DateAfter, CompareDates | IDoc date yyyyMMdd to a partner date format |
| Statistic | count, sum, average, index | Number of lines for the 850 CTT segment |
| Constants and Conversions | Constant, FixValues, Value Mapping | Fixed qualifiers; code translation (sap-pim-204) |
Standard function categories and typical uses in Contoso's PO-to-Integration-Suite migration.
Conditions
Boolean functions return the strings true or false. Functions that expect a Boolean treat 1 and true (any case) as true and everything else as false. Choose the right comparison: equalsS compares text, equalsA compares numbers (so 1.5 equals 1.50), and equals compares two Boolean values. Using equals on text is a classic bug: non-Boolean values are all read as false, so two different strings compare as equal.
if takes a condition and two values. ifWithoutElse passes the value only when the condition is true; otherwise it produces SUPPRESS entries, so no target node is created. That is how "if condition" mapping works in practice: ifWithoutElse(equalsS(PARVW, Constant WE), NAME1) maps the ship-to name only from the ship-to partner segment.
Text and the leading-zeros trap
Text positions start at 0, and substring excludes the end position: substring("Hello", 0, 1) returns H. concat joins two strings and can insert a separator set in its parameters. Partners often want SAP numbers without leading zeros. Arithmetic functions seem to do this, but they calculate with Java float precision, and long numeric IDs such as an 18-character material number lose digits. For IDs, strip zeros with a small custom function (sap-pim-202) or a format the partner agrees on. Never round-trip an identifier through arithmetic.
Arithmetic and amounts
SAP's documentation shows the float problem with 2.11 + 22.11 = 24.220001. Format results with FormatNum when a partner expects two decimals, and check whether the result value is right, not only its format. Contoso's reference invoice 90001877 bills 50 × CMC-ALT-100 at 240.00, which is 12,000.00 USD. Lesson 3 of sap-pim-205 shows why the same value appears as 1200000 in an X12 TDS segment, which carries two implied decimals.
Dates
Date functions use Java SimpleDateFormat patterns. IDoc dates arrive as yyyyMMdd. DateTrans converts from one pattern to another, for example to MM/dd/yyyy for a flat-file partner. currentDate uses the time zone of the data center that hosts your tenant, not Contoso's Detroit time. Near midnight, a document date taken from currentDate can be a day off; take dates from the payload whenever the business date matters.
| Function | Compares | Example result |
|---|---|---|
| equalsS | Two strings, exactly | "WE" vs "we" → false |
| equalsA | Two numbers, numerically | "1.5" vs "1.50" → true |
| equals | Two Boolean values | "WE" vs "AG" → true (both read as false) |
| compare | Two strings, lexicographically | Returns 0, a positive or a negative number |
Statistics for control totals
count returns the number of values in a context, sum adds them and index numbers them with a start value and increment you set. Contoso's 850 uses count on the items to fill CTT01 (number of line items), and index when a partner wants line numbers 1, 2, 3 instead of SAP's 10, 20, 30. Both depend on the context of the input, so check the queue before trusting the total.
What would you do?
Dan reviews a test invoice for Great Lakes Fleet Services and finds the total off by a fraction of a cent on a few lines. The mapping multiplies quantity by unit price with <code>multiply</code> and sends the result as is. What should the developer change?
- Use equalsS for text, equalsA for numbers and equals only for Boolean values.
- ifWithoutElse produces SUPPRESS when false, so no target node is created.
- Arithmetic uses float precision: format amounts and never do arithmetic on identifiers.
- currentDate uses the data center's time zone; prefer dates from the payload.
Check your understanding · not graded
Lesson check
1. Which function should compare the partner function PARVW with the constant WE?
2. Why is arithmetic a poor way to remove leading zeros from an 18-character material number?
3. What time zone does currentDate use in a Cloud Integration mapping?
4. A target node must be created only for the ship-to partner. Which construct does this?