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

Module pool Field Validation

0 Likes
2,669

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,872

HI Narasimha,

try this sample code..

IF STRLEN( your_emp_number ) LT 6.

  Error Message...

ENDIF.

Regards,

Mordhwaj

10 REPLIES 10
Read only

Former Member
0 Likes
1,874

HI Narasimha,

try this sample code..

IF STRLEN( your_emp_number ) LT 6.

  Error Message...

ENDIF.

Regards,

Mordhwaj

Read only

Former Member
0 Likes
1,872

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

Read only

Former Member
0 Likes
1,872

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.

Read only

Former Member
0 Likes
1,872

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

Read only

Former Member
0 Likes
1,872

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

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,872

Why don't you check the employee number with a HR infotype ?

Regards;

Raymond

Read only

satyabrata_sahoo3
Contributor
0 Likes
1,872

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.

Read only

bastinvinoth
Contributor
0 Likes
1,872

Hi Narasimha Swamy

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

Read only

venkateswaran_k
Active Contributor
0 Likes
1,872

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

Read only

Former Member
0 Likes
1,872

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.