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

Number Validation

Former Member
0 Likes
653

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
Read only

Former Member
0 Likes
581

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
Read only

Former Member
0 Likes
581

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.

Read only

Former Member
0 Likes
582

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

Read only

0 Likes
581

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.

Read only

Former Member
0 Likes
581

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