GoodleAds

CHANGE CHARACTERS IN A STRING (TRANSLATE)

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
*-------------------------------------------------------------
DATAld_date(10TYPE c.

ld_date 
'28.10.1979'.

*Finds all occurences of first char(.) & replaces them with second(-)
TRANSLATE ld_date USING '.-'.
WRITEld_date.

*Code to demonstrate TRANSLATE to UPPER/LOWER CASE command
*---------------------------------------------------------
DATAld_char(20TYPE c.

ld_char 
'Hello World'.
TRANSLATE ld_char TO UPPER CASE.
WRITE:/ ld_char.
TRANSLATE ld_char TO LOWER CASE.
WRITE:/ ld_char.



OUTPUT:




No comments:

Post a Comment