Skip to Content
author's profile photo Former Member
Former Member

special character deletion issue

Hi all,

I have a text field which contains special characters which are not being entered by key board. I would like to repalce those chars. system is displaying these spl chars as '#'. I have used function module 'SCP_REPLACE_STRANGE_CHARS' , but it is replacing all the specail chars to dots(.), due to this if I have any valid chinese or japanese chars those are also getting replaced.

pls any can help me out to resolve this issue.

Thanks in advance

reddi

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 09:13 AM

    If you have to replace only one charactter '#'. Use replace statement otherwise use replace all occurrences of.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 09:27 AM

    hello there

    u can also read that into a variable and check if its got any '#' and replace them.

    for eg: lv_text = 34jhgfdk#

    if lv_text ca '#'.

    <do smthing>

    endif.

    regards

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 09:29 AM

    Hi,

    Try like this...

    
    data : lv_special_chars type char50 value '' ' _  ! " & / = + : , - ( ) # @ % ^ $ | ~'. 
    " maintain what are the special characters want to remove
     
    translate lv_field_value using lv_special_chars.
    
    
    

    Hope its helps

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 09:29 AM

    Use FM SF_SPECIALCHAR_DELETE

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 09:31 AM

    sample code will delete all # characters from the char variable.

    REPORT ztn_test LINE-COUNT 100.
    
    data: char(20) VALUE '1k##23kjh#ll'.
    
    REPLACE ALL OCCURRENCES OF REGEX '#' in char WITH ' '.
    
    
    WRITE char.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 09:36 AM

    hi,

    if you want use this fm

    code as like below

    check this program

    RFFORI99

    or

    use like below

    form special_character changing p_text_in p_text_out.

    call function 'SCP_REPLACE_STRANGE_CHARS'

    exporting

    intext = p_text_in

    • INTEXT_LG = 0

    • INTER_CP = '0000'

    • INTER_BASE_CP = '0000'

    • IN_CP = '0000'

    • REPLACEMENT = 46

    importing

    outtext = p_text_out

    • OUTUSED =

    • OUTOVERFLOW =

    exceptions

    invalid_codepage = 1

    codepage_mismatch = 2

    internal_error = 3

    cannot_convert = 4

    fields_not_type_c = 5

    others = 6.

    if sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    endif.

    endform. " special_character

    Thanks and regards

    durga.K

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 10:06 AM

    Hi vrreddi,

    data:

    w_str type string value '!@#$%^&*()asfdfagfh'.

    w_count type i,

    w_len type i,

    w_off type i.

    w_len = strlen( w_str ).

    do w_len times.

    w_char = w_str+w_off(1).

    if w_char CA '!@#$%^&*()_+{}[]?/><'.

    replace w_char with space into w_str.

    endif.

    add 1 to w_off.

    condense w_str no-gaps.

    enddo.

    Hope it helps....

    Regards,

    Mdi.Deeba

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.