SAP Build Apps Functions – “Text” of all formulas available for Data Transformation

Estimated read time 15 min read

SAP Build Apps is a powerful low-code platform that enables users to create robust applications with minimal coding. One of the key features of SAP Build Apps is its ability to use functions and formulas to manipulate and transform data dynamically. In this blog, we’ll explore when to use these functions and how to get the desired output from formulas.

Understanding SAP Build Apps Functions

Functions in SAP Build Apps are predefined operations that can be used to perform specific tasks within your application. These functions can range from simple arithmetic operations to complex data manipulations. Here are some common scenarios where you might need to use functions:

Data Validation: Ensuring that user inputs meet certain criteria before processing.Data Transformation: Converting data from one format to another, such as changing date formats or calculating derived values.Conditional Logic: Implementing if-else conditions to control the flow of your application based on specific criteria.

Using the Formula Editor

The Formula Editor in SAP Build Apps is a powerful tool that allows you to create and apply formulas to your data. It combines spreadsheet-like formulas with built-in support for application context, making it easy to create complex algorithms. Here’s how to get started:

Function NameFormulaFormula DescriptionExamples with ResultTEXTAPPEND_URL_PARAMETERSAppends the given URL parameters (given as a dictionary object) to the URL text. Can result in multiple URL parameters of the same name.APPEND_URL_PARAMETERS(“http://www.example.com“, { test1: “abc”, test2: 123})
=”http://www.example.com/?test1=abc&test2=123

APPEND_URL_PARAMETERS(“http://www.example.com/?abc=123&test=abc“, { test1: “abc”, test2: 123})
=”http://www.example.com/?abc=123&test=abc&test1=abc&test2=123

APPEND_URL_PARAMETERS(“http://www.example.com/?abc=123&test=abc“, {})
=”http://www.example.com/?abc=123&test=abc“TEXTCAPITALIZECapitalizes each word in a specified text so that they start with a upper-case letter, leaving all other letters lower-case.CAPITALIZE(“foobar”)
=”FooBar”

CAPITALIZE(“Foo Bar”)
=”Foo Bar”

CAPITALIZE(“fOoO baAaR”)
=”Fooo Baaar”TEXTCONTAINSReturns TRUE,  if the given text contains the given slice of text, otherwise returns  FALSECONTAINS(“Foo Bar”, “Foo”)
=true

CONTAINS(“Foo Bar”, “foo”)
=false

CONTAINS(“Foo Bar”, “o B”)
=trueTEXTFORMAT_LOCALIZED_DECIMALReturns a text with a language-/locale-sensitive representation of the given decimal number.FORMAT_LOCALIZED_DECIMAL(123450.673, “ru-RU”, 2)
=”123 450,67″

FORMAT_LOCALIZED_DECIMAL(123450.673, “en-IN”, 4)
=”1,23,450.6730″

FORMAT_LOCALIZED_DECIMAL(123450.673, “de-CH”, 3)
=”123’456.073)

FORMAT_LOCALIZED_DECIMAL(1234.5678, “fi-FI”, 3, 😎
=”1 234,5678″TEXTGENERATE_UUIDGenerate and return a v4-type UUID.
Please note that this function is not “cryptographically secure”, and should not be used in situations where that is required.GENERATE_UUID()
=”bd177959-6ba1-46ec-9e63-ea1ab70d8b2d”

GENERATE_UUID()
=”957b9ffd-c6ce-47b3-abbd-66db6f51f2df”TEXTJOINJoins a list of component texts into a single concatenated text, with each component text separated by the optional separator parameter.JOIN([“a”, “b”, “c”], “, “)
=”a, b, c”

JOIN([], “”)
=””TEXTLEFT_PADReturns the given text with extra left padding, if needed, to bring its total number of characters to at least the value of the width parameter.
LEFT_PAD(“foo”, 5)
=” foo”

LEFT_PAD(“foo”, 6, “ABC”)
=”ABCfoo”

LEFT_PAD(“foo”, 7, “ABC”)
=”ABCfoo”TEXTLEFT_STRIPReturns text with number of characters stripped from the beginning of the text.LEFT_STRIP(“foo bar”, 4)
=”bar”

LEFT_STRIP(“foo bar”, 2)
=”o bar”

LEFT_STRIP(“foo bar”, -1)
=”foo bar”TEXTLENGTHReturns the number of characters in the given text.LENGTH(“Foobar”)
=6

LENGTH(“”)
=0TEXTLOWERCASEConverts each character of the given text to lower-case letters.LOWERCASE(“FOOBAR”)
=”foobar”

LOWERCASE(“Foo Bar”)
=”foo bar”TEXTMATCHES_REGEX Returns TRUE if text is matched by the given regular expression pattern, otherwise returns FALSEMATCHES_REGEX(“Foo Bar”, “^Foo”)
=true

MATCHES_REGEX(“Foo Bar”, “^foo”)
=false

MATCHES_REGEX(“Foo Bar”, “o B”)
=true

MATCHES_REGEX(“Foo Bar”, “[a-zA-Z]+”)
=trueTEXTQUERY_PARAMETERS_ARRAYGiven an URL, return its query parameters as an object with schema:
{ param1Key: param1Value, param2Key: param2Value }
Numbers and booleans are parsed to their correct types.QUERY_PARAMETERS_ARRAY(“https://api.myapp.com/leads?search=all&limit=20“)
=[
    {
        “key”: “limit”,
        “value”: “20”
    },
    {
        “key”: “search”,
        “value”: “all”
    }
]

QUERY_PARAMETERS_ARRAY(“http://example.com/path?name=Branch&products=Journeys&products=Email&products=Universal%20Ads“)
=[
    {
        “key”: “name”,
        “value”: “Branch”
    },
    {
        “key”: “products”,
        “value”: “Journeys”
    },
    {
        “key”: “products”,
        “value”: “Email”
    },
    {
        “key”: “products”,
        “value”: “Universal Ads”
    }
]TEXTQUERY_PARAMETERS_OBJECTGiven an URL, return its query parameters as an object with schema:
{ param1Key: param1Value, param2Key: param2Value }
Numbers and booleans are parsed to their correct types.QUERY_PARAMETERS_OBJECT(“https://api.myapp.com/leads?search=all&limit=20“)
={
    “limit”: “20”,
    “search”: “all”
}

QUERY_PARAMETERS_OBJECT(“http://example.com/path?name=Branch&products=Journeys&products=Email&products=Universal%20Ads“)
={
    “name”: “Branch”,
    “products”: “Universal Ads”
}TEXTREPLACE_ALLReturns a new text where all occurrences of the given text are replaced with the given replacement text.REPLACE_ALL(“foo bar baz”, “bar”, “baz”)
=”foo baz baz”

REPLACE_ALL(“foo foo baz”, “foo”, “bar”)
=”foo bar baz”

REPLACE_ALL(“foo bar”, “baz”, “bar”)
=”foo bar”TEXTREPLACE_ALL_REGEX REPLACE_ALL_REGEX(“foo bar”, “[a-zA-Z]+”, “xxxx”)TEXTREPLACE_ONEReturns a new text where the first occurence of the given text are replaced with the given replacement text.REPLACE_ONE(“foo bar baz”, “bar”, “baz”)
=”foo bar baz”

REPLACE_ONE(“foo foo baz”, “foo”, “bar”)
=”foo foo baz”

REPLACE_ONE(“foo bar”, “baz”, “bar”)
=”foo bar”TEXTREPLACE_ONE_REGEXReturns a new text where the first match for the given regular exprssion is replaced with the given replacement text.REPLACE_ONE_REGEX(“foo bar”, “[a-zA-Z]+”, “xxxx”)
=”xxxx bar”

REPLACE_ONE_REGEX(“foo foo foo”, “^foo”, “bar”)
=”bar foo foo”

REPLACE_ONE_REGEX(“foo foo baz”, “\s”, “-“)
=”foo-foo baz”TEXTREPLACE_URL_PARAMETERSSets the given URL texts query parameters to the given parameter object.
RIGHT_PAD(“foo”, 5)
=”foo “

RIGHT_PAD(“foo”, 5, “a”)
=”fooaa”

RIGHT_PAD(“foo”, 7, “ABC”)
=”fooABCA”TEXTRIGHT_PADReturns the given text with extra right padding, if needed, to bring its total number of characters to at least the value of the width parameter.
RIGHT_PAD(“foo”, 5)
=”foo “

RIGHT_PAD(“foo”, 5, “a”)
=”fooaa”

RIGHT_PAD(“foo”, 7, “ABC”)
=”fooABCA”TEXTRIGHT_STRIPReturns text with number of characters stripped from the end of the text.RIGHT_STRIP(“foo bar”, 4)
=”foo”

RIGHT_STRIP(“foo bar”, 2)
=”foo b”

RIGHT_STRIP(“foo bar”, -1)
=”foo bar”TEXTSPLITSplits a text into a list of sliced texts. The separator parameter specifies the characters within the text at which the splits will be done. If the separator is an empty text, the result is an array of single characters.

SPLIT(“Foo Bar”, ” “)
=[“Foo”,”Bar”]

SPLIT(“Foo”, “”)
=[“F”, “o”, “o”]

SPLIT(“Foo Bar”, “bbb”)
=[“Foo Bar”]

SPLIT(“Foo Bar Baz xxx”, ” “, 3)
=[ “Foo”, “Bar”, “Baz xxx” ]TEXTSTRIP_HTML_TAGSReturns the given text wih all HTML tags stripped away.html = “<div class=”test”><span >123<br/>456</span ></div>”

STRIP_HTML_TAGS(html)
=”1213456″

STRIP_HTML_TAGS(html, true)
=”123n456″TEXTSUBSTRINGReturns a slice of the given text between the given indices.The slice of text starts at (and includes) the index given as the 2nd parameter. It ends at (and excludes) the index given as the 3rd parameter.If both indices are the same, the function returns an empty text. Negative indices are counted backwards, starting from the end of the text.SUBSTRING(“foo bar”, 0, 3)
=”foo”

SUBSTRING(“foo bar”, 4)
=”bar”

SUBSTRING(“foo bar”, 0, -1)
=”foo ba”TEXTTRIM_WHITESPACERemoves all whitespace characters at the beginning and at the end of the given text. This includes any tab characters and newlines. Returns the trimmed text.

TRIM_WHITESPACE(”  foobar  “)
=”foobar”

TRIM_WHITESPACE(“tfoobart”)
=”foobar”

TRIM_WHITESPACE(“nfoobarn”)
=”foobar”TEXTTRUNCATEIf the given text is longer than the given length parameter, it is shortened and appended with an ellipsis character, so that the resultant text length is always less or equal than the given length parameter. Returns the truncated text.TRUNCATE(“Wissenschaft is a science”, 5)
=”Wiss”

TRUNCATE(“This is a simple text”, 4)
=”Thi …”

TRUNCATE(“This is a simple text”, 4, “…”)
=”T…”

TRUNCATE(“This is a simple text”, 4, “”)
=”This”TEXTUPPERCASEConverts all characters of the given text to upper-case letters.UPPERCASE(“foobar”)
=”FOOBAR”

UPPERCASE(“Foo Bar”)
=”FOO BAR”

I will continue to write a next blog with New function and New formulas, Keep watching the blog…

Conclusion

Using functions and formulas in SAP Build Apps can significantly enhance the functionality and user experience of your applications. By understanding when and how to use these tools, you can efficiently transform data and implement complex logic without extensive coding. Experiment with different functions and formulas to see how they can best serve your application needs.

 

​ SAP Build Apps is a powerful low-code platform that enables users to create robust applications with minimal coding. One of the key features of SAP Build Apps is its ability to use functions and formulas to manipulate and transform data dynamically. In this blog, we’ll explore when to use these functions and how to get the desired output from formulas.Understanding SAP Build Apps FunctionsFunctions in SAP Build Apps are predefined operations that can be used to perform specific tasks within your application. These functions can range from simple arithmetic operations to complex data manipulations. Here are some common scenarios where you might need to use functions:Data Validation: Ensuring that user inputs meet certain criteria before processing.Data Transformation: Converting data from one format to another, such as changing date formats or calculating derived values.Conditional Logic: Implementing if-else conditions to control the flow of your application based on specific criteria.Using the Formula EditorThe Formula Editor in SAP Build Apps is a powerful tool that allows you to create and apply formulas to your data. It combines spreadsheet-like formulas with built-in support for application context, making it easy to create complex algorithms. Here’s how to get started:Function NameFormulaFormula DescriptionExamples with ResultTEXTAPPEND_URL_PARAMETERSAppends the given URL parameters (given as a dictionary object) to the URL text. Can result in multiple URL parameters of the same name.APPEND_URL_PARAMETERS(“http://www.example.com”, { test1: “abc”, test2: 123})=”http://www.example.com/?test1=abc&test2=123″APPEND_URL_PARAMETERS(“http://www.example.com/?abc=123&test=abc”, { test1: “abc”, test2: 123})=”http://www.example.com/?abc=123&test=abc&test1=abc&test2=123″APPEND_URL_PARAMETERS(“http://www.example.com/?abc=123&test=abc”, {})=”http://www.example.com/?abc=123&test=abc”TEXTCAPITALIZECapitalizes each word in a specified text so that they start with a upper-case letter, leaving all other letters lower-case.CAPITALIZE(“foobar”)=”FooBar”CAPITALIZE(“Foo Bar”)=”Foo Bar”CAPITALIZE(“fOoO baAaR”)=”Fooo Baaar”TEXTCONTAINSReturns TRUE,  if the given text contains the given slice of text, otherwise returns  FALSECONTAINS(“Foo Bar”, “Foo”)=trueCONTAINS(“Foo Bar”, “foo”)=falseCONTAINS(“Foo Bar”, “o B”)=trueTEXTFORMAT_LOCALIZED_DECIMALReturns a text with a language-/locale-sensitive representation of the given decimal number.FORMAT_LOCALIZED_DECIMAL(123450.673, “ru-RU”, 2)=”123 450,67″FORMAT_LOCALIZED_DECIMAL(123450.673, “en-IN”, 4)=”1,23,450.6730″FORMAT_LOCALIZED_DECIMAL(123450.673, “de-CH”, 3)=”123’456.073)FORMAT_LOCALIZED_DECIMAL(1234.5678, “fi-FI”, 3, 😎=”1 234,5678″TEXTGENERATE_UUIDGenerate and return a v4-type UUID.Please note that this function is not “cryptographically secure”, and should not be used in situations where that is required.GENERATE_UUID()=”bd177959-6ba1-46ec-9e63-ea1ab70d8b2d”GENERATE_UUID()=”957b9ffd-c6ce-47b3-abbd-66db6f51f2df”TEXTJOINJoins a list of component texts into a single concatenated text, with each component text separated by the optional separator parameter.JOIN([“a”, “b”, “c”], “, “)=”a, b, c”JOIN([], “”)=””TEXTLEFT_PADReturns the given text with extra left padding, if needed, to bring its total number of characters to at least the value of the width parameter.LEFT_PAD(“foo”, 5)=” foo”LEFT_PAD(“foo”, 6, “ABC”)=”ABCfoo”LEFT_PAD(“foo”, 7, “ABC”)=”ABCfoo”TEXTLEFT_STRIPReturns text with number of characters stripped from the beginning of the text.LEFT_STRIP(“foo bar”, 4)=”bar”LEFT_STRIP(“foo bar”, 2)=”o bar”LEFT_STRIP(“foo bar”, -1)=”foo bar”TEXTLENGTHReturns the number of characters in the given text.LENGTH(“Foobar”)=6LENGTH(“”)=0TEXTLOWERCASEConverts each character of the given text to lower-case letters.LOWERCASE(“FOOBAR”)=”foobar”LOWERCASE(“Foo Bar”)=”foo bar”TEXTMATCHES_REGEX Returns TRUE if text is matched by the given regular expression pattern, otherwise returns FALSEMATCHES_REGEX(“Foo Bar”, “^Foo”)=trueMATCHES_REGEX(“Foo Bar”, “^foo”)=falseMATCHES_REGEX(“Foo Bar”, “o B”)=trueMATCHES_REGEX(“Foo Bar”, “[a-zA-Z]+”)=trueTEXTQUERY_PARAMETERS_ARRAYGiven an URL, return its query parameters as an object with schema:{ param1Key: param1Value, param2Key: param2Value }Numbers and booleans are parsed to their correct types.QUERY_PARAMETERS_ARRAY(“https://api.myapp.com/leads?search=all&limit=20”)=[    {        “key”: “limit”,        “value”: “20”    },    {        “key”: “search”,        “value”: “all”    }]QUERY_PARAMETERS_ARRAY(“http://example.com/path?name=Branch&products=Journeys&products=Email&products=Universal%20Ads”)=[    {        “key”: “name”,        “value”: “Branch”    },    {        “key”: “products”,        “value”: “Journeys”    },    {        “key”: “products”,        “value”: “Email”    },    {        “key”: “products”,        “value”: “Universal Ads”    }]TEXTQUERY_PARAMETERS_OBJECTGiven an URL, return its query parameters as an object with schema:{ param1Key: param1Value, param2Key: param2Value }Numbers and booleans are parsed to their correct types.QUERY_PARAMETERS_OBJECT(“https://api.myapp.com/leads?search=all&limit=20”)={    “limit”: “20”,    “search”: “all”}QUERY_PARAMETERS_OBJECT(“http://example.com/path?name=Branch&products=Journeys&products=Email&products=Universal%20Ads”)={    “name”: “Branch”,    “products”: “Universal Ads”}TEXTREPLACE_ALLReturns a new text where all occurrences of the given text are replaced with the given replacement text.REPLACE_ALL(“foo bar baz”, “bar”, “baz”)=”foo baz baz”REPLACE_ALL(“foo foo baz”, “foo”, “bar”)=”foo bar baz”REPLACE_ALL(“foo bar”, “baz”, “bar”)=”foo bar”TEXTREPLACE_ALL_REGEX REPLACE_ALL_REGEX(“foo bar”, “[a-zA-Z]+”, “xxxx”)TEXTREPLACE_ONEReturns a new text where the first occurence of the given text are replaced with the given replacement text.REPLACE_ONE(“foo bar baz”, “bar”, “baz”)=”foo bar baz”REPLACE_ONE(“foo foo baz”, “foo”, “bar”)=”foo foo baz”REPLACE_ONE(“foo bar”, “baz”, “bar”)=”foo bar”TEXTREPLACE_ONE_REGEXReturns a new text where the first match for the given regular exprssion is replaced with the given replacement text.REPLACE_ONE_REGEX(“foo bar”, “[a-zA-Z]+”, “xxxx”)=”xxxx bar”REPLACE_ONE_REGEX(“foo foo foo”, “^foo”, “bar”)=”bar foo foo”REPLACE_ONE_REGEX(“foo foo baz”, “\s”, “-“)=”foo-foo baz”TEXTREPLACE_URL_PARAMETERSSets the given URL texts query parameters to the given parameter object.RIGHT_PAD(“foo”, 5)=”foo “RIGHT_PAD(“foo”, 5, “a”)=”fooaa”RIGHT_PAD(“foo”, 7, “ABC”)=”fooABCA”TEXTRIGHT_PADReturns the given text with extra right padding, if needed, to bring its total number of characters to at least the value of the width parameter.RIGHT_PAD(“foo”, 5)=”foo “RIGHT_PAD(“foo”, 5, “a”)=”fooaa”RIGHT_PAD(“foo”, 7, “ABC”)=”fooABCA”TEXTRIGHT_STRIPReturns text with number of characters stripped from the end of the text.RIGHT_STRIP(“foo bar”, 4)=”foo”RIGHT_STRIP(“foo bar”, 2)=”foo b”RIGHT_STRIP(“foo bar”, -1)=”foo bar”TEXTSPLITSplits a text into a list of sliced texts. The separator parameter specifies the characters within the text at which the splits will be done. If the separator is an empty text, the result is an array of single characters.SPLIT(“Foo Bar”, ” “)=[“Foo”,”Bar”]SPLIT(“Foo”, “”)=[“F”, “o”, “o”]SPLIT(“Foo Bar”, “bbb”)=[“Foo Bar”]SPLIT(“Foo Bar Baz xxx”, ” “, 3)=[ “Foo”, “Bar”, “Baz xxx” ]TEXTSTRIP_HTML_TAGSReturns the given text wih all HTML tags stripped away.html = “<div class=”test”><span >123<br/>456</span ></div>”STRIP_HTML_TAGS(html)=”1213456″STRIP_HTML_TAGS(html, true)=”123n456″TEXTSUBSTRINGReturns a slice of the given text between the given indices.The slice of text starts at (and includes) the index given as the 2nd parameter. It ends at (and excludes) the index given as the 3rd parameter.If both indices are the same, the function returns an empty text. Negative indices are counted backwards, starting from the end of the text.SUBSTRING(“foo bar”, 0, 3)=”foo”SUBSTRING(“foo bar”, 4)=”bar”SUBSTRING(“foo bar”, 0, -1)=”foo ba”TEXTTRIM_WHITESPACERemoves all whitespace characters at the beginning and at the end of the given text. This includes any tab characters and newlines. Returns the trimmed text.TRIM_WHITESPACE(”  foobar  “)=”foobar”TRIM_WHITESPACE(“tfoobart”)=”foobar”TRIM_WHITESPACE(“nfoobarn”)=”foobar”TEXTTRUNCATEIf the given text is longer than the given length parameter, it is shortened and appended with an ellipsis character, so that the resultant text length is always less or equal than the given length parameter. Returns the truncated text.TRUNCATE(“Wissenschaft is a science”, 5)=”Wiss”TRUNCATE(“This is a simple text”, 4)=”Thi …”TRUNCATE(“This is a simple text”, 4, “…”)=”T…”TRUNCATE(“This is a simple text”, 4, “”)=”This”TEXTUPPERCASEConverts all characters of the given text to upper-case letters.UPPERCASE(“foobar”)=”FOOBAR”UPPERCASE(“Foo Bar”)=”FOO BAR”I will continue to write a next blog with New function and New formulas, Keep watching the blog…ConclusionUsing functions and formulas in SAP Build Apps can significantly enhance the functionality and user experience of your applications. By understanding when and how to use these tools, you can efficiently transform data and implement complex logic without extensive coding. Experiment with different functions and formulas to see how they can best serve your application needs.   Read More Technology Blogs by SAP articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author