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

check var

Former Member
0 Likes
985

is there a way to know if a var contain char or digits ?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
953

Hi,

try : C14W_CHAR_NUMBER_CONVERSION

is there a way to know if a var contain char or digits ?

6 REPLIES 6
Read only

rejish_balakrishnan
Contributor
0 Likes
953

HI,

U can use CO(contains only operator to analysis it_

If var CO '1234567890'.

flag = digits.

endif.

and.

if var CO sy-abcde "abcdefg......z"

flag = char.

endif.

Read only

amit_khare
Active Contributor
0 Likes
953

For digits you can check -

if var co '1234567890'.

for character you may check

if var CO sy-abcde.

Read only

Former Member
0 Likes
954

Hi,

try : C14W_CHAR_NUMBER_CONVERSION

Read only

Former Member
0 Likes
953
Data: w_no(10) type n
parameters: w_char(20) type .


W_no = w_char.

If w_no is initial.
Write : / W_char, 'Contains Characters'.
Else.
Write : / W_char, 'Contains Numbers'.
Endif.

Or.

Check for w_char CO '1234567890' and w_char co SY-ABCDE.

Regards,

Gurpreet

Read only

Former Member
0 Likes
953

hi,

also u can use

FM :

NUMERIC_CHECK

or you can use tghis logic

If string CO '0123456789' .

message only numbers.

endif.

if string CA sy-abcde.

message only letters.

endif.

Also refer the following thread:

thanks

Read only

Former Member
0 Likes
953

Hi ,

You can check like:

-> create one range for checking digits:

r_digit type i.

r_digit-low = 0.

r_digit-high = 9.

r_digit-sign = BT.

append r_digit.

->Then write:

var1( variable name) CA(Contains any) sy-abcde or r_digit.

Hope it helps

Regrds

Mansi