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'
|