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

Check on special characters

In my program, on the selection screen a user can enter any variable except special characters.How can I put a check on special characters??

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2009 at 12:22 PM

    in event AT SELECTION-SCREEN

    chk for the value in the selection screen input field and display message accordigly.

    like say

    parameter: p_input(20) type c.

    AT SELECTION_SCREEN

    if p_input ca '~!@#$%^&*()_+{}|:"<>?/.,';]['

    message 'whtever' type 'E'.

    endif.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2009 at 12:22 PM

    Use Var CA '!@#$%^&*'

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2009 at 12:23 PM
    DATA var TYPE string VALUE '2@dfdf'.
    IF var CO '0123456789abcdefghijklmnopqrstuvwxyz'.
      WRITE: 'No special character'.
    ELSE.
      WRITE: 'Special characters are there'.
    ENDIF.

    Edited by: Nitesh Kumar on Jan 15, 2009 6:01 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2009 at 12:25 PM

    Hi,

    try this,

    parameters: var(10) type c.

    at selection-screen.

    if var ca '!@#$%^&*(){[]}\|;:",<>/?'.

    message 'Error' type 'E'.

    endif.

    Regards,

    Venkatesh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2009 at 12:26 PM

    hi,

    In our key board, these many special characters present..

    so try your code like this..

    data: spe_char(31) value '~`!@#$%^&*()_+-=\|][{}";:,./?><'. ( include all

    special chars whatever u want)

    spe_char1 value ' '. ( this is to check empty space)

    spechar2. (this is to check single ' ).

    Create one text element and assign ' as value to that text element.

    in ur program code as given below.

    spechar2 = text-001.

    if (fieldname) CA spe_char.

    MESSAGE "special character is present in the given input

    endif.

    if ( fieldname) CA spe_char1.

    message "special character is present in the given input

    endif.

    if (fieldname) CA spe_char2.

    len = strlen( fieldname ).

    if sy-fdpos NE len.

    message "special character is present in the given input

    endif.

    endif.

    Hope this code will guide you ..

    regards

    vijay

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 15, 2009 at 12:27 PM

    Hi Priya,

    Hope... Now its clear.

    You can do it with help of agrregate functions CO or CA.

    For better knowledge see the table on this functins provided by f1 help.

    Thanks,

    Naveen.Inuganti.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2009 at 12:27 PM

    Hello

    if parameter1 co sy-acbde.
      write: 'without special characters'.
    else.
      write: 'with special characters'.
    endif.
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 15, 2009 at 12:29 PM

    Hi

    plz look at this .....this may help u lot

    data: spe_char(31) value '~`!@#$%^&*()_+-=\|][{}";:,./?><'. ( include all

    special chars whatever u want)

    spe_char1 value ' '. ( this is to check empty space)

    spechar2. (this is to check single ' ).

    Create one text element and assign ' as value to that text element.

    in ur program code as given below.

    spechar2 = text-001.

    if (fieldname) CA spe_char.

    MESSAGE e009(zsmessage).

    endif.

    if ( fieldname) CA spe_char1.

    message e009(zsmessage).

    endif.

    if (fieldname) CA spe_char2.

    len = strlen( fieldname ).

    if sy-fdpos NE len.

    message e009(zsmessage).

    endif.

    endif.

    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.