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

Check for input validation

Karan_Chopra_
Active Participant
0 Likes
1,419

how can i check that value entered in input field is numeric n it shud give error if value is non numeric

14 REPLIES 14
Read only

Former Member
0 Likes
1,386

Hi karan,

1. u can use the FM NUMERIC_CHECK

2. To give error messge u can use like this.

message 'Enter numeric value' type 'E'.

regards,

amit m.

Read only

Former Member
0 Likes
1,386

the validation check is built-in, if u declare the input field as numeric.

Reward if useful.

Read only

Former Member
0 Likes
1,386

try this code..

PARAMETERS : num TYPE char20.

IF num CA sy-abcde.

MESSAGE 'ERROR IN INPUT' TYPE 'S'.

ELSE.

MESSAGE 'INPUT OK' TYPE 'S'.

ENDIF

Read only

Former Member
0 Likes
1,386

Hi,

You can declare a parameter of type i, p, or n.

System automatically check for the validation.

Thanks,

Sriram Ponna.

Read only

Karan_Chopra_
Active Participant
0 Likes
1,386

acctually i need to chk for quantity field

type packed with 3 decimal places

is there a FM for that

Read only

0 Likes
1,386

Ok..then

If your field is type P with 3 decimals you need not do any checks...

Read only

sachin_mathapati
Contributor
0 Likes
1,386

Hi Karan,

You can check weather a field is numeric or not by using function contains any(CA).

Eg.

if test CA '0123456789'.

*raise error

endif.

Reward points if Helpful.

Regards,

Sachin

Read only

Karan_Chopra_
Active Participant
0 Likes
1,386

i need to chk 4 general value not a single value

how can i chk for a type in dat field

the assignment is

ls_plantdata-reorder_pt = int_table-nvalue.

the thing is int_table-nvalue is char type from table control

and ls_plantdata-reorder_pt is quan i cant change int_table-nvalue to quan bt need to chk it b4 assinment only as it gives dump after assignment

Read only

0 Likes
1,386

Right...do like this..

IF int_table-nvalue CA sy-abcde.

"Do not assign.

ELSE.

"assign value.

ls_plantdata-reorder_pt = int_table-nvalue.

ENDIF.

Read only

Karan_Chopra_
Active Participant
0 Likes
1,386

this only checks 4 alphanumeric values

i need to chk 4 other characters also

i mean only num value till 3 decimals needs to be added

Read only

0 Likes
1,386

If you want check for other characters as well along with Alphabets, use the below (Slight modfication to Pervez)

IF int_table-nvalue CN '0123456789'.

"Do not assign.

ELSE.

"assign value.

ls_plantdata-reorder_pt = int_table-nvalue.

ENDIF.

I think u got my point, reward if useful

Pra

Read only

Former Member
0 Likes
1,386

Hi Karan,

I did not get ur requirement but if the question deals with selection screens, I have an answer for it.

before u do all these things, first you need to trigger an event called AT SELECTION-SCREEN.

example code is :

AT SELECTION-SCREEN.

IF (fld name) > (value) -


> any logic which u need

message

endif.

Read only

Karan_Chopra_
Active Participant
0 Likes
1,386

the assignment is

ls_plantdata-reorder_pt = int_table-nvalue.

the thing is int_table-nvalue is char type from table control

and ls_plantdata-reorder_pt is quan i cant change int_table-nvalue to quan bt need to chk it b4 assignment only as it gives dump after assignment

Read only

Karan_Chopra_
Active Participant
0 Likes
1,386

its wont wrk bcoz i need to enter packed value

like 1.229 so single decimal needs to be included also

bt again problem comes if we enter 12..3 ie two decimals