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

Need to validate to the Inputs in code

former_member229310
Active Participant
0 Likes
414

Hello All,

I need to validate the input given from format XXXXXXXXXX to XXX-XXX-XXXX.The system should take <b>only digits</b> and it should <b>not allow user to enter more than 10 digits</b>.Please help me in reaching the above requirements.

Also please tell me whether can I write my code after PAI.Does writing code like this validates the input given or where should i write my code..........Please suggest

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
387

In the PAI, write

CHAIN.

FIELD V_INPUT. "mention here the field name instead of V_INPUT

MODULE VALIDATE_INPUT.

ENDCHAIN.

MODULE VALIDATE_INPUT.

data : l_len type i,

l_counter type i.

l_len = strlen(V_INPUT).

if l_len gt 10.

message 'Invalid INput!'.

endif.

do.

l_var = v_input+l_counter(1).

if l_var lt 0 or l_var gt 10.

message 'Invalid Input!'.

endif.

l_counter = l_counter + 1.

if l_counter gt 10.

exit.

endif.

enddo.

ENDMODULE.

Hello All,

I need to validate the input given from format XXXXXXXXXX to XXX-XXX-XXXX.The system should take <b>only digits</b> and it should <b>not allow user to enter more than 10 digits</b>.Please help me in reaching the above requirements.

Also please tell me whether can I write my code after PAI.Does writing code like this validates the input given or where should i write my code..........Please suggest

1 REPLY 1
Read only

Former Member
0 Likes
388

In the PAI, write

CHAIN.

FIELD V_INPUT. "mention here the field name instead of V_INPUT

MODULE VALIDATE_INPUT.

ENDCHAIN.

MODULE VALIDATE_INPUT.

data : l_len type i,

l_counter type i.

l_len = strlen(V_INPUT).

if l_len gt 10.

message 'Invalid INput!'.

endif.

do.

l_var = v_input+l_counter(1).

if l_var lt 0 or l_var gt 10.

message 'Invalid Input!'.

endif.

l_counter = l_counter + 1.

if l_counter gt 10.

exit.

endif.

enddo.

ENDMODULE.