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: 

How to identify contents of a character field.

Former Member
0 Kudos

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..

1 ACCEPTED SOLUTION

Former Member
0 Kudos
IF LV_VAR CA '0123456789'.
* this has numbers
ENDIF.

You can use other operators aswell like CO - Contains Only etc etc

-Aman

4 REPLIES 4

Former Member
0 Kudos
IF LV_VAR CA '0123456789'.
* this has numbers
ENDIF.

You can use other operators aswell like CO - Contains Only etc etc

-Aman

0 Kudos

Thanks aman

Former Member
0 Kudos

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.

0 Kudos

thanks