10-07-2008 4:11 PM
Hi,
I have a field type c and length 5.
I want to check if the contents of this field are number or not, how do i achieve it.
Ex: if that field has 2000, then I want to identify it...
Please help me with the logic,
Thanks,
CD..
10-07-2008 4:15 PM
IF LV_VAR CA '0123456789'.
* this has numbers
ENDIF.
You can use other operators aswell like CO - Contains Only etc etc
-Aman
10-07-2008 4:15 PM
IF LV_VAR CA '0123456789'.
* this has numbers
ENDIF.
You can use other operators aswell like CO - Contains Only etc etc
-Aman
10-07-2008 4:19 PM
10-07-2008 4:19 PM
One option would be to catch the CONVT_NO_NUMBER exception whilst moving the characters into a numeric field:
parameters:
p_char(5) type c.
end-of-selection.
data:
lv_int type i.
catch SYSTEM-EXCEPTIONS
convt_no_number = 1.
lv_int = p_char.
endcatch.
if sy-subrc = 0.
write: 'It is a number.', /.
else.
write: 'It is not a number.', /.
endif.
10-07-2008 4:23 PM