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

Validation

Former Member
0 Likes
841

I m having a field projectname type c of length 50.

I should not allow the user to enter the project name which contain special character.

i tried with CO with sy-abcde its not working correctly since i have used length 50.

if i want to use sy-abcde means the string must grow dynamically, but here project name is a keyfield so i m not able to use string type .

Can any one help me to solve it.

Thanks in advance.

Kalpanashri Rajendran.

1 ACCEPTED SOLUTION
Read only

anversha_s
Active Contributor
0 Likes
806

hi,

pls try this.

if l_string CA 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
write : 'String has a character'.
endif.

<b>please refer this thread.

https://forums.sdn.sap.com/click.jspa?searchID=234253&messageID=2685281</b>;

rgds

Anver

6 REPLIES 6
Read only

anversha_s
Active Contributor
0 Likes
807

hi,

pls try this.

if l_string CA 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
write : 'String has a character'.
endif.

<b>please refer this thread.

https://forums.sdn.sap.com/click.jspa?searchID=234253&messageID=2685281</b>;

rgds

Anver

Read only

Former Member
0 Likes
806

Hi,

I think sy-abcde should work.

Try the following -


parameters p_proj(50).

data lv_ptoject(50) type c.

at selection-screen.
  lv_project = p_proj.
  condense lv_project no-gaps.
  if not lv_project CO sy-abcde.
    "Error Message"
  endif.

Hope that helps.

Regards,

Anand Mandalika.

Read only

Former Member
0 Likes
806

use <b>SEARCH <c> FOR <str> <options>.</b>

regards,

aswin.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
806

Hi,

data : alphanumeric(38).

parameters fname(4).

AT SELECTION-SCREEN ON fname.

IF fname CA '0123456789' and fname ca sy-abcde.

message e000(zhrt) with 'alphanumeric'.

elseif fname ca '0123456789'.

message e000(zhrt) with 'no'.

elseif fname ca sy-abcde.

message e000(zhrt) with 'alphabet'.

ENDIF.

Read only

Former Member
0 Likes
806

Hi Rajendran,

I hope the following code will helps to you.

If you want check with special character group.

[code]DATA:

c_schar_grp TYPE char50 VALUE '~`!@#$%^&*()_+=-{[}]"':;?/>. <,', " Special character set

IF plv_projname CN c_schar_grp.

Message 'Error Please avoid Special character' TYPE 'E'.

ENDIF.[/code]

If you want check with character group.

[code]DATA:

c_alphanumc TYPE char69

VALUE 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'. " Alphanumc Group

IF plv_projname CO c_alphanumc.

  • --- define your code here.

ELSE.

  • --- Raise error

ENDIF.[/code]

Regards

Bhupal Reddy

Message was edited by:

Bhupal Reddy Vendidandi

Message was edited by:

Bhupal Reddy Vendidandi

Read only

Former Member
0 Likes
806

Hi

I have tested it. It's working fine. Check it out.

PARAMETERS P_PROJECT(50).

DATA V_PROJECT TYPE STRING.

AT SELECTION-SCREEN OUTPUT.

V_PROJECT = p_PROJECT.

CONDENSE V_PROJECT NO-GAPS.

IF NOT V_PROJECT CO sy-abcde.

MESSAGE 'Wrong Input' TYPE 'E'.

ENDIF.

--> You will get error message when you give input with special character

Regards

Surya.