ABAP for Cloud Development, ©Copyright 2024 SAP SE. All rights reserved.
ABAP - Keyword Documentation → ABAP - Data Interfaces and Communication Interfaces → ABAP and XML → XML - Transformations → XSL Transformations → XSL - User-Defined Transformations → XSL - Functions →XSL - SAP Functions
In the following, enhanced SAP-specific functions of the SAP XSLT processor are listed. The URI for the SAP namespace is http://www.sap.com/sapxsl.
Numeric Functions
| Function | XPath 1.0 / XPath 2.0 | Description |
| sap:abs(number) | abs() | Returns the absolute value of the number. |
| sap:exp(number) | - | Returns the result of the exponential function. |
| sap:log(number) | - | Returns the result of the natural logarithm. |
| sap:log10(number) | - | Returns the result of the decimal logarithm. |
| sap:sqrt(number) | - | Returns the square root of the number. |
| sap:sin(number) | - | Returns the result of the sine function. |
| sap:cos(number) | - | Returns the result of the cosine function. |
| sap:tan(number) | - | Returns the result of the tangent function. |
| sap:asin(number) | - | Returns the result of the inverse sine function. |
| sap:acos(number) | - | Returns the result of the inverse cosine function. |
| sap:atan(number) | - | Returns the result of the inverse tangent function. |
String Functions
| Function | XPath 1.0 / XPath 2.0 | Description |
| sap:upper-case(string) | upper-case() | Converts the string to upper-case letters. |
| sap:lower-case(string) | lower-case() | Converts the string to lower-case letters. |
| sap:string-pad(string, number) | - | Returns the string as many times as the number represents. |
| sap:ends-with(string, string) | ends-with() | Returns true if the first string ends with the second string. Otherwise, it returns false. Note: Parameters as part of the collation URI are not supported. |
| sap:find-first(string, string[, number]) | - | Returns the first occurrence of the second string in the first string. If a number is specified, the search only starts at this position. |
| sap:find-last(string, string[, number]) | - | Returns the last occurrence of the second string in the first string. If a number is specified, the search ends at this position. |
| sap:find-first-of(string, string[, number]) | - | Returns the first occurrence of a character in the second string in the first string. If a number is specified, the search only starts at this position. |
| sap:find-first-not-of(string, string[, number]) | - | Returns the first occurrence of a character not in the second string in the first string. If a number is specified, the search only starts at this position. |
| sap:find-last-of(string, string[, number]) | - | Returns the last occurrence of a character in the second string in the first string. If a number is specified, the search ends at this position. |
| sap:find-last-not-of(string, string[, number]) | - | Returns the last occurrence of a character not in the second string in the first string. If a number is specified, the search ends at this position. |
| sap:escape-uri(string) | escape-uri() | Returns the URI unchanged. |
| sap:resolve-uri(string, string) | resolve-uri() | Resolves a relative URI reference against an absolute URI. The first string contains the base URI and the second string contains the relative URI. |
Node Set Functions
| Function | Description |
| sap:min(number|node-set, number|node-set) | Returns the minimum of two numbers or the minimum of the numerical values of a node set. |
| sap:max(number|node-set, number|node-set) | Returns the maximum of two numbers or the maximum of the numerical values of a node set. |
| sap:node-set(fragment) | Obsolete. Converts a fragment of the result tree into a node set. The resulting node set contains its own node, which is the fragment root. |
| sap:intersection(node-set, node-set) | Returns the intersection of two node sets. Example: sap:intersection(node-set1, node-set2) returns the intersection of the two node sets node-set1 and node-set2. |
Functions for the Online Text Repository
XSLT can be used to read texts of the Online Text Repository (OTR) and make output of XSLT programs multilingual.
| Function | Description |
| sap:otr-string() | Returns OTR strings. An alias name is used to identify a string. There are three variants: sap:otr-string(alias) returns OTR strings for an alias in the current language. sap:otr-string(alias, language) returns OTR strings for an alias in the specified language. sap:otr-string(alias, id_1, value_1, ..., id_n, value_n[, language]) returns OTR strings for an alias in the current or specified language. The corresponding placeholder id_i is replaced by the appropriate value value_i. A placeholder is specified either as a string (reference by name) or as a number (reference by position). |
| sap:otr-text() | Returns short texts from the OTR. An alias name is used to identify a short text (sap:otr-text(alias, ...)). In the case of sap:otr-string(), the language and placeholder can be specified as further function arguments. |
| sap:otr-line() | Returns the line number of the node from the current context. Example: sap:otr-line(node-set) returns the line number of the first node of the node set in the source document. |
| sap:otr-column() | Returns the column number of the node from the current context. Example: sap:otr-column(node-set) returns the column number of the first node of the node set in the source document. |
More Functions
| Function | XPath 1.0 / XPath 2.0 | Description |
| sap:if(object, object, object) | if() | Returns the second object if the first object is true. Otherwise, it returns the third object. Example: The function sap:if(x, e1, e2) returns e1 if x=true; else e2. |
| sap:let(object, object, object) | - | Displays the syntax of an extension function, but it is used as a construct for a variable bind.
sap:let(x, e1, e2) binds $x to e1
in e2. Example: sap:let(x, 4, $x + $x) returns 8. |
| sap:timestamp() | - | Returns a time stamp. |