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: 

validation

Former Member
0 Kudos
713

Hi,

In my customized screen,i have 3 fields..Each field is of size 10..First field is holding a phone number which is of data length 10..

Now i need to validate whether 10 digits are entered..If less than 10 digits entered means i want to throw error..

How to validate,give a sample code

1 ACCEPTED SOLUTION

former_member212653
Active Contributor
0 Kudos
300

check the string length...



data l_len type i.

l_len = strlen( v_field_name ).

6 REPLIES 6

former_member212653
Active Contributor
0 Kudos
301

check the string length...



data l_len type i.

l_len = strlen( v_field_name ).

kesavadas_thekkillath
Active Contributor
0 Kudos
300

at selection-screen on pa_phone.

check strlen( pa_phone ) < 10.

error

Former Member
0 Kudos
300

Hi,

try as follows,

s_pno is ur input.

take this into some variable and count the lenght of that number using string property. i.e.

lenght = strln(v_pno).

if lenght = 10.

proceed.

else.

error message.

endif.

Regards,

kk.

Former Member
0 Kudos
300

Hi Mahesh,

Take the phone number type a char of lenght 10.

Now get the length of that string and validate it as shown below.

parameter phno(10) type c.

data len type i.

len = strlen( phno ).

if len < 10.

Message e000(0) WITH 'ENTER 10 DIGIT NUMBER'.

ENDIF.

This will help you.

Reward points if useful.

Thanks,

Khan.

Former Member
0 Kudos
300

Hi,

Ensure that you have defined the screen field as NUMC and not character otherwise the user will be able to enter characters and you will also need to validate that only digits are entered.

Other than the above validation you need to check the length of the input in the field in the PAI.

create a a module validation just after PAI. and use the strlen function. however you need to convert the numeric to charcater and then shift the field left deleting leading zeros n then check the lenght : see the example program below :


REPORT  Z_VALIDATE                              .
parameters phone(10) type n.

data phone_char(10) type c.
data len type i.
phone_char = phone.
shift phone_char left deleting leading '0'.
condense phone_char.
len = strlen( phone_char ).
if len < 10.
message 'Incorrect entry. Less than 10 numbers' type 'E'.
endif.

regards,

Advait

Former Member
0 Kudos
300

Thanks