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

a numeric or not

Former Member
0 Likes
791

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
Read only

former_member156446
Active Contributor
0 Likes
762

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
Read only

Former Member
0 Likes
762

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.

Read only

0 Likes
762

So 1234.56 would fail your test.

Rob

Read only

0 Likes
762

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.

Read only

0 Likes
762

And -123.12 ?

Or 123,12 ?

Read only

0 Likes
762

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

Read only

former_member156446
Active Contributor
0 Likes
763

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.