Strings, which are widely used in ABAP programming, are a sequence of characters.

We use data type C variables for holding alphanumeric characters, with a minimum of 1 character and a maximum of 65,535 characters. By default, these are aligned to the left.

Creating Strings


The following declaration and initialization creates a string consisting of the word 'Hello'. The size of the string is exactly the number of characters in the word 'Hello'.

Data my_Char(5) VALUE 'Hello'.

Following program is an example of creating strings.

REPORT YT_SEP_15.
DATA my_Char(5) VALUE 'Hello'.
Write my_Char.

The above code produces the following output −

Hello


String Length


In order to find the length of character strings, we can use STRLEN statement. The STRLEN () function returns the number of characters contained in the string.

Example:

REPORT YT_SEP_15.
DATA: title_1(10) VALUE 'Tutorials',
      length_1 TYPE I.

length_1 = STRLEN( title_1 ).
Write: / 'The Length of the Title is:', length_1.

The above code produces the following output.

The Length of the Title is: 9

ABAP supports a wide range of statements that manipulate strings.

Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP S/4 HANA Logistics Team Lead
Contact : serkurumsal@yandex.com



S.No. Statement & Purpose
1 CONCATENATE
Two strings are joined to form a third string.
2 CONDENSE
This statement deletes the space characters.
3 STRLEN
Used to find the length of a field.
4 REPLACE
Used to make replacements in characters.
5 SEARCH
To run searches in character strings.
6 SHIFT
Used to move the contents of a string left or right.
7 SPLIT
Used to split the contents of a field into two or more fields.