[ABAP] How do I manipulate strings in ABAP (e.g., concatenation, length)?
In ABAP, you can manipulate strings using various string functions and methods. Here are some examples of how to perform common string operations like concatenation and length calculation:
-
Concatenation:
- Using the
CONCATENATE
statement:1CONCATENATE 'Hello' 'World' INTO lv_string.
- Using the
&
operator:1lv_string = 'Hello' & 'World'.
- Using the
-
Length Calculation:
- Using the
STRLEN
function:1DATA(lv_length) = STRLEN( lv_string ).
- Using the
-
Substring Extraction:
- Using the
SUBSTRING
function:1DATA(lv_substring) = SUBSTRING( lv_string FROM 3 FOR 5 ).
- Using the
-
String Replacement:
- Using the
REPLACE
function:1DATA(lv_new_string) = REPLACE( lv_string 'old' 'new' ).
- Using the
-
Case Conversion:
- Using the
CONV
method:1DATA(lv_uppercase) = lv_string->CONV( |U| ).
- Using the
TRANSLATE
function:1DATA(lv_uppercase) = TRANSLATE( lv_string TO UPPER CASE ).
- Using the
-
Padding:
- Using the
CONCATENATE
statement:1CONCATENATE lv_string ' ' INTO lv_padded_string.
- Using the
CONDENSE
statement:1CONDENSE lv_string.
- Using the
These are just a few examples of string manipulation in ABAP. There are many more functions and methods available in the ABAP language for different string operations.