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

Function module to check whether the input field value is numeric or not

Former Member
0 Likes
4,120

Hi,

I wanted to check whether the input field has the numeric value or not. What is the function module to check whether it is numeric field or not.

1 ACCEPTED SOLUTION
Read only

anversha_s
Active Contributor
0 Likes
1,525

hi,

<b>CATS_NUMERIC_INPUT_CHECK</b>

or

You can use the Function Module:

<b>numeric_check.</b>

Usage:

CALL FUNCTION 'NUMERIC_CHECK'
EXPORTING
STRING_IN = X
IMPORTING
STRING_OUT = X
HTYPE = H_TYPE.
if h_type = 'CHAR'.


WRITE:/ 'NOt Numeric'.
else.
write:/ 'Numeric'.
ENDIF

*****<b>With out Any FM</b>*******

data: field(10) type c value '1%56539'. 
data: length type i. length = strlen( field ). 
if field(length) co '1234567890'. 
write:/ 'This is a number'.
 else. 
write:/ 'This is not a number'. endif.

******************

You can even use CATS_NUMERIC_INPUT_CHECK


* Check for Numeric Value
 
call function 'CATS_NUMERIC_INPUT_CHECK'
 exporting
   input = t_return-fieldval
 exceptions
   no_numeric = 1
   others = 2.
 
if sy-subrc = 0.
read table t_f4_table index t_return-fieldval.
endif.

rgards

Anver

<b><i>Kinly mark points if ur issue solved</i></b>

2 REPLIES 2
Read only

anversha_s
Active Contributor
0 Likes
1,526

hi,

<b>CATS_NUMERIC_INPUT_CHECK</b>

or

You can use the Function Module:

<b>numeric_check.</b>

Usage:

CALL FUNCTION 'NUMERIC_CHECK'
EXPORTING
STRING_IN = X
IMPORTING
STRING_OUT = X
HTYPE = H_TYPE.
if h_type = 'CHAR'.


WRITE:/ 'NOt Numeric'.
else.
write:/ 'Numeric'.
ENDIF

*****<b>With out Any FM</b>*******

data: field(10) type c value '1%56539'. 
data: length type i. length = strlen( field ). 
if field(length) co '1234567890'. 
write:/ 'This is a number'.
 else. 
write:/ 'This is not a number'. endif.

******************

You can even use CATS_NUMERIC_INPUT_CHECK


* Check for Numeric Value
 
call function 'CATS_NUMERIC_INPUT_CHECK'
 exporting
   input = t_return-fieldval
 exceptions
   no_numeric = 1
   others = 2.
 
if sy-subrc = 0.
read table t_f4_table index t_return-fieldval.
endif.

rgards

Anver

<b><i>Kinly mark points if ur issue solved</i></b>

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
1,525

Hi,

If it is type I or integer type then you can use

DATA: integer type i,

var1 type string.

var1 = integer

if var1 CO '0123456789.

  • its numberic

endif.

Regards,

Sesh