Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

removing special characters

Former Member
0 Likes
1,137

Hi,

I have to remove special characters from string and replace it with space.

Kindly help its urgent.

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
735

Hi i can explain this with an example.

Write a program to give input as “+91-44-42040260”, output should be “ 91 44 42040260”.

Ans :

DATA:INPUT(15) VALUE '+91-44-42040260',

STR(4) VALUE '+ - '.

TRANSLATE INPUT USING STR.

WRITE:/ INPUT.

Please reward if helpful.

Hi,

I have to remove special characters from string and replace it with space.

Kindly help its urgent.

Thanks

4 REPLIES 4
Read only

Former Member
0 Likes
736

Hi i can explain this with an example.

Write a program to give input as “+91-44-42040260”, output should be “ 91 44 42040260”.

Ans :

DATA:INPUT(15) VALUE '+91-44-42040260',

STR(4) VALUE '+ - '.

TRANSLATE INPUT USING STR.

WRITE:/ INPUT.

Please reward if helpful.

Read only

Former Member
0 Likes
735

Hi,

You Can use Overlay command for this.

Syntax

OVERLAY text1 WITH text2 [ONLY pattern].

Effect

Characters in the text1 variable are replaced by characters in the text2 data object which are there in the same location. If the ONLY addition is not specified, all blank characters in text1 are replaced. If the ONLY addition is specified, all characters are replaced that occur in the pattern data object, and upper and lowercase is taken into consideration. If the lengths of text1 and text2 are different, text1 is processed using the shorter length only.

CONSTANTS initial_time TYPE t VALUE IS INITIAL.

DATA: time TYPE t,

text(4) TYPE c.

text = '12'.

time = text.

write : time.

Thanks,

Reward If Helpful.

Read only

abdulazeez12
Active Contributor
0 Likes
735

declare a constant that has all the special characters like

gc_spl(20) type c value '!@#$%....'

if string CA gc_spl.

string+0(sy-fdpos) = space.

endif.

Read only

Former Member
0 Likes
735

Hi.

null