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

How to check whether a string includes only numeric characters.

Former Member
0 Likes
1,166

Hi,

I need to write a function module which judges whether a string includes only numeric characters.

Import: a string

Export:

- True: If this is a numeric string

- False: The string includes non-numeric characters

Thanks in advance!

Best REgards, Johnney.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,112

Also you can check FM: NUMERIC_CHECK.

~Eswar

Hi,

I need to write a function module which judges whether a string includes only numeric characters.

Import: a string

Export:

- True: If this is a numeric string

- False: The string includes non-numeric characters

Thanks in advance!

Best REgards, Johnney.

6 REPLIES 6
Read only

Former Member
0 Likes
1,112

search before posting

its as simple as checking

xx co ( 1234567890 )

Read only

Former Member
0 Likes
1,112


DATA: text(10).
text = '0123456789'.

  IF string CA text.
write:/ 'numeric'.
else. 
write:/ non-numeric'.
endif.

Read only

0 Likes
1,112

CA is incorrect, it needs ot be CO


DATA: text(10).
text = '0123456789'.
 
  IF string CA text.   <----------  should be CO instead of  CA
write:/ 'numeric'.
else. 
write:/ non-numeric'.
endif.

Read only

0 Likes
1,112

Yes you are correct my mistake

Read only

Former Member
0 Likes
1,113

Also you can check FM: NUMERIC_CHECK.

~Eswar

Read only

Former Member
0 Likes
1,112

Hi ,

Try using this FM.

data in_string type string.

data out_string type string.

data h_type type string.

CALL FUNCTION 'NUMERIC_CHECK'

EXPORTING

string_in = in

IMPORTING

STRING_OUT = out

HTYPE = h_type.

if h_type = 'CHAR'.

WRITE:/ 'Not Numeric'.

else.

write:/ 'Numeric'.

ENDIF.

Hope this will be useful for you.

Regards,

Rohit