‎2013 Jun 04 12:42 PM
In my module pool program there is one field for employee number .
if we give two numbers as input it is accepting
Actual condition is it shouldn't accept numbers less than six digits.
how to make the field validation according to the condition.
‎2013 Jun 04 1:32 PM
HI Narasimha,
try this sample code..
IF STRLEN( your_emp_number ) LT 6.
Error Message...
ENDIF.
Regards,
Mordhwaj
‎2013 Jun 04 1:32 PM
HI Narasimha,
try this sample code..
IF STRLEN( your_emp_number ) LT 6.
Error Message...
ENDIF.
Regards,
Mordhwaj
‎2013 Jun 04 1:34 PM
Hi Narashima,
Get the string length if it is less than 6 ,
give an error message.
as below,
DATA : p_empno TYPE char10.
DATA : lv_len TYPE i.
p_empno = '1234'.
lv_len = strlen( p_empno ).
IF lv_len < 6.
MESSAGE 'Incorrect lenght' TYPE 'E'.
ENDIF.
Thanks,
Kannan N
‎2013 Jun 04 1:35 PM
Hi,
Use the Function STRLEN to get field length.
Eg:
data : lv_val type c length 5 default 'ABCDE',
lv_length type i.
lv_length = strlen ( lv_val ).
Write 😕 lv_length.
Ouput would be 5. lv_length has value 5.
BR,
Ankit.
‎2013 Jun 04 1:35 PM
Hi Narasimha,
One way to achieve this is through string manipulation.
1. We shall pass the entered employee number on screen to a string variable.
2. Get the length of that string variable.
3. Validate whether the length is greater than 6. If it is less than 6, then raise an error message.
For syntax to get length of string variable, use F1 help.
With Regards,
Gurulakshmi
‎2013 Jun 04 1:44 PM
Hi Narasimha,
For the above mentioned validation you can put condition in PAI like
if (emp_no > 99999).
{
only then accept emp_no
}
else.
{
give error message.
skip/exit.
}
or
condition can be modified like if(emp_no >= 100000).
then accept the employee nos.
Hope it helps!!!!
Regards,
Alora Sahu
‎2013 Jun 04 1:56 PM
‎2013 Jun 04 3:06 PM
In PAI, validate the screen field value.
PROCESS AFTER INPUT.
CHAIN.
if STRLEN ( Screen-Field) LT 6.
Message: 'Less than 6 character not allowed !'.
endif.
ENDCHAIN.
‎2013 Jun 04 7:46 PM
Place the codes in PAI
if screen field LT 6 " means
Error Message
Else.
" Proceed further
Endif.
you can place the code inside of chain endchain statement also
Regards,
Bastin.G
‎2013 Jun 04 8:55 PM
Hi
Go to Screen Section - PAI (Process After Input)
FIELD <Your field name> MODULE <your module name>.
In Program section,
MODULE <your module name> INPUT.
Your logic goes here..
If Employee number is < 100000 ( ie lesser than 6 digits)
MESSAGE 'Minimum length of employee number is 6 digits...' TYPE 'S' DISPLAY LIKE 'E'.
endif.
ENDMOUDLE.
Regards,
Venkat
‎2013 Jun 05 10:29 AM
parameter: p_empno(10) type c.
data: lv_len type i.
at selection-screen.
lv_len = strlen( p_empno ).
if lv_len LT 6.
Message 'Employee number must be greater than 6 characters' type 'E'.
endif.