Application Development 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: 

regarding removing special characters

rakesh_mandal
Explorer
0 Kudos


can anyone tell me the code to remove special characters but not spaces from fields in a report program

21 REPLIES 21

Former Member
0 Kudos

Hi Rakesh,

Data : lv_field type string value 'ABC123a$'.

Replace REGEX '[A-Za-z0-9]'  in lv_field with ''.

lv_field contains $'.

The above statement replaces letters A,B...Z or a,b,..z or numbers 0,1,..9 with Space.

To remove speacial characters include backslash character before special character, like to remove / symbol precede it with \/.

Regards,

Ravikiran.K

0 Kudos

Hi ravi,

thanks for ur reply.but my question is like a field value is-Ravi@48,7Kiran.i want to remove special characters so the desire output should be-Ravi 48 7Kiran.

0 Kudos

Hi Rakesh,

Data : lv_field type string value 'Ravi@48,7Kiran'.

OVERLAY lv_field WITH 'Ravi 48 7kiran' ONLY '@,'.

WRITE lv_field.

Regards,

Ravikiran.K

0 Kudos

Hi Ravi,

thanks ravi for the reply.but here you are working on a single value.i am working on 100 diff values so its not possible to use overlay here.

Regards,

Rakesh

0 Kudos

Hi Rakesh,

I didnt undestand what is single value, 100 ?

0 Kudos

Hi ravi,

one more question suppose the value is Ravi#@* Kiran.

the output should be Ravi Kiran.means i dont want to replace special characters with spaces.

Regards,

Rakesh

0 Kudos

HI.

Data : lv_field type string value ' Ravi#@* Kiran'.

REPLACE REGEX '[#]' IN lv_field WITH ''.

REPLACE REGEX '[@]' IN lv_field WITH ''.

REPLACE REGEX '[*]' IN lv_field WITH ''.

WRITE lv_field.

0 Kudos

Hi Ravi,

the above code is helpful but this will replace the special characters with space.the space present in the field should be there but  special characters should not be replaced with spaces.

Regards,

rakesh

0 Kudos

Hi Rakesh,

Please be specific what exactly you want..

Above post is according to your desired output.

0 Kudos

Hi Ravi,

actually m new in sap-abap.so its difficult to understand a few things.eg Ravi@#$  kiran.

output-Ravi  Kiran.here @#$ should not be replaced by space.but there are two spaces, those two spaces should be kept as it is.

Regards,

Rakesh

0 Kudos

Hi Rakesh,

In your output  what happened to @#$. where did they go?

0 Kudos

Hi Ravi,

those are replaced with spaces.

0 Kudos
regarding removing special characters

rakesh mandalGlass


Hi Ravi,

actually m new in sap-abap.so its difficult to understand a few things.eg Ravi@#$  kiran.

output-Ravi  Kiran.here @#$ should not be replaced by space.but there are two spaces, those two spaces should be kept as it is.

Regards,

Rakesh

you say should not replaced by space.Again you say replaced by space. please dont waste time.

0 Kudos

Hi Ravi,

sorry ravi,actually here these fields are getting replaced by space in the code u mentioned but i dont want that to happen.

0 Kudos

Hi ravi,

Thanks.the code is working fine.and sorry

Regards,

Rakesh

0 Kudos

Hi Rakesh,

Mark the answers as correct and helpful, so that it will be helpful for others who look into the post.


Regards,

Ravikiran.K

0 Kudos

Hi Rakesh,

Please mark answer as Helpful or correct .

Regards,

Ravikiran.K

0 Kudos

Ravi, this is a discussion 'Correct Answer' option can't be there..

0 Kudos

Hi Chandra,

Asking for marking Helpful answer. Some times you will have correct answer.

Regards,

Ravikiran.K

0 Kudos

If the Question is 'Marked as a Question' then only correct answer option will come otherwise no. And this question is not marked as 'Question'. 

0 Kudos

ok got it chandra..