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: 

digits

Former Member
0 Kudos

hi i have a 6 char field .

in that i have to check each character is a char or numeric .

pls help me

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

declare 2 variables:

data: char(26) type c value 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',

num(9) type value '1234567890',

str(6) type c value 'ABF123'.

now use the string comparison paramters like CS,CO,CN etc and check

if str CS char or Str CO num.

.............

endif.

Regards

Anji

6 REPLIES 6

Former Member
0 Kudos

USING SEARCH SYNTAX U CAN EASY FIND EASYLY DO.

Former Member
0 Kudos

Hi

declare 2 variables:

data: char(26) type c value 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',

num(9) type value '1234567890',

str(6) type c value 'ABF123'.

now use the string comparison paramters like CS,CO,CN etc and check

if str CS char or Str CO num.

.............

endif.

Regards

Anji

JozsefSzikszai
Active Contributor
0 Kudos

hi Chaaya,

IF string CO '0123456789'.

==> it is number

ELSE.

==> it is something else (i. e. not only numbers)

ELSE.

if you have to do it character by character, than you can do in a DO-ENDDO.

hope thishelps

ec

Former Member
0 Kudos

do.

try

if string(sy-index) IN '0123456789'.

write: / string(sy-index) ' is a number'.

else

write: / string(sy-index) ' is not a number'.

catch CX_root.

exit.

endtry.

enddo.

*reward if solved*

Former Member
0 Kudos

data: cnt type i value 0.

do 6 times.

if str+cnt(1) CO '0123456789'.

message i000.

endif.

enddo.

Hope dis helps..

Reward if it does

Former Member
0 Kudos

Hi,

Try like this:

data: v_string(15) type c value 'BHASKAR2006'.

data : str(10) type c.

str = v_string+0(5).

write str.

if str CA sy-abcde.

write 'Characters'.

else.

write 'Numerics'.

endif.

Regards,

Bhaskar