2008 May 21 9:27 AM
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
2008 May 21 9:31 AM
check the string length...
data l_len type i.
l_len = strlen( v_field_name ).
2008 May 21 9:31 AM
check the string length...
data l_len type i.
l_len = strlen( v_field_name ).
2008 May 21 9:35 AM
at selection-screen on pa_phone.
check strlen( pa_phone ) < 10.
error
2008 May 21 9:36 AM
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.
2008 May 21 9:40 AM
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.
2008 May 21 10:14 AM
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
2008 May 21 10:55 AM