String manipulations

Concatenation

Concatenate integers with strings:

REPORT  zconcatenate_int_string.
DATA:
      lv_string TYPE string,
      lv_int TYPE i VALUE 9.
 
*CONCATENATE works with string only.
* Therefore, you must cast the integer as a string 
*   by assigning the integer variable into a string variable.
lv_string = lv_int.
CONCATENATE 'The value is:' lv_string INTO lv_string.
 
WRITE: / lv_string.

Trimming

Remove leading and trailing spaces:

REPORT  Z_REMOVE_SPACES.
 
DATA: STR TYPE STRING.
STR = ' Hello, world ! '.
 
* Display the initial string with spaces.
WRITE:/ '|',STR,'|'.
 
* Remove space leading and trailing spaces from the string.
SHIFT STR LEFT DELETING LEADING SPACE.
SHIFT STR RIGHT DELETING TRAILING SPACE.
 
* Display end result.
WRITE:/ '|',STR,'|'.