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: 

a numeric or not

Former Member
0 Kudos

hello,

i need to check a constantes of 2 character if it's a NUMBER or not ; is there a MF or a method wich do this.

thank you for help.

1 ACCEPTED SOLUTION

former_member156446
Active Contributor
0 Kudos

data: var type C value '02'.

if var+0(1) ca sy-abcde and var+1(1) ca sy-abcde.
write: its not a character.
endif.

6 REPLIES 6

Former Member
0 Kudos

Hi,

You dont need a method or a FM to do this. Jus go with the simple IF stmt.

IF c_num CO '0123456789'.

.....

.....

ENDIF.

0 Kudos

So 1234.56 would fail your test.

Rob

0 Kudos

Yes forgot to mention tat. Add a '.' too.

Data: l_num(6) TYPE c value '123.56'.

if l_num CO '0123456789.'.

write 😕 'Success'.

else.

write 😕 'failure'.

endif.

0 Kudos

And -123.12 ?

Or 123,12 ?

0 Kudos

... and 1234.56.789 would pass.

So the point is that the OP has to decide what his or her numbers should consist of. At that point it will be easy to code.

Rob

former_member156446
Active Contributor
0 Kudos

data: var type C value '02'.

if var+0(1) ca sy-abcde and var+1(1) ca sy-abcde.
write: its not a character.
endif.