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

Checking a variable for Numeric field only

vivekkrishnan
Active Participant
0 Likes
570

Hi all ,

I am having a text variable .

I need to fill an internal table with it only if its a Numeric otherwise it shld not be considered .

Please advise .

Thanks in Advance .

Vivek K

1 ACCEPTED SOLUTION
Read only

former_member186741
Active Contributor
0 Likes
539

of course, you may also need to consider thousands seperaters (',') and embedded spaces.

5 REPLIES 5
Read only

Former Member
0 Likes
539

hi,

loop at itab.

if itab-field1 CO '0123456789'.

append itab to itab1.

endif.

endloop.

Thanks,

Naren

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
539

Depending on if you are checking the extra space in the field you may need to do this.

data: c(10) type c value '123.78'.
data: len type i.

len = strlen( c ).

if c+0(len) CO '0123456789.'.
* Ok, allow it.
endif.

REgards,

RIch Heilman

Read only

former_member186741
Active Contributor
0 Likes
540

of course, you may also need to consider thousands seperaters (',') and embedded spaces.

Read only

0 Likes
539

You can use numeric check or alternatively you can use the following code:

DATA : l_string TYPE string,

lv_lifex TYPE likp-lifex VALUE '10.001'.

MOVE 'abcdefghijklmnopqrstuvwxyz' TO l_string.

CONCATENATE l_string 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' INTO l_string.

CONCATENATE l_string

'`~!@#$%^&*()-_=+|\}]{["''";:/?>,<' INTO l_string.

IF lv_lifex CA l_string.

WRITE 😕 'Contains Characters'.

ELSE.

WRITE 😕 'Only Numeric'.

ENDIF.

For me CO dint work with '10.001' so I had to resort to the above to make it to work.

hith

Sunil Achyut

Message was edited by: Sunil Achyut

Read only

0 Likes
539

Hi

Just to add to our friends responses, you can use

FM: <b>CATS_NUMERIC_INPUT_CHECK</b> to check for pure numeric

values which will consider the decimal and unit

separator.

Kind Regards

Eswar