Application Development 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: 

Number Validation

Former Member
0 Kudos

Hi All,

Is there any function module to validate a given value is number or not? (Fm to validate a number).

Thx

- Senthil Bala

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

I don't think so, but you can simply check of the variable contains anything else other than 0 to 9. That will tell you if there are non-numeric characters.

Amit's code is not taking care of the special characters.

regards,

Ravi

note : Please mark the helpful answers

Message was edited by: Ravikumar Allampallam

4 REPLIES 4

Former Member
0 Kudos

Hi senthil,

1. we can use this kind of logic.

2. just copy paste in new program.

It will give X , if number, other wise blank

3.

report abc.

parameters : n(10) type c.

data : flag type c.

perform isnumber using n flag.

write 😕 flag.

*----


form isnumber using str flag.

flag = 'X'.

if str ca sy-abcde.

flag = ''.

endif.

endform.

regards,

amit m.

Former Member
0 Kudos

Hi,

I don't think so, but you can simply check of the variable contains anything else other than 0 to 9. That will tell you if there are non-numeric characters.

Amit's code is not taking care of the special characters.

regards,

Ravi

note : Please mark the helpful answers

Message was edited by: Ravikumar Allampallam

0 Kudos

Hi,

A small modification to Amit's code.

PARAMETERS: check(12).

IF check <b>CO '0123456789 '</b>.
  WRITE 'Numbers'.
ELSE.
  WRITE 'Non numeric'.
ENDIF.

Regards,

Wenceslaus.

former_member184569
Active Contributor
0 Kudos

Hi Senthil.

You can do it this way.

data : numeric_data(10) TYPE c VALUE '0123456789'.

IF infile-order CO numeric_data.

/* Contains only numerals

else.

/* Is alphanumberic.

Endif.

Regards,

Susmitha