Change characters within a string ( TRANSLATE )

The translate command allows you to convert characters within a string from one character to another.

i.e. Convert 28.10.1979 to 28-10-1979 Convert to UPPER/LOWER CASE

*Code to Replace one char with another using TRANSLATE command
*-------------------------------------------------------------
DATA: ld_date(10) type c.
ld_date = '28.10.1979'.
*Finds all occurences of first char(.) & replaces them with second(-)
TRANSLATE ld_date using '.-'.
*ld_date will now contain '28-10-1979'

*Code to demonstrate TRANSLATE to UPPER/LOWER CASE command
*---------------------------------------------------------
DATA: ld_char(20) type c.
ld_char = 'Hello World'.
TRANSLATE ld_char TO UPPER CASE. "Result: ld_char = 'HELLO WORLD'
TRANSLATE ld_char TO LOWER CASE. "Result: ld_char = 'hello world'

Related Articles

Data manipulation - Example code and information on various data manipulation techniques
Retrun the fraction / whole value of a decimal number using MOD, DIV, FRAC or SHIFT
Remove spaces from character field (CONDENSE)
Move minus sign(-) from end to start of field
ABAP Round functionality to round values down to nearest value based on your decimal place requirement
Round ABAP values up to the nearest value
Inserting TAB's into text strings