0% found this document useful (0 votes)
5 views9 pages

String Functions

The document outlines various string functions and operations available in SAP ABAP for manipulating strings, including concatenation, substring extraction, searching, and replacing. It details key functions like CONCATENATE, FIND, REPLACE, and SPLIT, along with their syntax and usage. Additionally, it mentions support for regular expressions and modern string templates for enhanced string processing.

Uploaded by

vyt30010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views9 pages

String Functions

The document outlines various string functions and operations available in SAP ABAP for manipulating strings, including concatenation, substring extraction, searching, and replacing. It details key functions like CONCATENATE, FIND, REPLACE, and SPLIT, along with their syntax and usage. Additionally, it mentions support for regular expressions and modern string templates for enhanced string processing.

Uploaded by

vyt30010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

String Functions :

String functions are used to manipulate and process


strings. ABAP provides a variety of built-in string
functions and operations to perform tasks like
concatenation, searching, replacing, extracting
substrings, and more.

Key String Functions and Operations in SAP ABAP


1. String Operations : These are basic operations for
string manipulation, often used with string variables
(TYPE STRING or TYPE C).
CONCATENATE: Concatenates multiple strings into
one, with an optional separator.
Syntax: CONCATENATE str1 str2 ... INTO result
[SEPARATED BY sep].
sep : Space / Any Symbol.
Concatenation(&&) : Concatenates two strings.
Syntax: result = string1 && string2.

Note : The above Syntax is fully supported in modern


SAP ABAP programming, including in the ABAP Cloud
Environment and on-premise S/4HANA with ABAP
version 7.40 and above.

String Length(STRLEN( )): Returns the length of a


string (excluding trailing blanks for TYPE C).
Substring Extraction:
SUBSTRING( ): Extracts a portion of a string
based on offset and length.
Syntax: result = SUBSTRING( val = string
off = n len = m ).

Old Syntax (Offset-Based): Use string+n(m) to


extract m characters starting from position n.
Search for Substring:
FIND: Searches for a substring in a string and
returns its position (0-based index).
Syntax: FIND substring IN string [IGNORING
CASE] [MATCH OFFSET offset] [MATCH
LENGTH length].

Replace Substring:
REPLACE: Replaces occurrences of a substring
with another string.
Syntax: REPLACE [ALL OCCURRENCES OF]
substring IN string WITH new
[IGNORING CASE].
Shift String:
SHIFT: Shifts characters in a string left or right,
optionally deleting specific characters.
Syntax: SHIFT string [LEFT|RIGHT]
[BY n PLACES]
[DELETING LEADING|TRAILING char].

Condense:
CONDENSE: Removes leading and trailing blanks
and optionally reduces multiple blanks to a single
blank.
Syntax: CONDENSE string [NO-GAPS].
Translate (Case Conversion):
TO_UPPER / TO_LOWER: Converts a string to
uppercase or lowercase.
Syntax: result = TO_UPPER( string ) or
result = TO_LOWER( string ).

TRANSLATE(older method):
Syntax: TRANSLATE string TO
UPPER CASE | LOWER CASE.
Split String:
SPLIT: Splits a string into multiple parts based on
a delimiter.
Syntax: SPLIT string AT delimiter INTO
result1 result2 ... | TABLE itab.

NUMOFCHAR( ): Counts the number of characters


(similar to STRLEN for TYPE STRING).
2. String Comparison
Relational Operators: Use CO (contains only), CA
(contains any), CS (contains string), CP (contains
pattern) for string comparisons.
3. Regular Expressions
ABAP supports regular expressions for advanced
string processing using FIND and REPLACE with the
REGEX addition.

4. String Templates (Modern ABAP):

Use string templates (|...|) for formatting and embedding


expressions.

Syntax: result = |{ variable } text { expression }|.

You might also like