CHANGE CHARACTERS IN A STRING USING 'TRANSLATE' :
The translate command allows you to convert characters within a string from one character to another.
PROGRAM:
*&---------------------------------------------------------------------*
*& Report Z_CHANGE_CHAR_IN_STRING
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT z_change_char_in_string.
*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 '.-'.
WRITE: ld_date.
*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.
WRITE:/ ld_char.
TRANSLATE ld_char TO LOWER CASE.
WRITE:/ ld_char.
OUTPUT:
The translate command allows you to convert characters within a string from one character to another.
PROGRAM:
*&---------------------------------------------------------------------*
*& Report Z_CHANGE_CHAR_IN_STRING
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT z_change_char_in_string.
*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 '.-'.
WRITE: ld_date.
*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.
WRITE:/ ld_char.
TRANSLATE ld_char TO LOWER CASE.
WRITE:/ ld_char.
OUTPUT: