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 needed

Former Member
0 Likes
767

1. I have a field for pancard no which should allow you to enter "apup678n" ( alphanumeric only). It should not allow to enter the special character like $#%^&. How to validate this field?

2. I have a field called name which should allow you to enter only alphabets. How to validate this?

Thanks in advance.

Regards,

Pon Murugesh

6 REPLIES 6
Read only

Former Member
0 Likes
739

Hi,

if var cp sy-abcdef.

ur code

else.

message.

endif.

Plzz reward points if ithelps.

Read only

Former Member
0 Likes
739

Pon,

DATA : v_num TYPE i,

v_cnt TYPE i.

EX: PARAMETERS : p_pancard LIKE xxxxxxx.

AT SELECTION-SCREEN.

v_num = strlen( p_pancard ).

Do v_num TIMES.

v_cnt = v_cnt + 1.

IF p_pancard+o(v_cnt) CA '$#%^&.'.

Message e000(zmp).

ENDIF.

ENDDO.

Validation For Alphabets.

EX: PARAMETERS : p_alphabets LIKE xxxxxxx.

AT SELECTION-SCREEN.

v_num = strlen( p_alphabets ).

Do v_num TIMES.

v_cnt = v_cnt + 1.

IF p_alphabets+o(v_cnt) CA '0123456789'.

Message e000(zmp).

ENDIF.

ENDDO.

Don't forget to reward if useful....

Read only

Former Member
0 Likes
739

Hi,

For checking name, use sy-abcde. This will ensure only alphabets are there in the name.

Reward if Helpful.

Read only

Former Member
0 Likes
739

Hi dude,

Declare the PAN No., and Name fields to type c ,

if the entered value is not of the type C,the system will automatically generate error message.

I suppose you need not carry out any validations.

Reward if useful.

Regards,

Lakshmanan

Read only

0 Likes
739

Hi Laxmanan , i think the special charachters like #*% are also considered as characters so the system will accpet that.

Read only

Former Member
0 Likes
739

Hi,

For checking PAN number, please try the following.

data: pan_number(10) type c.

data: first_five_char(5) type c.

data: sixth_to_ninth(4) type c.

data: last_char(1) type c.

*for the characters of PAN card having 10 characters

*checking the first five characters to eb alphabets, the sixth to ninth as integers and the last character as an alphabet

first_five_char = pan_number+0(5).

sixth_to_ninth = pan_number+5(4).

last_char = pan_number+9(1).

*check whether the first five characters are alphabets

IF NOT ( first_five_char CO 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ' ).

MESSAGE S(001). "error message

ENDIF.

IF NOT ( sixth_to_ninth CO '1234567890' ).

MESSAGE S(002). "error message.

ENDIF.

IF NOT ( last_char CO 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ' ).

MESSAGE S(003). "error message

ENDIF.

Reward if Helpful.

Reward if Helpful.