Comprehensive Guide to CPI Pallet Functions
Overview
Pallet functions in SAP Cloud Platform Integration (CPI) are pre-built functions used in message
mapping to transform data during integration processes. These functions are organized into
categories and provide essential data manipulation capabilities without requiring custom code.
Architecture and Inner Workings
Input Data → Pallet Function → Transformation Logic → Output Data
↓ ↓ ↓ ↓
Source Field → Function Parameters → Processing → Target Field
How Pallet Functions Work:
1. Input Reception: Functions receive input values from source fields
2. Parameter Processing: Additional parameters are evaluated
3. Logic Execution: Core transformation logic is applied
4. Output Generation: Transformed result is produced
5. Target Assignment: Result is mapped to target field
1. Arithmetic Functions
Core Purpose
Arithmetic functions perform mathematical operations on numeric values, enabling calculations
within message mappings.
Function Details
add
Purpose: Adds two or more numeric values
Usage: add(value1, value2, ...)
Example:
Input: 10, 20, 5
Output: 35
subtract
Purpose: Subtracts second value from first
Usage: subtract(minuend, subtrahend)
Example:
Input: 100, 25
Output: 75
multiply
Purpose: Multiplies two or more values
Usage: multiply(factor1, factor2, ...)
Example:
Input: 4, 5, 2
Output: 40
divide
Purpose: Divides first value by second
Usage: divide(dividend, divisor)
Example:
Input: 100, 4
Output: 25
power
Purpose: Raises base to the power of exponent
Usage: power(base, exponent)
Example:
Input: 2, 3
Output: 8
sqrt
Purpose: Calculates square root
Usage: sqrt(value)
Example:
Input: 16
Output: 4
square
Purpose: Calculates square of a number
Usage: square(value)
Example:
Input: 5
Output: 25
absolute
Purpose: Returns absolute value
Usage: absolute(value)
Example:
Input: -15
Output: 15
sign
Purpose: Returns sign of number (-1, 0, or 1)
Usage: sign(value)
Example:
Input: -25
Output: -1
neg
Purpose: Returns negative of a number
Usage: neg(value)
Example:
Input: 10
Output: -10
inv
Purpose: Returns reciprocal (1/x)
Usage: inv(value)
Example:
Input: 4
Output: 0.25
max
Purpose: Returns maximum value from inputs
Usage: max(value1, value2, ...)
Example:
Input: 10, 25, 5, 30
Output: 30
min
Purpose: Returns minimum value from inputs
Usage: min(value1, value2, ...)
Example:
Input: 10, 25, 5, 30
Output: 5
ceil
Purpose: Rounds up to nearest integer
Usage: ceil(value)
Example:
Input: 4.2
Output: 5
floor
Purpose: Rounds down to nearest integer
Usage: floor(value)
Example:
Input: 4.8
Output: 4
round
Purpose: Rounds to nearest integer
Usage: round(value)
Example:
Input: 4.6
Output: 5
equals (number)
Purpose: Compares two numbers for equality
Usage: equals(value1, value2)
Example:
Input: 10, 10
Output: true
lesser
Purpose: Checks if first value is less than second
Usage: lesser(value1, value2)
Example:
Input: 5, 10
Output: true
greater
Purpose: Checks if first value is greater than second
Usage: greater(value1, value2)
Example:
Input: 15, 10
Output: true
counter
Purpose: Generates sequential numbers
Usage: counter()
Application: Creating unique identifiers or sequence numbers
formatNumber
Purpose: Formats numbers according to specified pattern
Usage: formatNumber(number, pattern)
Example:
Input: 1234.5, "#,##0.00"
Output: "1,234.50"
2. Boolean Functions
Core Purpose
Boolean functions perform logical operations and conditional evaluations.
Function Details
and
Purpose: Logical AND operation
Usage: and(condition1, condition2, ...)
Example:
Input: true, false, true
Output: false
or
Purpose: Logical OR operation
Usage: or(condition1, condition2, ...)
Example:
Input: true, false, false
Output: true
not
Purpose: Logical NOT operation
Usage: not(condition)
Example:
Input: true
Output: false
equals (boolean)
Purpose: Compares boolean values
Usage: equals(boolean1, boolean2)
Example:
Input: true, true
Output: true
notEquals
Purpose: Checks if values are not equal
Usage: notEquals(value1, value2)
Example:
Input: "A", "B"
Output: true
if
Purpose: Conditional logic with else clause
Usage: if(condition, then_value, else_value)
Example:
Input: true, "Yes", "No"
Output: "Yes"
ifS
Purpose: String-based conditional logic
Usage: ifS(condition, then_string, else_string)
Application: String manipulations based on conditions
ifWithoutElse
Purpose: Conditional logic without else clause
Usage: ifWithoutElse(condition, then_value)
Example:
Input: true, "Execute"
Output: "Execute"
ifSWithoutElse
Purpose: String conditional without else
Usage: ifSWithoutElse(condition, then_string)
Application: Conditional string assignment
isNil
Purpose: Checks if value is null or empty
Usage: isNil(value)
Example:
Input: null
Output: true
3. Constant Functions
Core Purpose
Constant functions provide fixed values or handle special cases in mappings.
constant
Purpose: Returns a constant value
Usage: constant(value)
Application: Providing default values or fixed text
Example:
Output: "FIXED_VALUE"
copyValue
Purpose: Copies input value to output
Usage: copyValue(input)
Application: Direct field mapping
Example:
Input: "Sample Text"
Output: "Sample Text"
xsi:nil
Purpose: Generates XML nil element
Usage: xsi:nil()
Application: Creating null XML elements
Example:
Output: <element xsi:nil="true"/>
4. Conversion Functions
Core Purpose
Conversion functions transform data types and apply value mappings.
fixValues
Purpose: Replaces specific values with alternatives
Usage: fixValues(input, oldValue1, newValue1, oldValue2, newValue2, ...)
Example:
Input: "USD", "USD", "US Dollar", "EUR", "Euro"
Output: "US Dollar"
ValueMapping
Purpose: Applies value mapping table transformations
Usage: ValueMapping(agency, identifier, sourceValue)
Application: Code transformations using predefined tables
Example:
Input: "CURRENCY_CODES", "ISO_TO_SAP", "USD"
Output: "1"
5. Date Functions
Core Purpose
Date functions handle date manipulations and comparisons.
currentDate
Purpose: Returns current system date
Usage: currentDate()
Example:
Output: "2025-06-28"
dateTrans
Purpose: Transforms date format
Usage: dateTrans(date, sourceFormat, targetFormat)
Example:
Input: "28/06/2025", "dd/MM/yyyy", "yyyy-MM-dd"
Output: "2025-06-28"
dateBefore
Purpose: Checks if first date is before second
Usage: dateBefore(date1, date2)
Example:
Input: "2025-06-01", "2025-06-28"
Output: true
dateAfter
Purpose: Checks if first date is after second
Usage: dateAfter(date1, date2)
Example:
Input: "2025-06-28", "2025-06-01"
Output: true
compareDates
Purpose: Compares two dates
Usage: compareDates(date1, date2)
Returns: -1 (before), 0 (equal), 1 (after)
6. Node Functions
Core Purpose
Node functions manipulate XML structure and context handling.
createIf
Purpose: Creates node based on condition
Usage: createIf(condition)
Application: Conditional node creation
Example:
Input: true
Result: Node is created
removeContexts
Purpose: Removes context information
Usage: removeContexts(input)
Application: Flattening hierarchical data
Process Flow:
Multiple Contexts → removeContexts() → Single Context
Context1 ↓ Merged
Context2 Function Result
Context3 ↓
replaceValue
Purpose: Replaces specific values in nodes
Usage: replaceValue(input, oldValue, newValue)
Example:
Input: "Hello World", "World", "CPI"
Output: "Hello CPI"
exists
Purpose: Checks if node exists
Usage: exists(node)
Returns: Boolean indicating existence
splitByValue
Purpose: Splits values based on delimiter
Usage: splitByValue(input, delimiter)
Example:
Input: "A,B,C", ","
Output: ["A", "B", "C"]
collapseContexts
Purpose: Combines multiple contexts
Usage: collapseContexts(input)
Process:
Context1: [A, B] → Combined: [A, B, C, D]
Context2: [C, D] →
useOneAsMany
Purpose: Replicates single value for multiple contexts
Usage: useOneAsMany(singleValue, multipleContext)
Application: Value replication across contexts
sort
Purpose: Sorts values in ascending order
Usage: sort(input)
Example:
Input: [3, 1, 4, 2]
Output: [1, 2, 3, 4]
sortByKey
Purpose: Sorts based on key values
Usage: sortByKey(input, key)
Application: Complex sorting scenarios
mapWithDefault
Purpose: Maps values with default fallback
Usage: mapWithDefault(input, mapping, default)
Example:
Input: "Unknown", mapping_table, "DEFAULT"
Output: "DEFAULT"
formatByExample
Purpose: Formats values based on example pattern
Usage: formatByExample(input, example)
Application: Pattern-based formatting
7. Statistic Functions
Core Purpose
Statistic functions perform calculations on collections of values.
sum
Purpose: Calculates sum of numeric values
Usage: sum(values)
Example:
Input: [10, 20, 30]
Output: 60
average
Purpose: Calculates arithmetic mean
Usage: average(values)
Example:
Input: [10, 20, 30]
Output: 20
count
Purpose: Counts number of elements
Usage: count(input)
Example:
Input: [A, B, C, D]
Output: 4
index
Purpose: Returns element at specific index
Usage: index(input, position)
Example:
Input: [A, B, C], 1
Output: B
8. Text Functions
Core Purpose
Text functions manipulate and analyze string data.
concat
Purpose: Concatenates strings
Usage: concat(string1, string2, ...)
Example:
Input: "Hello", " ", "World"
Output: "Hello World"
substring
Purpose: Extracts substring
Usage: substring(string, startIndex, length)
Example:
Input: "Hello World", 0, 5
Output: "Hello"
equals (string)
Purpose: Compares strings for equality
Usage: equals(string1, string2)
Example:
Input: "ABC", "ABC"
Output: true
indexOf (2 parameters)
Purpose: Finds first occurrence of substring
Usage: indexOf(string, substring)
Example:
Input: "Hello World", "World"
Output: 6
indexOf (3 parameters)
Purpose: Finds occurrence starting from position
Usage: indexOf(string, substring, startPosition)
Example:
Input: "Hello Hello", "Hello", 1
Output: 6
lastIndexOf (2 parameters)
Purpose: Finds last occurrence of substring
Usage: lastIndexOf(string, substring)
Example:
Input: "Hello Hello", "Hello"
Output: 6
lastIndexOf (3 parameters)
Purpose: Finds last occurrence before position
Usage: lastIndexOf(string, substring, endPosition)
compare
Purpose: Compares strings lexicographically
Usage: compare(string1, string2)
Returns: -1, 0, or 1
replaceString
Purpose: Replaces occurrences of substring
Usage: replaceString(string, oldSubstring, newSubstring)
Example:
Input: "Hello World", "World", "CPI"
Output: "Hello CPI"
length
Purpose: Returns string length
Usage: length(string)
Example:
Input: "Hello"
Output: 5
endsWith
Purpose: Checks if string ends with suffix
Usage: endsWith(string, suffix)
Example:
Input: "[Link]", ".txt"
Output: true
startsWith (2 parameters)
Purpose: Checks if string starts with prefix
Usage: startsWith(string, prefix)
Example:
Input: "Hello World", "Hello"
Output: true
startsWith (3 parameters)
Purpose: Checks prefix starting from position
Usage: startsWith(string, prefix, position)
toUpperCase
Purpose: Converts to uppercase
Usage: toUpperCase(string)
Example:
Input: "hello world"
Output: "HELLO WORLD"
trim
Purpose: Removes leading and trailing whitespace
Usage: trim(string)
Example:
Input: " Hello World "
Output: "Hello World"
Implementation Steps
Step 1: Access Message Mapping
1. Open SAP CPI
2. Navigate to your Integration Flow
3. Open Message Mapping artifact
Step 2: Select Function
1. Expand Functions palette
2. Choose appropriate category
3. Drag function to mapping area
Step 3: Configure Parameters
1. Connect source fields to function inputs
2. Set constant parameters if required
3. Configure additional settings
Step 4: Connect Output
1. Link function output to target field
2. Test mapping with sample data
3. Validate transformation results
Step 5: Deploy and Test
1. Save mapping changes
2. Deploy integration flow
3. Test with real data scenarios
Best Practices
Performance Considerations
Use appropriate functions for data types
Minimize nested function calls
Consider memory usage for large datasets
Error Handling
Validate input parameters
Use conditional functions for null checks
Implement fallback mechanisms
Maintenance
Document complex mappings
Use meaningful function combinations
Test with edge cases
Common Use Cases
Data Transformation Patterns
Source System → Pallet Functions → Target System
↓ ↓ ↓
Raw Data → Transformation Logic → Formatted Data
Example Scenarios
1. Currency Conversion: Using arithmetic functions with value mapping
2. Date Standardization: Combining date functions for format consistency
3. Text Processing: Using string functions for data cleansing
4. Conditional Logic: Implementing business rules with boolean functions
5. Data Aggregation: Using statistic functions for summaries
This comprehensive guide provides the foundation for effectively utilizing CPI pallet functions in
your integration scenarios.