05-04-2006 6:12 AM
Hi All,
Is there any function module to validate a given value is number or not? (Fm to validate a number).
Thx
- Senthil Bala
05-04-2006 6:17 AM
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
05-04-2006 6:16 AM
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.
05-04-2006 6:17 AM
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
05-04-2006 6:24 AM
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.
05-04-2006 6:23 AM
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